|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
AVL balanced binary search tree with rank (order statistics). More...
#include <tpl_avlRk.H>
Classes | |
| class | Iterator |
| Iterator over the nodes. More... | |
Public Types | |
| using | Node = NodeType< Key > |
| using | key_type = Key |
Public Member Functions | |
| constexpr Compare & | key_comp () noexcept |
| The key type. | |
| constexpr Compare & | get_compare () noexcept |
See key_comp(). | |
| Gen_Avl_Tree_Rk () 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. | |
| Gen_Avl_Tree_Rk (Compare cmf_fct) noexcept(std::is_nothrow_default_constructible_v< Node > and std::is_nothrow_constructible_v< Compare, Compare & >) | |
Builds an empty tree with the comparison criteria cmf_fct. | |
| Gen_Avl_Tree_Rk (const Gen_Avl_Tree_Rk &)=delete | |
| Not copyable: the tree does not own its nodes, and a copy would hold the same ones. | |
| Gen_Avl_Tree_Rk & | operator= (const Gen_Avl_Tree_Rk &)=delete |
| Not copyable, for the same reason as the copy constructor. | |
| Gen_Avl_Tree_Rk (Gen_Avl_Tree_Rk &&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. | |
| void | swap (Gen_Avl_Tree_Rk &tree) noexcept(std::is_nothrow_swappable_v< Compare >) |
Swap in constant time all the items of this with the items of tree. | |
| virtual | ~Gen_Avl_Tree_Rk () noexcept=default |
| constexpr Node *& | getRoot () noexcept |
| Return a modifiable reference to tree's root. | |
| constexpr Node * | getRoot () const noexcept |
| Return a pointer to the tree's root. | |
| size_t | size () const noexcept |
| Return the number of nodes in the tree. | |
| constexpr bool | is_empty () const noexcept |
| Return true if tree is empty. | |
| Node * | search (const Key &key) const noexcept(nothrow_compare_v< Compare, Key >) |
Search a node containing key. | |
| Node * | insert (Node *p) noexcept(nothrow_compare_v< Compare, Key >) |
| Insert the node pointed by p in the tree. | |
| Node * | search_or_insert (Node *p) noexcept(nothrow_compare_v< Compare, Key >) |
| Search or insert a key. | |
| Node * | insert_dup (Node *p) noexcept(nothrow_compare_v< Compare, Key >) |
| Insert the node p without testing for key duplicity. | |
| Node * | remove (const Key &key) noexcept(nothrow_compare_v< Compare, Key >) |
| Remove from tree the node containing key. | |
| Node * | select (const size_t i) const |
| Return the i-th node in order sense. | |
| std::pair< long, Node * > | position (const Key &key) const noexcept(nothrow_compare_copy_v< Compare, Key >) |
| Compute the inorder position of a key. | |
| std::pair< long, Node * > | find_position (const Key &key) const noexcept(nothrow_compare_copy_v< Compare, Key >) |
| Find the inorder position of a key in the tree. | |
| bool | verify () const |
| Return true if the tree is a valid AVL tree with correct counters and its keys are in order. | |
| void | join_exclusive (Gen_Avl_Tree_Rk &t) noexcept |
| Join this tree exclusively with another tree. | |
| Node * | split_key (const Key &key, Gen_Avl_Tree_Rk &t1, Gen_Avl_Tree_Rk &t2) noexcept |
| Split tree by key. | |
| void | split_key_dup (const Key &key, Gen_Avl_Tree_Rk &t1, Gen_Avl_Tree_Rk &t2) noexcept |
| Split tree by key including duplicates. | |
| void | split_pos (const size_t pos, Gen_Avl_Tree_Rk &t1, Gen_Avl_Tree_Rk &t2) noexcept |
| Split tree by inorder position. | |
Private Types | |
| enum | Rotation_Type { ROTATE_LEFT , ROTATE_RIGHT , DOUBLE_ROTATE_LEFT , DOUBLE_ROTATE_RIGHT } |
| using | Path = InlineStack< Node *, Node::MaxHeight+1 > |
Private Member Functions | |
| Node * | search_and_stack_avl (const Key &key, signed char &cmp_result, Path &path) noexcept(nothrow_compare_v< Compare, Key >) |
| Node * | search_dup_and_stack_avl (const Key &key, signed char &cmp_result, Path &path) noexcept(nothrow_compare_v< Compare, Key >) |
| void | restore_avl_after_insertion (Node *p, Path &path) noexcept |
| Node * | swapWithSuccessor (Node *p, Node *&pp, Path &path) noexcept |
| void | restore_avl_after_deletion (bool left_deficit, Path &path) noexcept |
| void | update_counters_after_insertion (const Path &path) noexcept |
| void | update_counters_after_deletion (const Path &path) noexcept |
| Node * | split_key_rec (Node *p, const Key &key, Node *&t1, Node *&t2) noexcept(nothrow_compare_v< Compare, Key >) |
| void | split_key_dup_rec (Node *p, const Key &key, Node *&t1, Node *&t2) noexcept(nothrow_compare_v< Compare, Key >) |
| void | split_pos_rec (Node *p, size_t pos, Node *&t1, Node *&t2) noexcept |
Static Private Member Functions | |
| static bool | at_head (const Path &path) noexcept |
true when path holds only the head node. | |
| static Node * | rotateLeft (Node *p) noexcept |
| static Node * | rotateRight (Node *p) noexcept |
| static Node * | doubleRotateLeft (Node *p) noexcept |
| static Node * | doubleRotateRight (Node *p) noexcept |
| static Rotation_Type | rotation_type (Node *p) noexcept |
| static Node * | restore_avl (Node *p, Node *pp) noexcept |
| static size_t | avl_height (Node *p) noexcept |
| static Node * | extract_min (Node *&p) noexcept |
| static Node * | extract_max (Node *&p) noexcept |
| static Node * | join_exclusive_rec (Node *t1, size_t h1, Node *t2, size_t h2) noexcept |
| static Node * | join_with_pivot (Node *t1, const size_t h1, Node *pivot, Node *t2, const size_t h2) noexcept |
| static Node * | join_right (Node *t1, const size_t h1, Node *pivot, Node *t2, const size_t h2) noexcept |
| static Node * | join_left (Node *t1, const size_t h1, Node *pivot, Node *t2, const size_t h2) noexcept |
Private Attributes | |
| Node | head_node |
| The type of node. | |
| Node * | head_ptr |
| Node *& | root |
| Compare | cmp |
AVL balanced binary search tree with rank (order statistics).
An AVL tree is a self-balancing binary search tree where the heights of the two child subtrees of any node differ by at most one. This guarantees O(log n) worst-case time complexity for search, insertion, and deletion operations.
The maximum height of an AVL tree with n nodes is bounded by: \( 1.4404 \lg{(n + 2)} - 0.3277 \)
This extended version maintains a count in each node representing the number of nodes in its subtree, enabling O(log n) operations for selecting by position and finding the position of a key.
| NodeType | Template for the node type (typically AvlNodeRk). |
| Key | The type of keys stored in the tree. |
| Compare | Comparison functor for ordering keys. |
Definition at line 108 of file tpl_avlRk.H.
| using Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::key_type = Key |
Definition at line 513 of file tpl_avlRk.H.
| using Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::Node = NodeType<Key> |
Definition at line 111 of file tpl_avlRk.H.
|
private |
Definition at line 123 of file tpl_avlRk.H.
|
private |
| Enumerator | |
|---|---|
| ROTATE_LEFT | |
| ROTATE_RIGHT | |
| DOUBLE_ROTATE_LEFT | |
| DOUBLE_ROTATE_RIGHT | |
Definition at line 332 of file tpl_avlRk.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 540 of file tpl_avlRk.H.
|
inlinenoexcept |
Builds an empty tree with the comparison criteria cmf_fct.
| [in] | cmf_fct | the comparison criteria, which the tree copies. |
| what | the default construction of the key of a header node or the copy of cmf_fct 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 557 of file tpl_avlRk.H.
|
delete |
Not copyable: the tree does not own its nodes, and a copy would hold the same ones.
The copy that the compiler wrote did worse: the copy used the header node of the tree that it copied, so that the two were one tree, and std::move() of a tree copied it too. Move the tree, which leaves the other one empty, or copy its nodes (copyRec()).
|
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 the header node is built by default when that cannot throw; else it is that of the 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 the header node throws, with a key whose move may throw too. Then tree keeps its nodes. Nothing when they are noexcept. |
Definition at line 595 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
|
virtualdefaultnoexcept |
|
inlinestaticprivatenoexcept |
true when path holds only the head node.
Definition at line 126 of file tpl_avlRk.H.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_insertion(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_avl().
|
inlinestaticprivatenoexcept |
Definition at line 891 of file tpl_avlRk.H.
References DIFF, h, LLINK, and RLINK.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive_rec(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_rec(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos_rec().
|
inlinestaticprivatenoexcept |
Definition at line 254 of file tpl_avlRk.H.
References Aleph::and, Aleph::COUNT(), DIFF, LLINK, r, and RLINK.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl().
|
inlinestaticprivatenoexcept |
Definition at line 294 of file tpl_avlRk.H.
References Aleph::and, Aleph::COUNT(), DIFF, LLINK, r, and RLINK.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl().
|
inlinestaticprivatenoexcept |
Definition at line 964 of file tpl_avlRk.H.
References Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateRight(), Aleph::InlineStack< T, N >::is_empty(), LLINK, Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::push(), RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateRight().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive_rec().
|
inlinestaticprivatenoexcept |
Definition at line 908 of file tpl_avlRk.H.
References Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateLeft(), Aleph::InlineStack< T, N >::is_empty(), LLINK, Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::push(), RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateLeft().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive_rec().
|
inlinenoexcept |
Find the inorder position of a key in the tree.
| [in] | key | to be searched |
| 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 858 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::BinTreeXt_Operation< Node, Cmp >::find_position(), r, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
|
inlineconstexprnoexcept |
See key_comp().
Definition at line 522 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::key_comp().
|
inlineconstexprnoexcept |
Return a pointer to the tree's root.
Definition at line 630 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
|
inlineconstexprnoexcept |
Return a modifiable reference to tree's root.
Definition at line 624 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
Referenced by TEST().
|
inlinenoexcept |
Insert the node pointed by p in the tree.
| [in] | p | the node to be inserted |
| anything | that the comparison throws; the tree changes only after the last comparison, so it is left as it was, without p. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 673 of file tpl_avlRk.H.
References Aleph::CmpEqual, Aleph::CmpGreater, Aleph::CmpLess, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::head_ptr, KEY, LLINK, Aleph::InlineStack< T, N >::push(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_insertion(), RLINK, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::update_counters_after_insertion().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Insert the node p without testing for key duplicity.
| [in] | p | the node to be inserted |
p | anything | that the comparison throws; the tree changes only after the last comparison, so it is left as it was, without p. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 737 of file tpl_avlRk.H.
References Aleph::CmpEqual, Aleph::CmpLess, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::head_ptr, KEY, LLINK, Aleph::InlineStack< T, N >::push(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_insertion(), RLINK, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_avl(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::update_counters_after_insertion().
|
inlineconstexprnoexcept |
|
inlinenoexcept |
Join this tree exclusively with another tree.
All keys in this tree must be less than all keys in t. After the operation, t becomes empty and this tree contains all nodes.
| [in,out] | t | tree to join with (will be empty after) |
std::terminate()). noexcept because it inserts the nodes of t one by one: a comparison that threw in the middle would leave nodes out of both trees. Definition at line 1345 of file tpl_avlRk.H.
References Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::InlineStack< T, N >::is_empty(), LLINK, Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::push(), RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
|
inlinestaticprivatenoexcept |
Definition at line 1018 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::avl_height(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot().
|
inlinestaticprivatenoexcept |
Definition at line 1124 of file tpl_avlRk.H.
References Aleph::and, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::avl_height(), Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateRight(), Aleph::InlineStack< T, N >::is_empty(), LLINK, Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::push(), RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateRight().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot().
|
inlinestaticprivatenoexcept |
Definition at line 1073 of file tpl_avlRk.H.
References Aleph::and, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::avl_height(), Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateLeft(), Aleph::InlineStack< T, N >::is_empty(), LLINK, Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::push(), RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateLeft().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot().
|
inlinestaticprivatenoexcept |
Definition at line 1048 of file tpl_avlRk.H.
References Aleph::and, Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), LLINK, and RLINK.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive_rec(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_rec(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos_rec().
|
inlineconstexprnoexcept |
The key type.
Return a reference to the comparison criteria
Definition at line 516 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::get_compare().
|
delete |
Not copyable, for the same reason as the copy constructor.
|
inlinenoexcept |
Compute the inorder position of a key.
| [in] | key | to be searched |
| 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 838 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::BinTreeXt_Operation< Node, Cmp >::inorder_position(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
|
inlinenoexcept |
Remove from tree the node containing key.
| [in] | key | the key to remove |
nullptr otherwise | 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 766 of file tpl_avlRk.H.
References Aleph::CmpEqual, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::head_ptr, LLINK, Aleph::InlineStack< T, N >::push(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_deletion(), RLINK, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::swapWithSuccessor(), Aleph::InlineStack< T, N >::top(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::update_counters_after_deletion().
|
inlinestaticprivatenoexcept |
Definition at line 360 of file tpl_avlRk.H.
References AH_ERROR, DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::DOUBLE_ROTATE_LEFT, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::DOUBLE_ROTATE_RIGHT, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateLeft(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateRight(), LLINK, RLINK, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::ROTATE_LEFT, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::ROTATE_RIGHT, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateLeft(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateRight(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotation_type().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_deletion(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_insertion().
|
inlineprivatenoexcept |
Definition at line 470 of file tpl_avlRk.H.
References DIFF, LLINK, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove().
|
inlineprivatenoexcept |
Definition at line 384 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::at_head(), DIFF, LLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert_dup(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_or_insert().
|
inlinestaticprivatenoexcept |
Definition at line 204 of file tpl_avlRk.H.
References Aleph::COUNT(), DIFF, LLINK, and RLINK.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl().
|
inlinestaticprivatenoexcept |
Definition at line 229 of file tpl_avlRk.H.
References Aleph::COUNT(), DIFF, LLINK, and RLINK.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl().
|
inlinestaticprivatenoexcept |
Definition at line 340 of file tpl_avlRk.H.
References DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::DOUBLE_ROTATE_LEFT, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::DOUBLE_ROTATE_RIGHT, LLINK, RLINK, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::ROTATE_LEFT, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::ROTATE_RIGHT.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl().
|
inlinenoexcept |
Search a node containing key.
| [in] | key | the key to search |
key if it is found; otherwise nullptr | 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 657 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
Referenced by TEST().
|
inlineprivatenoexcept |
Definition at line 133 of file tpl_avlRk.H.
References Aleph::and, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::at_head(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::CmpEqual, Aleph::CmpGreater, Aleph::CmpLess, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::head_ptr, KEY, LLINK, RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_or_insert().
|
inlineprivatenoexcept |
Definition at line 176 of file tpl_avlRk.H.
References Aleph::and, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::at_head(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::CmpEqual, Aleph::CmpGreater, Aleph::CmpLess, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::head_ptr, KEY, LLINK, RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert_dup().
|
inlinenoexcept |
Search or insert a key.
| [in] | p | the node whose key must be searched and eventually inserted |
| anything | that the comparison throws; the tree changes only after the last comparison, so it is left as it was, without p. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 706 of file tpl_avlRk.H.
References Aleph::CmpEqual, Aleph::CmpGreater, Aleph::CmpLess, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::head_ptr, KEY, LLINK, Aleph::InlineStack< T, N >::push(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_insertion(), RLINK, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::update_counters_after_insertion().
Referenced by TEST().
|
inline |
Return the i-th node in order sense.
| [in] | i | inorder position of node to be selected |
| out_of_range | if i is greater or equal than the number of nodes of tree |
Definition at line 823 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root, and Aleph::select().
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Return the number of nodes in the tree.
Definition at line 636 of file tpl_avlRk.H.
References Aleph::COUNT(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Split tree by key.
After the operation:
| [in] | key | the splitting key |
| [out] | t1 | tree to receive keys < key |
| [out] | t2 | tree to receive keys > key |
std::terminate()). noexcept because it moves the nodes one by one: a comparison that threw in the middle would leave nodes out of every tree. Definition at line 1402 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::COUNT(), DIFF, Aleph::InlineStack< T, N >::is_empty(), KEY, LLINK, Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::push(), RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
|
inlinenoexcept |
Split tree by key including duplicates.
After the operation:
| [in] | key | the splitting key |
| [out] | t1 | tree to receive keys <= key |
| [out] | t2 | tree to receive keys > key |
std::terminate()). noexcept because it moves the nodes one by one: a comparison that threw in the middle would leave nodes out of every tree. Definition at line 1458 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::COUNT(), DIFF, Aleph::InlineStack< T, N >::is_empty(), KEY, LLINK, Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::push(), RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
Referenced by TEST().
|
inlineprivatenoexcept |
Definition at line 1238 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::avl_height(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot(), KEY, LLINK, RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec().
|
inlineprivatenoexcept |
Definition at line 1175 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::avl_height(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot(), KEY, LLINK, RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_rec().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_rec().
|
inlinenoexcept |
Split tree by inorder position.
After the operation:
| [in] | pos | the splitting position (0-based) |
| [out] | t1 | tree to receive positions [0, pos) |
| [out] | t2 | tree to receive positions [pos, size) |
std::terminate()). noexcept because it inserts the nodes one by one in t1 and t2, which compares: a comparison that threw in the middle would leave nodes out of every tree. Definition at line 1508 of file tpl_avlRk.H.
References Aleph::count(), Aleph::COUNT(), DIFF, Aleph::InlineStack< T, N >::is_empty(), LLINK, Aleph::InlineStack< T, N >::pop(), Aleph::InlineStack< T, N >::push(), RLINK, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::size().
|
inlineprivatenoexcept |
Definition at line 1285 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::avl_height(), Aleph::COUNT(), DIFF, Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot(), LLINK, RLINK, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos_rec().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos_rec().
|
inlinenoexcept |
Swap in constant time all the items of this with the items of tree.
| [in] | 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 613 of file tpl_avlRk.H.
References Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
|
inlineprivatenoexcept |
Definition at line 419 of file tpl_avlRk.H.
References Aleph::COUNT(), DIFF, LLINK, and RLINK.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove().
|
inlineprivatenoexcept |
Definition at line 505 of file tpl_avlRk.H.
References Aleph::COUNT().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove().
|
inlineprivatenoexcept |
Definition at line 495 of file tpl_avlRk.H.
References Aleph::COUNT().
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert_dup(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_or_insert().
|
inline |
Return true if the tree is a valid AVL tree with correct counters and its keys are in order.
It throws what the comparator throws.
Definition at line 870 of file tpl_avlRk.H.
References Aleph::and, Aleph::check_bst(), Aleph::check_rank_tree(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::cmp, Aleph::is_avl_rk(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::root.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
private |
Definition at line 117 of file tpl_avlRk.H.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::find_position(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::key_comp(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::position(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_rec(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::swap(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::verify().
|
private |
The type of node.
Definition at line 114 of file tpl_avlRk.H.
|
private |
Definition at line 115 of file tpl_avlRk.H.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_avl(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_or_insert().
|
private |
Definition at line 116 of file tpl_avlRk.H.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::Gen_Avl_Tree_Rk(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::find_position(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::is_empty(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::position(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_deletion(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::select(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::size(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::swap(), and Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::verify().