468 typedef TKey key_type;
469 typedef TKey value_type;
472 typedef value_type& reference;
473 typedef const value_type& const_reference;
477 typedef value_type* pointer;
478 typedef const value_type* const_pointer;
479 typedef size_t size_type;
515 return compare(key,
node.value);
522 return compare(
node.value, key);
529 return compare(key,
node.value);
543 static Data_Node* data_cast(Node* p_node)
545 return static_cast<Data_Node*
>(p_node);
551 static Data_Node& data_cast(Node&
node)
553 return static_cast<Data_Node&
>(
node);
559 static const Data_Node* data_cast(
const Node* p_node)
561 return static_cast<const Data_Node*
>(p_node);
567 static const Data_Node& data_cast(
const Node&
node)
569 return static_cast<const Data_Node&
>(
node);
585 , p_node(ETL_NULLPTR)
591 , p_node(ETL_NULLPTR)
603 , p_node(
other.p_node)
613 p_set->next_node(p_node);
620 p_set->next_node(p_node);
626 p_set->prev_node(p_node);
633 p_set->prev_node(p_node);
640 p_node =
other.p_node;
644 reference operator *()
const
646 return iset::data_cast(p_node)->value;
649 pointer operator &()
const
651 return &(iset::data_cast(p_node)->value);
654 pointer operator ->()
const
656 return &(iset::data_cast(p_node)->value);
661 return lhs.p_set ==
rhs.p_set &&
lhs.p_node ==
rhs.p_node;
690 , p_node(ETL_NULLPTR)
696 , p_node(ETL_NULLPTR)
708 , p_node(
other.p_node)
714 , p_node(
other.p_node)
724 p_set->next_node(p_node);
731 p_set->next_node(p_node);
737 p_set->prev_node(p_node);
744 p_set->prev_node(p_node);
751 p_node =
other.p_node;
755 const_reference operator *()
const
757 return iset::data_cast(p_node)->value;
760 const_pointer operator &()
const
762 return iset::data_cast(p_node)->value;
765 const_pointer operator ->()
const
767 return &(iset::data_cast(p_node)->value);
772 return lhs.p_set ==
rhs.p_set &&
lhs.p_node ==
rhs.p_node;
796 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
798 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
799 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
895 return reverse_iterator(
iterator(*
this));
917 const_reverse_iterator
rend()
const
933 const_reverse_iterator
crend()
const
945 template <
typename TIterator>
967 return find_node(
root_node, key) ? 1 : 0;
973 size_type
count(
const K& key)
const
975 return find_node(
root_node, key) ? 1 : 0;
985 return ETL_OR_STD::make_pair<iterator, iterator>(
iterator(*
this, find_lower_node(
root_node, key)),
992 ETL_OR_STD::pair<iterator, iterator>
equal_range(
const K& key)
994 return ETL_OR_STD::make_pair<iterator, iterator>(
iterator(*
this, find_lower_node(
root_node, key)),
1005 return ETL_OR_STD::make_pair<const_iterator, const_iterator>(
const_iterator(*
this, find_lower_node(
root_node, key)),
1012 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const
1014 return ETL_OR_STD::make_pair<const_iterator, const_iterator>(const_iterator(*
this, find_lower_node(
root_node, key)),
1015 const_iterator(*
this, find_upper_node(
root_node, key)));
1067 while (first != last)
1069 first =
erase(first);
1072 return last.to_iterator();
1118 ETL_OR_STD::pair<iterator, bool>
insert(const_reference value)
1129 ETL_ASSERT_FAIL(ETL_ERROR(
set_full));
1133 return ETL_OR_STD::make_pair(iter,
false);
1165 ETL_ASSERT_FAIL(ETL_ERROR(
set_full));
1169 return ETL_OR_STD::make_pair(iter,
false);
1174 Data_Node&
node = allocate_data_node(etl::move(value));
1201 ETL_ASSERT_FAIL(ETL_ERROR(
set_full));
1236 ETL_ASSERT_FAIL(ETL_ERROR(
set_full));
1245 Data_Node&
node = allocate_data_node(etl::move(value));
1262 template <
class TIterator>
1265 while (first != last)
1308 return const_iterator(*
this, find_lower_node(
root_node, key));
1348 return const_iterator(*
this, find_upper_node(
root_node, key));
1392 , p_node_pool(&node_pool)
1414 Data_Node& allocate_data_node(const_reference value)
1416 Data_Node*
node = allocate_data_node();
1417 ::new ((
void*)&
node->value) value_type(value);
1418 ETL_INCREMENT_DEBUG_COUNT;
1428 Data_Node*
node = allocate_data_node();
1429 ::new ((
void*)&
node->value) value_type(etl::move(value));
1430 ETL_INCREMENT_DEBUG_COUNT;
1438 Data_Node* allocate_data_node()
1440 Data_Node* (
etl::ipool::*
func)() = &etl::ipool::allocate<Data_Node>;
1441 return (p_node_pool->*
func)();
1447 void destroy_data_node(Data_Node&
node)
1449 node.value.~value_type();
1451 ETL_DECREMENT_DEBUG_COUNT;
1459 Node*
found = position;
1490 Node* find_node(Node* position,
const K& key)
1492 Node*
found = position;
1524 const Node* find_node(
const Node* position,
key_parameter_t key)
const
1526 const Node*
found = position;
1557 const Node* find_node(
const Node* position,
const K& key)
const
1559 const Node*
found = position;
1591 Node*& find_node(Node*& position,
const Node*
node)
1593 Node*
found = position;
1598 return found->children[kLeft];
1600 else if (
found->children[kRight] ==
node)
1602 return found->children[kRight];
1637 Node* find_parent_node(Node* position,
const Node*
node)
1640 Node*
found = ETL_NULLPTR;
1643 if (position &&
node && position !=
node)
1648 if (position->children[kLeft] !=
node &&
1649 position->children[kRight] !=
node)
1658 position = position->children[kLeft];
1663 position = position->children[kRight];
1685 const Node* find_parent_node(
const Node* position,
const Node*
node)
const
1688 const Node*
found = ETL_NULLPTR;
1691 if (position &&
node && position !=
node)
1696 if (position->children[kLeft] !=
node &&
1697 position->children[kRight] !=
node)
1706 position = position->children[kLeft];
1711 position = position->children[kRight];
1739 Data_Node&
data_node = iset::data_cast(*position);
1744 if (position->children[kLeft])
1746 position = position->children[kLeft];
1756 position = position->children[kRight];
1762 position = position->children[kLeft];
1773 Node* find_lower_node(Node* position,
const K& key)
const
1780 Data_Node&
data_node = iset::data_cast(*position);
1785 if (position->children[kLeft])
1787 position = position->children[kLeft];
1797 position = position->children[kRight];
1803 position = position->children[kLeft];
1820 Node*
node = position;
1835 else if (
node->children[kRight])
1853 Node* find_upper_node(Node* position,
const K& key)
const
1858 Node*
node = position;
1873 else if (
node->children[kRight])
1892 Node* insert_node(Node*& position, Data_Node&
node)
1895 Node*
found = position;
1908 if (kNeither !=
found->weight)
1926 found->dir = kRight;
1931 found->dir = kNeither;
1937 destroy_data_node(
node);
1948 if (kNeither !=
found->children[
found->dir]->weight)
2005 void next_node(Node*&position)
2010 if (position->children[kRight])
2019 Node* parent = position;
2024 parent = find_parent_node(
root_node, position);
2026 }
while (parent && parent->children[kRight] == position);
2037 void next_node(
const Node*& position)
const
2042 if (position->children[kRight])
2051 const Node* parent = position;
2056 parent = find_parent_node(
root_node, position);
2058 }
while (parent && parent->children[kRight] == position);
2069 void prev_node(Node*&position)
2080 if (position->children[kLeft])
2089 Node* parent = position;
2094 parent = find_parent_node(
root_node, position);
2096 }
while (parent && parent->children[kLeft] == position);
2107 void prev_node(
const Node*& position)
const
2118 if (position->children[kLeft])
2127 const Node* parent = position;
2132 parent = find_parent_node(
root_node, position);
2134 }
while (parent && parent->children[kLeft] == position);
2152 Node*
found = ETL_NULLPTR;
2154 Node* replace = position;
2166 replace->dir = kLeft;
2171 replace->dir = kRight;
2176 replace->dir = replace->children[kLeft] ? kLeft : kRight;
2184 if (replace->children[replace->dir] == ETL_NULLPTR)
2194 if ((replace->weight == kNeither) ||
2195 (replace->weight == (1 - replace->dir) &&
2196 replace->children[1 - replace->dir]->weight == kNeither))
2205 replace = replace->children[replace->dir];
2214 if (balance->children[balance->dir] == ETL_NULLPTR)
2219 if (balance->weight == kNeither)
2221 balance->weight = 1 - balance->dir;
2223 else if (balance->weight == balance->dir)
2225 balance->weight = kNeither;
2229 int weight = balance->children[1 - balance->dir]->weight;
2231 if (weight == balance->dir)
2237 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2242 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2247 else if (weight == kNeither)
2261 balance->weight = 1 - balance->dir;
2279 if (balance ==
found)
2297 balance = balance->children[balance->dir];
2339 Node* remove_node(Node*& position,
const K& key)
2345 Node*
found = ETL_NULLPTR;
2347 Node* replace = position;
2359 replace->dir = kLeft;
2364 replace->dir = kRight;
2369 replace->dir = replace->children[kLeft] ? kLeft : kRight;
2377 if (replace->children[replace->dir] == ETL_NULLPTR)
2387 if ((replace->weight == kNeither) ||
2388 (replace->weight == (1 - replace->dir) &&
2389 replace->children[1 - replace->dir]->weight == kNeither))
2398 replace = replace->children[replace->dir];
2407 if (balance->children[balance->dir] == ETL_NULLPTR)
2412 if (balance->weight == kNeither)
2414 balance->weight = 1 - balance->dir;
2416 else if (balance->weight == balance->dir)
2418 balance->weight = kNeither;
2422 int weight = balance->children[1 - balance->dir]->weight;
2424 if (weight == balance->dir)
2430 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2435 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2440 else if (weight == kNeither)
2454 balance->weight = 1 - balance->dir;
2472 if (balance ==
found)
2490 balance = balance->children[balance->dir];
2536#if defined(ETL_POLYMORPHIC_SET) || defined(ETL_POLYMORPHIC_CONTAINERS)