Skip to content

Commit

Permalink
Merge pull request #4 from GatorQue/master
Browse files Browse the repository at this point in the history
Added multimap/multiset containers
  • Loading branch information
jwellbelove committed Jun 23, 2015
2 parents 92f6f14 + f3ec399 commit 89f85d9
Show file tree
Hide file tree
Showing 22 changed files with 6,635 additions and 176 deletions.
1 change: 0 additions & 1 deletion fnv_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://github.com/ETLCPP/etl
Copyright(c) 2014 jwellbelove
Expand Down
88 changes: 5 additions & 83 deletions imap.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,16 +433,6 @@ namespace etl
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;


//*************************************************************************
/// Assignment operator.
//*************************************************************************
imap& operator = (const imap& rhs)
{
assign(rhs.cbegin(), rhs.cend());

return *this;
}

//*************************************************************************
/// Gets the beginning of the map.
//*************************************************************************
Expand Down Expand Up @@ -779,7 +769,7 @@ namespace etl
///\param position The position that would precede the value to insert.
///\param value The value to insert.
//*********************************************************************
iterator insert(iterator position, const value_type& value)
iterator insert(iterator, const value_type& value)
{
// Default to no inserted node
Node* inserted_node = nullptr;
Expand All @@ -790,7 +780,7 @@ namespace etl
Data_Node& node = allocate_data_node(value);

// Obtain the inserted node (might be nullptr if node was a duplicate)
inserted_node = insert_node(find_node(root_node, position.p_node), node);
inserted_node = insert_node(root_node, node);
}
else
{
Expand All @@ -811,7 +801,7 @@ namespace etl
///\param position The position that would precede the value to insert.
///\param value The value to insert.
//*********************************************************************
iterator insert(const_iterator position, const value_type& value)
iterator insert(const_iterator, const value_type& value)
{
// Default to no inserted node
Node* inserted_node = nullptr;
Expand All @@ -822,7 +812,7 @@ namespace etl
Data_Node& node = allocate_data_node(value);

// Obtain the inserted node (might be nullptr if node was a duplicate)
inserted_node = insert_node(find_node(root_node, position.p_node), node);
inserted_node = insert_node(root_node, node);
}
else
{
Expand Down Expand Up @@ -1151,7 +1141,7 @@ namespace etl
}
}

// Return root node if nothing or duplicate was found
// Return root node if nothing was found
return root_node;
}

Expand Down Expand Up @@ -1324,36 +1314,6 @@ namespace etl
return lower_node;
}

//*************************************************************************
/// Find the node whose key is not considered to go before the key provided
//*************************************************************************
const Node& find_lower_node(const Node* position, const key_value_parameter_t& key) const
{
// Something at this position? keep going
const Node* lower_node = position;
while (lower_node)
{
// Downcast lower node to Data_Node reference for key comparisons
const Data_Node& data_node = imap::data_cast(*lower_node);
// Compare the key value to the current lower node key value
if (node_comp(key, data_node))
{
lower_node = lower_node->children[kLeft];
}
else if (node_comp(data_node, key))
{
lower_node = lower_node->children[kRight];
}
else
{
break;
}
}

// Return the lower_node position found
return lower_node;
}

//*************************************************************************
/// Find the node whose key is considered to go after the key provided
//*************************************************************************
Expand Down Expand Up @@ -1392,44 +1352,6 @@ namespace etl
return upper_node;
}

//*************************************************************************
/// Find the node whose key is considered to go after the key provided
//*************************************************************************
const Node* find_upper_node(const Node* position, const key_value_parameter_t& key) const
{
// Keep track of parent of last upper node
const Node* upper_node = nullptr;
// Start with position provided
const Node* node = position;
while (node)
{
// Downcast position to Data_Node reference for key comparisons
const Data_Node& data_node = imap::data_cast(*node);
// Compare the key value to the current upper node key value
if (node_comp(key, data_node))
{
upper_node = node;
node = node->children[kLeft];
}
else if (node_comp(data_node, key))
{
node = node->children[kRight];
}
else if (node->children[kRight])
{
upper_node = find_limit_node(node->children[kRight], kLeft);
break;
}
else
{
break;
}
}

// Return the upper node position found (might be nullptr)
return upper_node;
}

//*************************************************************************
/// Insert a node.
//*************************************************************************
Expand Down
Loading

0 comments on commit 89f85d9

Please sign in to comment.