|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Hybrid top-down/bottom-up red-black tree with rank support. More...
#include <tpl_hRbTreeRk.H>
Classes | |
| struct | Iterator |
| In-order iterator. More... | |
Public Types | |
| using | Color = unsigned char |
| using | Node = RbNodeRk< Key > |
| using | key_type = Key |
Public Member Functions | |
| Compare & | key_comp () noexcept |
| const Compare & | key_comp () const noexcept |
| Compare & | get_compare () noexcept |
| constexpr const Compare & | get_compare () const noexcept |
| HtdRbTreeRk () noexcept(std::is_nothrow_default_constructible_v< Node > and std::is_nothrow_default_constructible_v< Compare > and std::is_nothrow_constructible_v< Compare, Compare & >) | |
| Builds an empty tree with a comparison criteria built by default. | |
| HtdRbTreeRk (Compare __cmp) noexcept(std::is_nothrow_default_constructible_v< Node > and std::is_nothrow_constructible_v< Compare, Compare & >) | |
Builds an empty tree with the comparison criteria __cmp. | |
| void | swap (HtdRbTreeRk &tree) noexcept(std::is_nothrow_swappable_v< Compare >) |
Swaps in constant time the nodes and the comparison criteria of this and tree. | |
| HtdRbTreeRk (HtdRbTreeRk &&tree) noexcept(bin_node_detail::nothrow_header_from_v< Node > and bin_node_detail::nothrow_compare_taken_v< Compare >) | |
Takes the nodes and the comparison criteria of tree, which is left empty and can take nodes again. | |
| HtdRbTreeRk & | operator= (HtdRbTreeRk &&tree) noexcept(std::is_nothrow_swappable_v< Compare >) |
Swaps the nodes and the comparison criteria with tree. | |
| HtdRbTreeRk (const HtdRbTreeRk &)=delete | |
| HtdRbTreeRk & | operator= (const HtdRbTreeRk &)=delete |
| virtual | ~HtdRbTreeRk ()=default |
| constexpr bool | is_empty () const noexcept |
| size_t | size () const noexcept |
| O(1) size using root count. | |
| void | reset () noexcept |
| Node * | insert (Node *p) noexcept(nothrow_compare_v< Compare, Key >) |
| Insert a node into the tree. | |
| Node * | search_or_insert (Node *p) noexcept(nothrow_compare_v< Compare, Key >) |
| Search for key or insert if not found. | |
| Node * | insert_dup (Node *p) noexcept(nothrow_compare_v< Compare, Key >) |
| Insert allowing duplicate keys. | |
| Node * | search (const Key &key) const noexcept(nothrow_compare_v< Compare, Key >) |
| Search for a key. | |
| Node * | remove (const Key &key) noexcept(nothrow_compare_v< Compare, Key >) |
| Remove node with given key. | |
| Node *& | getRoot () noexcept |
| Node * | getRoot () const noexcept |
| Node * | select (size_t i) const |
| Select the i-th smallest element (0-indexed). | |
| std::pair< long, Node * > | position (const Key &key) const noexcept(nothrow_compare_copy_v< Compare, Key >) |
| Find position of a key. | |
| std::pair< long, Node * > | find_position (const Key &key) const noexcept(nothrow_compare_copy_v< Compare, Key >) |
| Find position where key would be inserted. | |
| Node * | remove_pos (size_t i) |
| Remove element at position i. | |
| void | split_pos (size_t pos, HtdRbTreeRk &t1, HtdRbTreeRk &t2) |
| Split tree at position. | |
| bool | verify () const |
| Verify red-black and rank invariants. | |
Private Types | |
| using | Path = InlineStack< Node *, Node::MaxHeight+1 > |
Private Member Functions | |
| bool | less (const Key &k1, const Key &k2) const noexcept(nothrow_compare_v< Compare, Key >) |
| bool | equals (const Key &k1, const Key &k2) const noexcept(nothrow_compare_v< Compare, Key >) |
| void | restoreRedCondition (Node *p, Node *&fp, Node *ffp, Node *fffp) noexcept |
| Node * | searchFlipColorsAndInsert (Node *q) noexcept(nothrow_compare_v< Compare, Key >) |
| Insert with stack tracking for count updates. | |
| Node * | searchFlipColorsAndInsertDup (Node *q) noexcept(nothrow_compare_v< Compare, Key >) |
| Node * | searchAndBuildPath (const Key &key, Path &path) noexcept(nothrow_compare_v< Compare, Key >) |
| void | findSuccAndSwap (Node *p, Node *&fp, Path &path) noexcept |
| void | balanceDownAndColor (Node *p, Node *&fp, Node *&sp, Path &path) noexcept |
| void | rotateNephewAndColor (Node *fp, Node *sp, Node *np, Path &path) noexcept |
| void | doubleRotateNephewAndColor (Node *fp, Node *sp, Node *snp, Path &path) noexcept |
| void | removeAndFixBlackCondition (Node *q, Path &path) noexcept |
| Remove node and fix red-black violations. | |
| void | init () noexcept |
Static Private Member Functions | |
| static Node * | getSibling (Node *p, Node *fp) noexcept |
| static Node * | rotate_to_right_rk (Node *p, Node *fp) noexcept |
| Right rotation with count update. | |
| static Node * | rotate_to_left_rk (Node *p, Node *fp) noexcept |
| Left rotation with count update. | |
| static void | flipColors (Node *p) noexcept |
| static void | colorSiblingAsRed (Node *sp) noexcept |
| static void | colorParentAndSibling (Node *fp, Node *sp) noexcept |
| static void | updateCountRec (Node *p) noexcept |
| Recursively update counts for entire subtree - O(n) | |
| static bool | verifyCountsRec (Node *p) noexcept |
Private Attributes | |
| Node | headNode |
| Node | headParent |
| Node | headGrandParent |
| Node * | head |
| Node * | fHead |
| Node * | ffHead |
| Node *& | root |
| Compare | cmp |
Hybrid top-down/bottom-up red-black tree with rank support.
This class implements a self-balancing binary search tree with O(log n) rank operations (select, position). It combines:
This is the only implementation that achieves O(log n) for ALL operations including removal with rank support.
| Key | The type of keys stored in the tree |
| Compare | Comparison functor (default: Aleph::less<Key>) |
Definition at line 94 of file tpl_hRbTreeRk.H.
| using Aleph::HtdRbTreeRk< Key, Compare >::Color = unsigned char |
Definition at line 97 of file tpl_hRbTreeRk.H.
| using Aleph::HtdRbTreeRk< Key, Compare >::key_type = Key |
Definition at line 734 of file tpl_hRbTreeRk.H.
| using Aleph::HtdRbTreeRk< Key, Compare >::Node = RbNodeRk<Key> |
Definition at line 98 of file tpl_hRbTreeRk.H.
|
private |
Definition at line 117 of file tpl_hRbTreeRk.H.
|
inlinenoexcept |
Builds an empty tree with a comparison criteria built by default.
It is a constructor apart from the one that takes the comparison, and not a default argument of that one: GCC and Clang do not count a default argument in the noexcept of the implicit default constructor of a tree that inherits these, and what the construction of the comparison threw would end the program there.
| what | the default construction of the key of a header node or of the comparison, or the copy of the comparison, throws; nothing when they are noexcept. |
Definition at line 754 of file tpl_hRbTreeRk.H.
|
inlinenoexcept |
Builds an empty tree with the comparison criteria __cmp.
| [in] | __cmp | the comparison criteria, which the tree copies. |
| what | the default construction of the key of a header node or the copy of __cmp throws; nothing when both are noexcept. The copy is from a Compare that is not const, which a comparison may have apart from the one from a const one. |
Definition at line 771 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::init().
|
inlinenoexcept |
Takes the nodes and the comparison criteria of tree, which is left empty and can take nodes again.
It builds no key, if it can: the key of each of the three header nodes is built by default when that cannot throw; else it is that of the same header node of tree, moved, when the move of a key cannot throw (see bin_node_detail::header_from()).
| [in,out] | tree | the tree to move from. It keeps its comparison criteria, which are copied: from a const one, or from one that is not const, if they have only that copy. Criteria that cannot be copied are moved, and tree keeps criteria that were moved from. |
| what | the copy of the comparison criteria throws, or their move if they cannot be copied; and what the default construction of the key of a header node throws, with a key whose move may throw too. Then tree keeps its nodes. Nothing when they are noexcept. |
Definition at line 815 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::init(), Aleph::RbNodeRk< Key >::NullPtr, and Aleph::HtdRbTreeRk< Key, Compare >::root.
|
delete |
|
virtualdefault |
|
inlineprivatenoexcept |
Definition at line 505 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, LLINK, RED, RLINK, Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_left_rk(), and Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_right_rk().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition().
|
inlinestaticprivatenoexcept |
Definition at line 588 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, LLINK, RED, and RLINK.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition().
|
inlinestaticprivatenoexcept |
Definition at line 582 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, and RED.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition().
|
inlineprivatenoexcept |
Definition at line 556 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, LLINK, RED, RLINK, Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_left_rk(), and Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_right_rk().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition().
|
inlineprivatenoexcept |
Definition at line 126 of file tpl_hRbTreeRk.H.
References Aleph::and, and Aleph::HtdRbTreeRk< Key, Compare >::cmp.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::remove(), Aleph::HtdRbTreeRk< Key, Compare >::search(), Aleph::HtdRbTreeRk< Key, Compare >::searchAndBuildPath(), and Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert().
|
inlinenoexcept |
Find position where key would be inserted.
Works even if key doesn't exist in the tree.
| key | Key to find position for |
| anything | that the comparison or its copy throws; the search does not modify the tree, so it is left as it was. |
noexcept only if the comparison and its copy cannot throw, so that what it throws reaches the caller. Definition at line 1034 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp, Aleph::HtdRbTreeRk< Key, Compare >::find_position(), r, and Aleph::HtdRbTreeRk< Key, Compare >::root.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::find_position().
|
inlineprivatenoexcept |
Definition at line 452 of file tpl_hRbTreeRk.H.
References COLOR, LLINK, Aleph::RbNodeRk< Key >::NullPtr, and RLINK.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition().
|
inlinestaticprivatenoexcept |
Definition at line 239 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, LLINK, Aleph::RbNodeRk< Key >::NullPtr, RED, and RLINK.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), and Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup().
|
inlineconstexprnoexcept |
Definition at line 739 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp.
|
inlinenoexcept |
Definition at line 738 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp.
|
inlinenoexcept |
Definition at line 990 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::root.
|
inlinenoexcept |
Definition at line 989 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::root.
|
inlinestaticprivatenoexcept |
Definition at line 130 of file tpl_hRbTreeRk.H.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition().
|
inlineprivatenoexcept |
Definition at line 719 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, Aleph::COUNT(), Aleph::HtdRbTreeRk< Key, Compare >::ffHead, Aleph::HtdRbTreeRk< Key, Compare >::fHead, Aleph::HtdRbTreeRk< Key, Compare >::head, Aleph::RbNodeRk< Key >::NullPtr, and RLINK.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::HtdRbTreeRk(), and Aleph::HtdRbTreeRk< Key, Compare >::HtdRbTreeRk().
|
inlinenoexcept |
Insert a node into the tree.
| p | Node to insert (must have COLOR=RED and null children) |
| anything | that the comparison throws; the color flips and rotations done on the way down leave a valid red-black tree with right counters, and p is linked after the last comparison, so the tree keeps its keys, without p. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 869 of file tpl_hRbTreeRk.H.
References COLOR, Aleph::COUNT(), Aleph::RbNodeRk< Key >::NullPtr, RED, Aleph::HtdRbTreeRk< Key, Compare >::root, and Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert().
Referenced by HtdRbTreeRkTest::insert_range(), Aleph::HtdRbTreeRk< Key, Compare >::search_or_insert(), Aleph::HtdRbTreeRk< Key, Compare >::split_pos(), and TEST_F().
|
inlinenoexcept |
Insert allowing duplicate keys.
| p | Node to insert |
| anything | that the comparison throws; then the tree is valid with its keys, without p, as in insert(). |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 922 of file tpl_hRbTreeRk.H.
References COLOR, Aleph::COUNT(), Aleph::RbNodeRk< Key >::NullPtr, RED, Aleph::HtdRbTreeRk< Key, Compare >::root, and Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup().
|
inlineconstexprnoexcept |
Definition at line 851 of file tpl_hRbTreeRk.H.
References Aleph::RbNodeRk< Key >::NullPtr, and Aleph::HtdRbTreeRk< Key, Compare >::root.
|
inlinenoexcept |
Definition at line 737 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp.
|
inlinenoexcept |
Definition at line 736 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp.
|
inlineprivatenoexcept |
Definition at line 122 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp.
|
delete |
|
inlinenoexcept |
Swaps the nodes and the comparison criteria with tree.
| [in,out] | tree | the tree to swap with. |
*this. | what | the swap of the comparison criteria throws, which goes first: then the nodes stay where they were. |
Definition at line 839 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::swap().
|
inlinenoexcept |
Find position of a key.
| key | Key to find |
| anything | that the comparison or its copy throws; the search does not modify the tree, so it is left as it was. |
noexcept only if the comparison and its copy cannot throw, so that what it throws reaches the caller. Definition at line 1014 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp, Aleph::inorder_position(), and Aleph::HtdRbTreeRk< Key, Compare >::root.
|
inlinenoexcept |
Remove node with given key.
| key | Key to remove |
| anything | that the comparison throws; the tree changes only after the last comparison, so it is left as it was. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 968 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::equals(), KEY, Aleph::RbNodeRk< Key >::NullPtr, Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition(), Aleph::RbNodeRk< Key >::reset(), Aleph::HtdRbTreeRk< Key, Compare >::root, and Aleph::HtdRbTreeRk< Key, Compare >::searchAndBuildPath().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::remove_pos().
|
inline |
Remove element at position i.
| i | Position (0-indexed) |
| std::out_of_range | if i >= size() |
Definition at line 1049 of file tpl_hRbTreeRk.H.
References ah_out_of_range_error_if, KEY, Aleph::HtdRbTreeRk< Key, Compare >::remove(), Aleph::HtdRbTreeRk< Key, Compare >::select(), and Aleph::HtdRbTreeRk< Key, Compare >::size().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::split_pos().
|
inlineprivatenoexcept |
Remove node and fix red-black violations.
After BST deletion and red-black fixing, recalculates all counts. The count update is O(n) due to the complexity of tracking all affected nodes during deletion with swaps and rotations.
Definition at line 614 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::balanceDownAndColor(), BLACK, COLOR, Aleph::HtdRbTreeRk< Key, Compare >::colorParentAndSibling(), Aleph::HtdRbTreeRk< Key, Compare >::colorSiblingAsRed(), Aleph::HtdRbTreeRk< Key, Compare >::doubleRotateNephewAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::findSuccAndSwap(), Aleph::HtdRbTreeRk< Key, Compare >::getSibling(), LLINK, Aleph::RbNodeRk< Key >::NullPtr, RED, RLINK, Aleph::HtdRbTreeRk< Key, Compare >::root, Aleph::HtdRbTreeRk< Key, Compare >::rotateNephewAndColor(), and Aleph::HtdRbTreeRk< Key, Compare >::updateCountRec().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::remove().
|
inlinenoexcept |
Definition at line 856 of file tpl_hRbTreeRk.H.
References Aleph::RbNodeRk< Key >::NullPtr, and Aleph::HtdRbTreeRk< Key, Compare >::root.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::split_pos().
|
inlineprivatenoexcept |
Definition at line 194 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, LLINK, RED, RLINK, Aleph::HtdRbTreeRk< Key, Compare >::root, Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_left_rk(), and Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_right_rk().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), and Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup().
|
inlinestaticprivatenoexcept |
Left rotation with count update.
Definition at line 170 of file tpl_hRbTreeRk.H.
References Aleph::COUNT(), LLINK, Aleph::RbNodeRk< Key >::NullPtr, and RLINK.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::balanceDownAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::doubleRotateNephewAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::restoreRedCondition(), and Aleph::HtdRbTreeRk< Key, Compare >::rotateNephewAndColor().
|
inlinestaticprivatenoexcept |
Right rotation with count update.
After rotation:
Definition at line 145 of file tpl_hRbTreeRk.H.
References Aleph::COUNT(), LLINK, Aleph::RbNodeRk< Key >::NullPtr, and RLINK.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::balanceDownAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::doubleRotateNephewAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::restoreRedCondition(), and Aleph::HtdRbTreeRk< Key, Compare >::rotateNephewAndColor().
|
inlineprivatenoexcept |
Definition at line 535 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, LLINK, RED, RLINK, Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_left_rk(), and Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_right_rk().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition().
|
inlinenoexcept |
Search for a key.
| key | Key to search for |
| anything | that the comparison throws; the search does not modify the tree, so it is left as it was. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 946 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::equals(), KEY, LLINK, Aleph::RbNodeRk< Key >::NullPtr, RLINK, and Aleph::HtdRbTreeRk< Key, Compare >::root.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::search_or_insert().
|
inlinenoexcept |
Search for key or insert if not found.
| p | Node to insert if key not found |
| anything | that the comparison throws; then the tree is valid with its keys, without p, as in insert(). |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 893 of file tpl_hRbTreeRk.H.
References COLOR, Aleph::COUNT(), Aleph::HtdRbTreeRk< Key, Compare >::insert(), KEY, Aleph::RbNodeRk< Key >::NullPtr, RED, Aleph::HtdRbTreeRk< Key, Compare >::root, and Aleph::HtdRbTreeRk< Key, Compare >::search().
|
inlineprivatenoexcept |
Definition at line 420 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::equals(), Aleph::HtdRbTreeRk< Key, Compare >::head, KEY, LLINK, Aleph::RbNodeRk< Key >::NullPtr, RLINK, and Aleph::HtdRbTreeRk< Key, Compare >::root.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::remove().
|
inlineprivatenoexcept |
Insert with stack tracking for count updates.
Uses a stack to track the path during insertion, then updates counts bottom-up after all rotations are complete. Each color flip and rotation on the way down leaves a valid red-black tree with right counters, and q is linked after the last comparison, so a comparison that throws leaves a valid tree without q.
Definition at line 257 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, Aleph::COUNT(), Aleph::HtdRbTreeRk< Key, Compare >::equals(), Aleph::HtdRbTreeRk< Key, Compare >::ffHead, Aleph::HtdRbTreeRk< Key, Compare >::fHead, Aleph::HtdRbTreeRk< Key, Compare >::flipColors(), Aleph::HtdRbTreeRk< Key, Compare >::head, KEY, LLINK, Aleph::RbNodeRk< Key >::NullPtr, RED, Aleph::HtdRbTreeRk< Key, Compare >::restoreRedCondition(), RLINK, and Aleph::HtdRbTreeRk< Key, Compare >::root.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::insert().
|
inlineprivatenoexcept |
Definition at line 341 of file tpl_hRbTreeRk.H.
References BLACK, COLOR, Aleph::COUNT(), Aleph::HtdRbTreeRk< Key, Compare >::ffHead, Aleph::HtdRbTreeRk< Key, Compare >::fHead, Aleph::HtdRbTreeRk< Key, Compare >::flipColors(), Aleph::HtdRbTreeRk< Key, Compare >::head, KEY, LLINK, Aleph::RbNodeRk< Key >::NullPtr, RED, Aleph::HtdRbTreeRk< Key, Compare >::restoreRedCondition(), RLINK, and Aleph::HtdRbTreeRk< Key, Compare >::root.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::insert_dup().
|
inline |
Select the i-th smallest element (0-indexed).
| i | Position (0 = smallest) |
| std::out_of_range | if i >= size() |
Definition at line 1000 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::root, and Aleph::select().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::remove_pos(), and TEST_F().
|
inlinenoexcept |
O(1) size using root count.
Definition at line 854 of file tpl_hRbTreeRk.H.
References Aleph::COUNT(), and Aleph::HtdRbTreeRk< Key, Compare >::root.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::remove_pos(), Aleph::HtdRbTreeRk< Key, Compare >::split_pos(), and TEST_F().
|
inline |
Split tree at position.
After split:
| pos | Split position |
| t1 | Tree for left part |
| t2 | Tree for right part |
| std::out_of_range | if pos > size() |
std::terminate()). t1 or t2 compares: a comparison that threw there would leave the node in transit out of every tree, so the move is noexcept. Definition at line 1073 of file tpl_hRbTreeRk.H.
References ah_out_of_range_error_if, Aleph::HtdRbTreeRk< Key, Compare >::insert(), Aleph::RbNodeRk< Key >::NullPtr, Aleph::HtdRbTreeRk< Key, Compare >::remove_pos(), Aleph::HtdRbTreeRk< Key, Compare >::reset(), Aleph::HtdRbTreeRk< Key, Compare >::root, and Aleph::HtdRbTreeRk< Key, Compare >::size().
|
inlinenoexcept |
Swaps in constant time the nodes and the comparison criteria of this and tree.
| [in,out] | tree | the tree to swap with. |
| what | the swap of the comparison criteria throws, which goes first: then the nodes stay where they were. |
Definition at line 790 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp, and Aleph::HtdRbTreeRk< Key, Compare >::root.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::operator=().
|
inlinestaticprivatenoexcept |
Recursively update counts for entire subtree - O(n)
Definition at line 599 of file tpl_hRbTreeRk.H.
References Aleph::COUNT(), LLINK, Aleph::RbNodeRk< Key >::NullPtr, RLINK, and Aleph::HtdRbTreeRk< Key, Compare >::updateCountRec().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition(), and Aleph::HtdRbTreeRk< Key, Compare >::updateCountRec().
|
inline |
Verify red-black and rank invariants.
| what | the comparator throws. |
Definition at line 1100 of file tpl_hRbTreeRk.H.
References Aleph::HtdRbTreeRk< Key, Compare >::cmp, Aleph::is_red_black_bst_rk(), Aleph::RbNodeRk< Key >::NullPtr, Aleph::HtdRbTreeRk< Key, Compare >::root, and Aleph::HtdRbTreeRk< Key, Compare >::verifyCountsRec().
Referenced by TEST_F().
|
inlinestaticprivatenoexcept |
Definition at line 1114 of file tpl_hRbTreeRk.H.
References Aleph::COUNT(), LLINK, Aleph::RbNodeRk< Key >::NullPtr, RLINK, and Aleph::HtdRbTreeRk< Key, Compare >::verifyCountsRec().
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::verify(), and Aleph::HtdRbTreeRk< Key, Compare >::verifyCountsRec().
|
private |
Definition at line 119 of file tpl_hRbTreeRk.H.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::equals(), Aleph::HtdRbTreeRk< Key, Compare >::find_position(), Aleph::HtdRbTreeRk< Key, Compare >::get_compare(), Aleph::HtdRbTreeRk< Key, Compare >::get_compare(), Aleph::HtdRbTreeRk< Key, Compare >::key_comp(), Aleph::HtdRbTreeRk< Key, Compare >::key_comp(), Aleph::HtdRbTreeRk< Key, Compare >::less(), Aleph::HtdRbTreeRk< Key, Compare >::position(), Aleph::HtdRbTreeRk< Key, Compare >::swap(), and Aleph::HtdRbTreeRk< Key, Compare >::verify().
|
private |
Definition at line 107 of file tpl_hRbTreeRk.H.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::init(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), and Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup().
|
private |
Definition at line 106 of file tpl_hRbTreeRk.H.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::init(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), and Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup().
|
private |
Definition at line 105 of file tpl_hRbTreeRk.H.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::init(), Aleph::HtdRbTreeRk< Key, Compare >::searchAndBuildPath(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), and Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup().
|
private |
Definition at line 103 of file tpl_hRbTreeRk.H.
|
private |
Definition at line 101 of file tpl_hRbTreeRk.H.
|
private |
Definition at line 102 of file tpl_hRbTreeRk.H.
|
private |
Definition at line 108 of file tpl_hRbTreeRk.H.
Referenced by Aleph::HtdRbTreeRk< Key, Compare >::HtdRbTreeRk(), Aleph::HtdRbTreeRk< Key, Compare >::find_position(), Aleph::HtdRbTreeRk< Key, Compare >::getRoot(), Aleph::HtdRbTreeRk< Key, Compare >::getRoot(), Aleph::HtdRbTreeRk< Key, Compare >::insert(), Aleph::HtdRbTreeRk< Key, Compare >::insert_dup(), Aleph::HtdRbTreeRk< Key, Compare >::is_empty(), Aleph::HtdRbTreeRk< Key, Compare >::position(), Aleph::HtdRbTreeRk< Key, Compare >::remove(), Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition(), Aleph::HtdRbTreeRk< Key, Compare >::reset(), Aleph::HtdRbTreeRk< Key, Compare >::restoreRedCondition(), Aleph::HtdRbTreeRk< Key, Compare >::search(), Aleph::HtdRbTreeRk< Key, Compare >::search_or_insert(), Aleph::HtdRbTreeRk< Key, Compare >::searchAndBuildPath(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::HtdRbTreeRk< Key, Compare >::select(), Aleph::HtdRbTreeRk< Key, Compare >::size(), Aleph::HtdRbTreeRk< Key, Compare >::split_pos(), Aleph::HtdRbTreeRk< Key, Compare >::swap(), and Aleph::HtdRbTreeRk< Key, Compare >::verify().