472 typedef TKey key_type;
473 typedef ETL_OR_STD::pair<const TKey, TMapped> value_type;
476 typedef value_type& reference;
477 typedef const value_type& const_reference;
481 typedef value_type* pointer;
482 typedef const value_type* const_pointer;
483 typedef size_t size_type;
490 typedef mapped_type& mapped_reference;
491 typedef const mapped_type& const_mapped_reference;
497 bool operator()(const_reference
lhs, const_reference
rhs)
const
499 return (kcompare(
lhs.first,
rhs.first));
504 key_compare kcompare;
532 return kcompare(
node1.value.first,
node2.value.first);
537 return kcompare(
node.value.first, key);
542 return kcompare(key,
node.value.first);
549 return kcompare(
node.value.first, key);
555 return kcompare(key,
node.value.first);
564 key_compare kcompare;
565 value_compare vcompare;
570 static Data_Node* data_cast(Node* p_node)
572 return static_cast<Data_Node*
>(p_node);
578 static Data_Node& data_cast(Node&
node)
580 return static_cast<Data_Node&
>(
node);
586 static const Data_Node* data_cast(
const Node* p_node)
588 return static_cast<const Data_Node*
>(p_node);
594 static const Data_Node& data_cast(
const Node&
node)
596 return static_cast<const Data_Node&
>(
node);
613 , p_node(ETL_NULLPTR)
619 , p_node(ETL_NULLPTR)
631 , p_node(
other.p_node)
641 p_map->next_node(p_node);
648 p_map->next_node(p_node);
654 p_map->prev_node(p_node);
661 p_map->prev_node(p_node);
668 p_node =
other.p_node;
672 reference operator *()
const
674 return imap::data_cast(p_node)->value;
677 pointer operator &()
const
679 return &(imap::data_cast(p_node)->value);
682 pointer operator ->()
const
684 return &(imap::data_cast(p_node)->value);
689 return lhs.p_map ==
rhs.p_map &&
lhs.p_node ==
rhs.p_node;
719 , p_node(ETL_NULLPTR)
725 , p_node(ETL_NULLPTR)
737 , p_node(
other.p_node)
743 , p_node(
other.p_node)
753 p_map->next_node(p_node);
760 p_map->next_node(p_node);
766 p_map->prev_node(p_node);
773 p_map->prev_node(p_node);
780 p_node =
other.p_node;
784 const_reference operator *()
const
786 return imap::data_cast(p_node)->value;
789 const_pointer operator &()
const
791 return imap::data_cast(p_node)->value;
794 const_pointer operator ->()
const
796 return &(imap::data_cast(p_node)->value);
801 return lhs.p_map ==
rhs.p_map &&
lhs.p_node ==
rhs.p_node;
826 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
828 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
829 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
884 return reverse_iterator(
iterator(*
this));
906 const_reverse_iterator
rend()
const
922 const_reverse_iterator
crend()
const
945 Data_Node&
node = allocate_data_node_with_key(etl::move(key));
1005 mapped_reference
at(
const K& key)
1033 const_mapped_reference
at(
const K& key)
const
1050 template <
typename TIterator>
1072 return find_node(
root_node, key) ? 1 : 0;
1078 size_type
count(
const K& key)
const
1080 return find_node(
root_node, key) ? 1 : 0;
1090 return ETL_OR_STD::make_pair<iterator, iterator>(
iterator(*
this, find_lower_node(
root_node, key)),
1097 ETL_OR_STD::pair<iterator, iterator>
equal_range(
const K& key)
1099 return ETL_OR_STD::make_pair<iterator, iterator>(
iterator(*
this, find_lower_node(
root_node, key)),
1110 return ETL_OR_STD::make_pair<const_iterator, const_iterator>(
const_iterator(*
this, find_lower_node(
root_node, key)),
1117 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const
1119 return ETL_OR_STD::make_pair<const_iterator, const_iterator>(const_iterator(*
this, find_lower_node(
root_node, key)),
1120 const_iterator(*
this, find_upper_node(
root_node, key)));
1134 remove_node(
root_node, (*position).first);
1145 return remove_node(
root_node, key) ? 1 : 0;
1163 while (first != last)
1165 first =
erase(first);
1168 return last.to_iterator();
1203 const_iterator
find(
const K&
k)
const
1205 return const_iterator(*
this, find_node(
root_node,
k));
1214 ETL_OR_STD::pair<iterator, bool>
insert(const_reference value)
1248 Data_Node&
node = allocate_data_node(etl::move(value));
1297 Data_Node&
node = allocate_data_node(etl::move(value));
1314 template <
class TIterator>
1317 while (first != last)
1360 return const_iterator(*
this, find_lower_node(
root_node, key));
1400 return const_iterator(*
this, find_upper_node(
root_node, key));
1482 , p_node_pool(&node_pool)
1504 Data_Node& allocate_data_node(const_reference value)
1506 Data_Node*
node = allocate_data_node();
1508 ETL_INCREMENT_DEBUG_COUNT;
1517 Data_Node*
node = allocate_data_node();
1521 ETL_INCREMENT_DEBUG_COUNT;
1531 Data_Node*
node = allocate_data_node();
1533 ETL_INCREMENT_DEBUG_COUNT;
1542 Data_Node*
node = allocate_data_node();
1546 ETL_INCREMENT_DEBUG_COUNT;
1555 Data_Node* allocate_data_node()
1557 Data_Node* (
etl::ipool::*
func)() = &etl::ipool::allocate<Data_Node>;
1558 return (p_node_pool->*
func)();
1564 void destroy_data_node(Data_Node&
node)
1566 node.value.~value_type();
1567 p_node_pool->release(&
node);
1568 ETL_DECREMENT_DEBUG_COUNT;
1576 Node*
found = position;
1607 Node* find_node(Node* position,
const K& key)
1609 Node*
found = position;
1643 const Node*
found = position;
1674 const Node* find_node(
const Node* position,
const K& key)
const
1676 const Node*
found = position;
1708 Node*& find_node(Node*& position,
const Node*
node)
1710 Node*
found = position;
1715 return found->children[kLeft];
1717 else if (
found->children[kRight] ==
node)
1719 return found->children[kRight];
1754 Node* find_parent_node(Node* position,
const Node*
node)
1757 Node*
found = ETL_NULLPTR;
1760 if (position &&
node && position !=
node)
1765 if (position->children[kLeft] !=
node &&
1766 position->children[kRight] !=
node)
1775 position = position->children[kLeft];
1780 position = position->children[kRight];
1802 const Node* find_parent_node(
const Node* position,
const Node*
node)
const
1805 const Node*
found = ETL_NULLPTR;
1808 if (position &&
node && position !=
node)
1813 if (position->children[kLeft] !=
node &&
1814 position->children[kRight] !=
node)
1823 position = position->children[kLeft];
1828 position = position->children[kRight];
1856 Data_Node&
data_node = imap::data_cast(*position);
1861 if (position->children[kLeft])
1863 position = position->children[kLeft];
1873 position = position->children[kRight];
1879 position = position->children[kLeft];
1890 Node* find_lower_node(Node* position,
const K& key)
const
1897 Data_Node&
data_node = imap::data_cast(*position);
1902 if (position->children[kLeft])
1904 position = position->children[kLeft];
1914 position = position->children[kRight];
1920 position = position->children[kLeft];
1937 Node*
node = position;
1952 else if (
node->children[kRight])
1970 Node* find_upper_node(Node* position,
const K& key)
const
1975 Node*
node = position;
1990 else if (
node->children[kRight])
2009 Node* insert_node(Node*& position, Data_Node&
node)
2012 Node*
found = position;
2025 if (kNeither !=
found->weight)
2043 found->dir = kRight;
2048 found->dir = kNeither;
2054 destroy_data_node(
node);
2065 if (kNeither !=
found->children[
found->dir]->weight)
2122 void next_node(Node*&position)
2127 if (position->children[kRight])
2136 Node* parent = position;
2141 parent = find_parent_node(
root_node, position);
2143 }
while (parent && parent->children[kRight] == position);
2154 void next_node(
const Node*& position)
const
2159 if (position->children[kRight])
2168 const Node* parent = position;
2173 parent = find_parent_node(
root_node, position);
2175 }
while (parent && parent->children[kRight] == position);
2186 void prev_node(Node*&position)
2197 if (position->children[kLeft])
2206 Node* parent = position;
2211 parent = find_parent_node(
root_node, position);
2213 }
while (parent && parent->children[kLeft] == position);
2224 void prev_node(
const Node*& position)
const
2235 if (position->children[kLeft])
2244 const Node* parent = position;
2249 parent = find_parent_node(
root_node, position);
2251 }
while (parent && parent->children[kLeft] == position);
2269 Node*
found = ETL_NULLPTR;
2271 Node* replace = position;
2283 replace->dir = kLeft;
2288 replace->dir = kRight;
2293 replace->dir = replace->children[kLeft] ? kLeft : kRight;
2301 if (replace->children[replace->dir] == ETL_NULLPTR)
2311 if ((replace->weight == kNeither) ||
2312 (replace->weight == (1 - replace->dir) &&
2313 replace->children[1 - replace->dir]->weight == kNeither))
2322 replace = replace->children[replace->dir];
2331 if (balance->children[balance->dir] == ETL_NULLPTR)
2336 if (balance->weight == kNeither)
2338 balance->weight = 1 - balance->dir;
2340 else if (balance->weight == balance->dir)
2342 balance->weight = kNeither;
2346 int weight = balance->children[1 - balance->dir]->weight;
2348 if (weight == balance->dir)
2354 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2359 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2364 else if (weight == kNeither)
2378 balance->weight = 1 - balance->dir;
2396 if (balance ==
found)
2414 balance = balance->children[balance->dir];
2459 Node* remove_node(Node*& position,
const K& key)
2465 Node*
found = ETL_NULLPTR;
2467 Node* replace = position;
2479 replace->dir = kLeft;
2484 replace->dir = kRight;
2489 replace->dir = replace->children[kLeft] ? kLeft : kRight;
2497 if (replace->children[replace->dir] == ETL_NULLPTR)
2507 if ((replace->weight == kNeither) ||
2508 (replace->weight == (1 - replace->dir) &&
2509 replace->children[1 - replace->dir]->weight == kNeither))
2518 replace = replace->children[replace->dir];
2527 if (balance->children[balance->dir] == ETL_NULLPTR)
2532 if (balance->weight == kNeither)
2534 balance->weight = 1 - balance->dir;
2536 else if (balance->weight == balance->dir)
2538 balance->weight = kNeither;
2542 int weight = balance->children[1 - balance->dir]->weight;
2544 if (weight == balance->dir)
2550 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2555 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2560 else if (weight == kNeither)
2574 balance->weight = 1 - balance->dir;
2592 if (balance ==
found)
2610 balance = balance->children[balance->dir];
2656#if defined(ETL_POLYMORPHIC_MAP) || defined(ETL_POLYMORPHIC_CONTAINERS)