465 typedef TKey key_type;
466 typedef ETL_OR_STD::pair<const TKey, TMapped> value_type;
467 typedef TMapped mapped_type;
468 typedef TKeyCompare key_compare;
469 typedef value_type& reference;
470 typedef const value_type& const_reference;
472 typedef value_type&& rvalue_reference;
474 typedef value_type* pointer;
475 typedef const value_type* const_pointer;
476 typedef size_t size_type;
481 typedef key_type&& rvalue_key_reference;
483 typedef mapped_type& mapped_reference;
484 typedef const mapped_type& const_mapped_reference;
490 bool operator()(const_reference lhs, const_reference rhs)
const
492 return (kcompare(lhs.first, rhs.first));
497 key_compare kcompare;
507 explicit Data_Node(value_type value_)
522 return kcompare(node1.value.first, node2.value.first);
527 return kcompare(node.value.first, key);
532 return kcompare(key, node.value.first);
536 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
539 return kcompare(node.value.first, key);
542 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
545 return kcompare(key, node.value.first);
554 key_compare kcompare;
578 return static_cast<const Data_Node*
>(p_node);
586 return static_cast<const Data_Node&
>(node);
594 class iterator :
public etl::iterator<ETL_OR_STD::bidirectional_iterator_tag, value_type>
599 friend class const_iterator;
603 , p_node(ETL_NULLPTR)
609 , p_node(ETL_NULLPTR)
613 iterator(imap&
map,
Node* node)
619 iterator(
const iterator& other)
621 , p_node(other.p_node)
627 iterator& operator++()
629 p_map->next_node(p_node);
633 iterator operator++(
int)
635 iterator temp(*
this);
636 p_map->next_node(p_node);
640 iterator& operator--()
642 p_map->prev_node(p_node);
646 iterator operator--(
int)
648 iterator temp(*
this);
649 p_map->prev_node(p_node);
653 iterator& operator=(
const iterator& other)
656 p_node = other.p_node;
660 reference operator*()
const
662 return imap::data_cast(p_node)->value;
665 pointer operator&()
const
667 return &(imap::data_cast(p_node)->value);
670 pointer operator->()
const
672 return &(imap::data_cast(p_node)->value);
675 friend bool operator==(
const iterator& lhs,
const iterator& rhs)
677 return lhs.p_map == rhs.p_map && lhs.p_node == rhs.p_node;
680 friend bool operator!=(
const iterator& lhs,
const iterator& rhs)
682 return !(lhs == rhs);
699 class const_iterator :
public etl::iterator<ETL_OR_STD::bidirectional_iterator_tag, const value_type>
707 , p_node(ETL_NULLPTR)
711 const_iterator(
const imap&
map)
713 , p_node(ETL_NULLPTR)
717 const_iterator(
const imap&
map,
const Node* node)
725 , p_node(other.p_node)
729 const_iterator(
const const_iterator& other)
731 , p_node(other.p_node)
737 const_iterator& operator++()
739 p_map->next_node(p_node);
743 const_iterator operator++(
int)
745 const_iterator temp(*
this);
746 p_map->next_node(p_node);
750 const_iterator& operator--()
752 p_map->prev_node(p_node);
756 const_iterator operator--(
int)
758 const_iterator temp(*
this);
759 p_map->prev_node(p_node);
763 const_iterator& operator=(
const const_iterator& other)
766 p_node = other.p_node;
770 const_reference operator*()
const
772 return imap::data_cast(p_node)->value;
775 const_pointer operator&()
const
777 return imap::data_cast(p_node)->value;
780 const_pointer operator->()
const
782 return &(imap::data_cast(p_node)->value);
785 friend bool operator==(
const const_iterator& lhs,
const const_iterator& rhs)
787 return lhs.p_map == rhs.p_map && lhs.p_node == rhs.p_node;
790 friend bool operator!=(
const const_iterator& lhs,
const const_iterator& rhs)
792 return !(lhs == rhs);
812 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
814 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
815 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
870 return reverse_iterator(
iterator(*
this));
892 const_reverse_iterator
rend()
const
908 const_reverse_iterator
crend()
const
919 mapped_reference
operator[](rvalue_key_reference key)
923 if (!i_element.p_node)
926 Node* inserted_node = ETL_NULLPTR;
931 Data_Node& node = allocate_data_node_with_key(etl::move(key));
935 inserted_node = insert_node(
root_node, node);
939 i_element =
iterator(*
this, inserted_node);
942 return i_element->second;
955 if (!i_element.p_node)
958 Node* inserted_node = ETL_NULLPTR;
963 Data_Node& node = allocate_data_node_with_key(key);
967 inserted_node = insert_node(
root_node, node);
971 i_element =
iterator(*
this, inserted_node);
974 return i_element->second;
990 return i_element->second;
995 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
996 mapped_reference
at(
const K& key)
1002 return i_element->second;
1019 return i_element->second;
1024 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1025 const_mapped_reference
at(
const K& key)
const
1031 return i_element->second;
1043 template <
typename TIterator>
1065 return find_node(
root_node, key) ? 1 : 0;
1070 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1073 return find_node(
root_node, key) ? 1 : 0;
1083 return ETL_OR_STD::make_pair<iterator, iterator>(
iterator(*
this, find_lower_node(
root_node, key)),
1089 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1090 ETL_OR_STD::pair<iterator, iterator>
equal_range(
const K& key)
1092 return ETL_OR_STD::make_pair<iterator, iterator>(
iterator(*
this, find_lower_node(
root_node, key)),
1103 return ETL_OR_STD::make_pair<const_iterator, const_iterator>(
const_iterator(*
this, find_lower_node(
root_node, key)),
1109 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1110 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const
1112 return ETL_OR_STD::make_pair<const_iterator, const_iterator>(
const_iterator(*
this, find_lower_node(
root_node, key)),
1123 Node*& reference_node = find_node(
root_node, position.p_node);
1124 iterator next(*
this, reference_node);
1127 remove_node(
root_node, (*position).first);
1138 return remove_node(
root_node, key) ? 1 : 0;
1143 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1147 return remove_node(
root_node, etl::forward<K>(key)) ? 1 : 0;
1156 while (first != last)
1158 first =
erase(first);
1161 return last.to_iterator();
1176 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1195 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1208 ETL_OR_STD::pair<iterator, bool>
insert(const_reference value)
1211 Node* inserted_node = ETL_NULLPTR;
1212 bool inserted =
false;
1217 Data_Node& node = allocate_data_node(value);
1220 inserted_node = insert_node(
root_node, node);
1221 inserted = inserted_node == &node;
1224 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node), inserted);
1234 ETL_OR_STD::pair<iterator, bool>
insert(rvalue_reference value)
1237 Node* inserted_node = ETL_NULLPTR;
1238 bool inserted =
false;
1243 Data_Node& node = allocate_data_node(etl::move(value));
1246 inserted_node = insert_node(
root_node, node);
1247 inserted = inserted_node == &node;
1250 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node), inserted);
1264 Node* inserted_node = ETL_NULLPTR;
1269 Data_Node& node = allocate_data_node(value);
1272 inserted_node = insert_node(
root_node, node);
1275 return iterator(*
this, inserted_node);
1289 Node* inserted_node = ETL_NULLPTR;
1294 Data_Node& node = allocate_data_node(etl::move(value));
1297 inserted_node = insert_node(
root_node, node);
1300 return iterator(*
this, inserted_node);
1312 template <
class TIterator>
1315 while (first != last)
1322#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
1327 template <
typename... Args>
1328 ETL_OR_STD::pair<iterator, bool>
emplace(Args&&... args)
1333 Data_Node& node = allocate_data_node_from_args(etl::forward<Args>(args)...);
1336 Node* inserted_node = insert_node(
root_node, node);
1337 bool inserted = inserted_node == &node;
1340 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node), inserted);
1347 template <
typename... Args>
1351 Node* found = find_node(
root_node, key);
1354 return ETL_OR_STD::make_pair(iterator(*
this, found),
false);
1360 Data_Node& node = allocate_data_node_emplace(key, etl::forward<Args>(args)...);
1366 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node),
true);
1373 template <
typename... Args>
1374 ETL_OR_STD::pair<iterator, bool>
try_emplace(rvalue_key_reference key, Args&&... args)
1380 return ETL_OR_STD::make_pair(
iterator(*
this, found),
false);
1386 Data_Node& node = allocate_data_node_emplace(etl::move(key), etl::forward<Args>(args)...);
1392 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node),
true);
1398 ETL_OR_STD::pair<iterator, bool>
emplace(
const value_type& value)
1406 template <
typename T1>
1413 return ETL_OR_STD::make_pair(
iterator(*
this, found),
false);
1419 Data_Node& node = allocate_data_node_emplace(key, value1);
1425 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node),
true);
1431 template <
typename T1,
typename T2>
1438 return ETL_OR_STD::make_pair(
iterator(*
this, found),
false);
1444 Data_Node& node = allocate_data_node_emplace(key, value1, value2);
1450 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node),
true);
1456 template <
typename T1,
typename T2,
typename T3>
1463 return ETL_OR_STD::make_pair(
iterator(*
this, found),
false);
1469 Data_Node& node = allocate_data_node_emplace(key, value1, value2, value3);
1475 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node),
true);
1481 template <
typename T1,
typename T2,
typename T3,
typename T4>
1488 return ETL_OR_STD::make_pair(
iterator(*
this, found),
false);
1494 Data_Node& node = allocate_data_node_emplace(key, value1, value2, value3, value4);
1500 return ETL_OR_STD::make_pair(
iterator(*
this, inserted_node),
true);
1517 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1537 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1557 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1577 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1611 while (from != rhs.end())
1613 this->
insert(etl::move(*from));
1648 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1662 , p_node_pool(&node_pool)
1673 while (item !=
end())
1684 Data_Node& allocate_data_node(const_reference value)
1686 Data_Node* node = allocate_data_node();
1688 ETL_INCREMENT_DEBUG_COUNT;
1697 Data_Node* node = allocate_data_node();
1700 ::new ((
void*)
etl::
addressof(node->value.second)) mapped_type();
1701 ETL_INCREMENT_DEBUG_COUNT;
1709 Data_Node& allocate_data_node(rvalue_reference value)
1711 Data_Node* node = allocate_data_node();
1713 ETL_INCREMENT_DEBUG_COUNT;
1720 Data_Node& allocate_data_node_with_key(rvalue_key_reference key)
1722 Data_Node* node = allocate_data_node();
1725 ::new ((
void*)
etl::
addressof(node->value.second)) mapped_type();
1726 ETL_INCREMENT_DEBUG_COUNT;
1730 #if ETL_NOT_USING_STLPORT
1734 template <
typename... Args>
1737 Data_Node* node = allocate_data_node();
1740 ::new ((
void*)
etl::
addressof(node->value.second)) mapped_type(
etl::forward<Args>(args)...);
1741 ETL_INCREMENT_DEBUG_COUNT;
1748 template <typename... Args>
1749 Data_Node& allocate_data_node_emplace(rvalue_key_reference key, Args&&... args)
1751 Data_Node* node = allocate_data_node();
1754 ::new ((
void*)
etl::
addressof(node->value.second)) mapped_type(
etl::forward<Args>(args)...);
1755 ETL_INCREMENT_DEBUG_COUNT;
1762 template <typename... Args>
1763 Data_Node& allocate_data_node_from_args(Args&&... args)
1765 Data_Node* node = allocate_data_node();
1766 ::new (&node->value)
value_type(
etl::forward<Args>(args)...);
1767 ETL_INCREMENT_DEBUG_COUNT;
1777 template <
typename T1>
1780 Data_Node* node = allocate_data_node();
1783 ::new ((
void*)
etl::
addressof(node->value.second)) mapped_type(value1);
1784 ETL_INCREMENT_DEBUG_COUNT;
1791 template <typename T1, typename T2>
1792 Data_Node& allocate_data_node_emplace(
const_key_reference key, const T1& value1, const T2& value2)
1794 Data_Node* node = allocate_data_node();
1797 ::new ((
void*)
etl::
addressof(node->value.second)) mapped_type(value1, value2);
1798 ETL_INCREMENT_DEBUG_COUNT;
1805 template <typename T1, typename T2, typename T3>
1806 Data_Node& allocate_data_node_emplace(
const_key_reference key, const T1& value1, const T2& value2, const T3& value3)
1808 Data_Node* node = allocate_data_node();
1811 ::new ((
void*)
etl::
addressof(node->value.second)) mapped_type(value1, value2, value3);
1812 ETL_INCREMENT_DEBUG_COUNT;
1819 template <typename T1, typename T2, typename T3, typename T4>
1820 Data_Node& allocate_data_node_emplace(
const_key_reference key, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
1822 Data_Node* node = allocate_data_node();
1825 ::new ((
void*)
etl::
addressof(node->value.second)) mapped_type(value1, value2, value3, value4);
1826 ETL_INCREMENT_DEBUG_COUNT;
1835 Data_Node* allocate_data_node()
1838 return (p_node_pool->*func)();
1844 void destroy_data_node(Data_Node& node)
1846 node.value.~value_type();
1847 p_node_pool->release(&node);
1848 ETL_DECREMENT_DEBUG_COUNT;
1856 Node* found = position;
1860 Data_Node& found_data_node = imap::data_cast(*found);
1866 found = found->children[kLeft];
1868 else if (
node_comp(found_data_node, key))
1871 found = found->children[kRight];
1886 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1887 Node* find_node(
Node* position,
const K& key)
1889 Node* found = position;
1893 Data_Node& found_data_node = imap::data_cast(*found);
1899 found = found->children[kLeft];
1901 else if (
node_comp(found_data_node, key))
1904 found = found->children[kRight];
1923 const Node* found = position;
1927 const Data_Node& found_data_node = imap::data_cast(*found);
1933 found = found->children[kLeft];
1935 else if (
node_comp(found_data_node, key))
1938 found = found->children[kRight];
1953 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
1954 const Node* find_node(
const Node* position,
const K& key)
const
1956 const Node* found = position;
1960 const Data_Node& found_data_node = imap::data_cast(*found);
1966 found = found->children[kLeft];
1968 else if (
node_comp(found_data_node, key))
1971 found = found->children[kRight];
1990 Node* found = position;
1993 if (found->children[kLeft] == node)
1995 return found->children[kLeft];
1997 else if (found->children[kRight] == node)
1999 return found->children[kRight];
2005 Data_Node& found_data_node = imap::data_cast(*found);
2006 const Data_Node& data_node = imap::data_cast(*node);
2009 if (
node_comp(data_node, found_data_node))
2012 found = found->children[kLeft];
2014 else if (
node_comp(found_data_node, data_node))
2017 found = found->children[kRight];
2035 Node* find_parent_node(
Node* position,
const Node* node)
2038 Node* found = ETL_NULLPTR;
2042 if (position && node && position != node)
2047 if (position->children[kLeft] != node && position->children[kRight] != node)
2051 const Data_Node& node_data_node = imap::data_cast(*node);
2052 Data_Node& position_data_node = imap::data_cast(*position);
2054 if (
node_comp(node_data_node, position_data_node))
2057 position = position->children[kLeft];
2059 else if (
node_comp(position_data_node, node_data_node))
2062 position = position->children[kRight];
2084 const Node* find_parent_node(
const Node* position,
const Node* node)
const
2087 const Node* found = ETL_NULLPTR;
2091 if (position && node && position != node)
2096 if (position->children[kLeft] != node && position->children[kRight] != node)
2100 const Data_Node& node_data_node = imap::data_cast(*node);
2101 const Data_Node& position_data_node = imap::data_cast(*position);
2103 if (
node_comp(node_data_node, position_data_node))
2106 position = position->children[kLeft];
2108 else if (
node_comp(position_data_node, node_data_node))
2111 position = position->children[kRight];
2135 Node* lower_node = ETL_NULLPTR;
2139 Data_Node& data_node = imap::data_cast(*position);
2143 lower_node = position;
2144 if (position->children[kLeft])
2146 position = position->children[kLeft];
2156 position = position->children[kRight];
2161 lower_node = position;
2162 position = position->children[kLeft];
2172 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
2173 Node* find_lower_node(
Node* position,
const K& key)
const
2176 Node* lower_node = ETL_NULLPTR;
2180 Data_Node& data_node = imap::data_cast(*position);
2184 lower_node = position;
2185 if (position->children[kLeft])
2187 position = position->children[kLeft];
2197 position = position->children[kRight];
2202 lower_node = position;
2203 position = position->children[kLeft];
2218 Node* upper_node = ETL_NULLPTR;
2220 Node* node = position;
2224 Data_Node& data_node = imap::data_cast(*node);
2229 node = node->children[kLeft];
2233 node = node->children[kRight];
2235 else if (node->children[kRight])
2252 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
2253 Node* find_upper_node(
Node* position,
const K& key)
const
2256 Node* upper_node = ETL_NULLPTR;
2258 Node* node = position;
2262 Data_Node& data_node = imap::data_cast(*node);
2267 node = node->children[kLeft];
2271 node = node->children[kRight];
2273 else if (node->children[kRight])
2295 Node* found = position;
2301 Node* critical_parent_node = ETL_NULLPTR;
2308 if (kNeither != found->weight)
2310 critical_node = found;
2315 Data_Node& found_data_node = imap::data_cast(*found);
2324 else if (
node_comp(found_data_node, node))
2327 found->dir = kRight;
2332 found->dir = kNeither;
2335 critical_node = ETL_NULLPTR;
2338 destroy_data_node(node);
2345 if (found->children[found->dir])
2349 if (kNeither != found->children[found->dir]->weight)
2351 critical_parent_node = found;
2355 found = found->children[found->dir];
2363 found = found->children[found->dir];
2373 if (critical_parent_node == ETL_NULLPTR && critical_node ==
root_node)
2377 else if (critical_parent_node == ETL_NULLPTR && critical_node == position)
2383 if (critical_parent_node != ETL_NULLPTR)
2385 balance_node(critical_parent_node->children[critical_parent_node->dir]);
2406 void next_node(
Node*& position)
2411 if (position->children[kRight])
2420 Node* parent = position;
2425 parent = find_parent_node(
root_node, position);
2427 }
while (parent && parent->children[kRight] == position);
2438 void next_node(
const Node*& position)
const
2443 if (position->children[kRight])
2452 const Node* parent = position;
2457 parent = find_parent_node(
root_node, position);
2459 }
while (parent && parent->children[kRight] == position);
2470 void prev_node(
Node*& position)
2481 if (position->children[kLeft])
2490 Node* parent = position;
2495 parent = find_parent_node(
root_node, position);
2497 }
while (parent && parent->children[kLeft] == position);
2508 void prev_node(
const Node*& position)
const
2519 if (position->children[kLeft])
2528 const Node* parent = position;
2533 parent = find_parent_node(
root_node, position);
2535 }
while (parent && parent->children[kLeft] == position);
2552 Node* found_parent = ETL_NULLPTR;
2553 Node* found = ETL_NULLPTR;
2554 Node* replace_parent = ETL_NULLPTR;
2555 Node* replace = position;
2556 Node* balance_parent = ETL_NULLPTR;
2561 Data_Node& replace_data_node = imap::data_cast(*replace);
2567 replace->dir = kLeft;
2569 else if (
node_comp(replace_data_node, key))
2572 replace->dir = kRight;
2577 replace->dir = replace->children[kLeft] ? kLeft : kRight;
2580 found_parent = replace_parent;
2585 if (replace->children[replace->dir] == ETL_NULLPTR)
2595 if ((replace->weight == kNeither) || (replace->weight == (1 - replace->dir) && replace->children[1 - replace->dir]->weight == kNeither))
2598 balance_parent = replace_parent;
2603 replace_parent = replace;
2604 replace = replace->children[replace->dir];
2613 if (balance->children[balance->dir] == ETL_NULLPTR)
2618 if (balance->weight == kNeither)
2620 balance->weight = 1 - balance->dir;
2622 else if (balance->weight == balance->dir)
2624 balance->weight = kNeither;
2628 int weight = balance->children[1 - balance->dir]->weight;
2630 if (weight == balance->dir)
2633 if (balance_parent == ETL_NULLPTR)
2635 rotate_3node(
root_node, 1 - balance->dir, balance->children[1 - balance->dir]->children[balance->dir]->weight);
2639 rotate_3node(balance_parent->children[balance_parent->dir], 1 - balance->dir,
2640 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2645 else if (weight == kNeither)
2648 if (balance_parent == ETL_NULLPTR)
2655 rotate_2node(balance_parent->children[balance_parent->dir], 1 - balance->dir);
2656 balance_parent->children[balance_parent->dir]->weight = balance->dir;
2660 balance->weight = 1 - balance->dir;
2666 if (balance_parent == ETL_NULLPTR)
2672 rotate_2node(balance_parent->children[balance_parent->dir], 1 - balance->dir);
2678 if (balance == found)
2682 found_parent = balance_parent->children[balance_parent->dir];
2684 found_parent->dir = found_parent->children[kLeft] == found ? kLeft : kRight;
2695 balance_parent = balance;
2696 balance = balance->children[balance->dir];
2703 detach_node(found_parent->children[found_parent->dir], replace_parent->children[replace_parent->dir]);
2721 Data_Node& found_data_node = imap::data_cast(*found);
2727 destroy_data_node(found_data_node);
2739 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
2740 Node* remove_node(
Node*& position,
const K& key)
2745 Node* found_parent = ETL_NULLPTR;
2746 Node* found = ETL_NULLPTR;
2747 Node* replace_parent = ETL_NULLPTR;
2748 Node* replace = position;
2749 Node* balance_parent = ETL_NULLPTR;
2754 Data_Node& replace_data_node = imap::data_cast(*replace);
2760 replace->dir = kLeft;
2762 else if (
node_comp(replace_data_node, key))
2765 replace->dir = kRight;
2770 replace->dir = replace->children[kLeft] ? kLeft : kRight;
2773 found_parent = replace_parent;
2778 if (replace->children[replace->dir] == ETL_NULLPTR)
2788 if ((replace->weight == kNeither) || (replace->weight == (1 - replace->dir) && replace->children[1 - replace->dir]->weight == kNeither))
2791 balance_parent = replace_parent;
2796 replace_parent = replace;
2797 replace = replace->children[replace->dir];
2806 if (balance->children[balance->dir] == ETL_NULLPTR)
2811 if (balance->weight == kNeither)
2813 balance->weight = 1 - balance->dir;
2815 else if (balance->weight == balance->dir)
2817 balance->weight = kNeither;
2821 int weight = balance->children[1 - balance->dir]->weight;
2823 if (weight == balance->dir)
2826 if (balance_parent == ETL_NULLPTR)
2828 rotate_3node(
root_node, 1 - balance->dir, balance->children[1 - balance->dir]->children[balance->dir]->weight);
2832 rotate_3node(balance_parent->children[balance_parent->dir], 1 - balance->dir,
2833 balance->children[1 - balance->dir]->children[balance->dir]->weight);
2838 else if (weight == kNeither)
2841 if (balance_parent == ETL_NULLPTR)
2848 rotate_2node(balance_parent->children[balance_parent->dir], 1 - balance->dir);
2849 balance_parent->children[balance_parent->dir]->weight = balance->dir;
2853 balance->weight = 1 - balance->dir;
2859 if (balance_parent == ETL_NULLPTR)
2865 rotate_2node(balance_parent->children[balance_parent->dir], 1 - balance->dir);
2871 if (balance == found)
2875 found_parent = balance_parent->children[balance_parent->dir];
2877 found_parent->dir = found_parent->children[kLeft] == found ? kLeft : kRight;
2888 balance_parent = balance;
2889 balance = balance->children[balance->dir];
2896 detach_node(found_parent->children[found_parent->dir], replace_parent->children[replace_parent->dir]);
2914 Data_Node& found_data_node = imap::data_cast(*found);
2920 destroy_data_node(found_data_node);
2934#if defined(ETL_POLYMORPHIC_MAP) || defined(ETL_POLYMORPHIC_CONTAINERS)