|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Randomized binary search tree with rank support. More...
#include <tpl_rand_tree.H>
Classes | |
| struct | Iterator |
| Iterator on nodes of the tree. More... | |
Public Types | |
| using | Node = NodeType< Key > |
Public Member Functions | |
| Gen_Rand_Tree (const Gen_Rand_Tree &)=delete | |
| Gen_Rand_Tree & | operator= (const Gen_Rand_Tree &)=delete |
| Compare & | key_comp () noexcept |
| return the comparison criteria | |
| const Compare & | key_comp () const noexcept |
| Compare & | get_compare () noexcept |
| const Compare & | get_compare () const noexcept |
| gsl_rng * | gsl_rng_object () noexcept |
| Get a pointer to gsl random number generator. | |
| void | set_seed (const unsigned long seed) noexcept |
| Set the random number generator seed. | |
| Gen_Rand_Tree (const unsigned int seed, const Compare &__cmp=Compare()) | |
Initialize a random tree with random seed and comparison criteria __cmp | |
| Gen_Rand_Tree (const Compare &cmp=Compare()) noexcept | |
Initialize a random tree with random seed from system time and comparison criteria cmp | |
| void | swap (Gen_Rand_Tree &tree) noexcept |
Swap in constant time all the nodes of this with tree | |
| Gen_Rand_Tree (Gen_Rand_Tree &&other) noexcept | |
| Move constructor - transfers ownership of tree and RNG. | |
| Gen_Rand_Tree & | operator= (Gen_Rand_Tree &&other) noexcept |
| Move assignment - transfers ownership of tree and RNG. | |
| virtual | ~Gen_Rand_Tree () noexcept |
| Node * | insert (Node *p) noexcept |
| Insert a node in the tree. | |
| Node * | insert_dup (Node *p) noexcept |
| Insert a node in the tree. | |
| Node * | remove (const Key &key) noexcept |
| Remove a key from the tree. | |
| Node * | search (const Key &key) const noexcept |
| Search a key. | |
| Node * | search_or_insert (Node *p) noexcept |
| Search or insert a key. | |
| bool | verify () const |
Return true if this is a consistent randomized tree. | |
| Node *& | getRoot () noexcept |
| Return the tree's root. | |
| Node * | select (const size_t i) const |
| Return the i-th node in inorder sense. | |
| size_t | size () const noexcept |
| Return the number of nodes that have the tree. | |
| bool | is_empty () const noexcept |
| Return true if the tree is empty. | |
| std::pair< long, Node * > | position (const Key &key) const noexcept |
| Compute the inorder position of a key. | |
| std::pair< long, Node * > | find_position (const Key &key) const noexcept |
| Find the inorder position of a key in the tree. | |
| Node * | remove_pos (const size_t i) |
Remove the key at inorder position i | |
| bool | split_key (const Key &key, Gen_Rand_Tree &t1, Gen_Rand_Tree &t2) noexcept |
| Split the tree according to a key. | |
| void | split_key_dup (const Key &key, Gen_Rand_Tree &t1, Gen_Rand_Tree &t2) noexcept |
| Split the tree according to a key that could be in the tree. | |
| void | split_pos (size_t pos, Gen_Rand_Tree &t1, Gen_Rand_Tree &t2) noexcept |
| Split a extended binary tree according to a position. | |
| void | join (Gen_Rand_Tree &t, Gen_Rand_Tree &dup) noexcept |
Join this with t filtering the duplicated keys. | |
| void | join_dup (Gen_Rand_Tree &t) noexcept |
Join this with t independently of the presence of duplicated keys. | |
| void | join_exclusive (Gen_Rand_Tree &t) noexcept |
Join exclusive of this with t | |
Private Member Functions | |
| Node * | random_insert (Node *root, Node *p) noexcept |
| Node * | random_insert_dup (Node *root, Node *p) noexcept |
| Node * | random_search_or_insert (Node *&root, Node *p) noexcept |
| void | init (const unsigned long seed) |
| Node * | random_join_exclusive (Node *tl, Node *tr) noexcept |
| Node * | random_remove (Node *&root, const Key &key) noexcept |
| Node * | remove_pos (Node *&root, const size_t pos) noexcept |
| Node * | random_join (Node *t1, Node *t2, Node *&dup) |
| Node * | random_join (Node *t1, Node *t2) |
Private Attributes | |
| Node * | tree_root |
| The type of node. | |
| gsl_rng * | r |
| Compare | cmp |
Randomized binary search tree with rank support.
This class implements a randomized binary search tree where random decisions during insertion and deletion ensure that the tree has the same expected properties as if it were built from a random permutation of keys, regardless of actual insertion order.
This allows treating the tree like a sorted dynamic array with O(log n) indexed access, insertion, and deletion.
| NodeType | Node template (RandNode or RandNodeVtl). |
| Key | The type of keys stored in the tree. |
| Compare | Comparison functor for ordering keys. |
Definition at line 151 of file tpl_rand_tree.H.
| using Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::Node = NodeType<Key> |
Definition at line 154 of file tpl_rand_tree.H.
|
delete |
|
inline |
Initialize a random tree with random seed and comparison criteria __cmp
Definition at line 307 of file tpl_rand_tree.H.
References Aleph::init.
|
inlinenoexcept |
Initialize a random tree with random seed from system time and comparison criteria cmp
Definition at line 315 of file tpl_rand_tree.H.
|
inlinenoexcept |
Move constructor - transfers ownership of tree and RNG.
Definition at line 329 of file tpl_rand_tree.H.
References Aleph::maps().
|
inlinevirtualnoexcept |
Definition at line 358 of file tpl_rand_tree.H.
References Aleph::maps(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r.
|
inlinenoexcept |
Find the inorder position of a key in the tree.
find_position(key) determines the inorder position that has or had key in the tree. Themethod return a tuple with a position and a node pointer.
If key is found then its inorder position is returned along with a pointer to the node containing it.
Otherwise, the tuple returns the position that would have key if this was in the tree and the parent node that the key should be. At this regard, there are three cases:
key is lesser than the minimum key of tree, then first is -1 and the node is one with the smallest key.key is greater than the maximum key in the tree, then first is the number of keys and the node is one with the maximum key in the tree.key if this was in the tree and second is the node whose key is immediately greater than key.| [in] | key | to be searched |
Definition at line 572 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::find_position(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::find_position(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 294 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp.
|
inlinenoexcept |
Definition at line 291 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::key_comp().
Referenced by TEST().
|
inlinenoexcept |
Return the tree's root.
Definition at line 508 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by destroy_tree(), RankTreeTest< Tree >::TearDown(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), test(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and write_rand().
|
inlinenoexcept |
Get a pointer to gsl random number generator.
Definition at line 297 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r.
Referenced by TEST().
Definition at line 274 of file tpl_rand_tree.H.
References ah_bad_alloc_if, Aleph::maps(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r.
|
inlinenoexcept |
Insert a node in the tree.
| [in] | p | pointer to the node to insert |
p->get_key() is not in the tree, then the pointer p is returned (it was inserted); otherwise, nullptr is returned Definition at line 372 of file tpl_rand_tree.H.
References Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert(), Aleph::RLINK(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by RankTreeTest< Tree >::insert_all(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), test(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and write_rand().
|
inlinenoexcept |
Insert a node in the tree.
This method does not fail. It always inserts.
| [in] | p | pointer to the node to insert |
p pointer Definition at line 392 of file tpl_rand_tree.H.
References Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), Aleph::RLINK(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Return true if the tree is empty.
Definition at line 526 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by destroy_tree(), RankTreeTest< Tree >::TearDown(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Join this with t filtering the duplicated keys.
join(t, dup) produces a random tree result of join of this and t. The resulting tree is stored in this.
Nodes containing duplicated keys are inserted in the randomized tree dup. The nodes could belong to any of two trees
| [in] | t | randomized tree to join with this |
| [out] | dup | randomized tree where nodes containing duplicated keys are inserted |
Definition at line 758 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
|
inlinenoexcept |
Join this with t independently of the presence of duplicated keys.
join(t) produces a random tree result of join of this and t. The resulting tree is stored in this.
| [in] | t | randomized tree to join with this keys are inserted |
Definition at line 772 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
|
inlinenoexcept |
Join exclusive of this with t
Exclusive means that all the keys of this are lesser than all the keys of t. This knowledge allows a more efficient way for joining that when the keys ranks are overlapped. However, use very carefully because the algorithm does not perform any check and the result would be incorrect.
| [in] | t | randomized tree to exclusively join with this keys are inserted |
Definition at line 789 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 288 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp.
|
inlinenoexcept |
return the comparison criteria
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 285 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp.
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::get_compare(), TEST(), and TEST().
|
delete |
|
inlinenoexcept |
Move assignment - transfers ownership of tree and RNG.
Definition at line 337 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::destroyRec(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
|
inlineprivatenoexcept |
Definition at line 161 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::COUNT(), Aleph::BinTreeXt_Operation< Node, Cmp >::insert_root(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert(), Aleph::RLINK(), and root().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert().
|
inlineprivatenoexcept |
Definition at line 201 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::COUNT(), Aleph::BinTreeXt_Operation< Node, Cmp >::insert_dup_root(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), Aleph::RLINK(), and root().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join().
|
inlineprivate |
Definition at line 712 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::COUNT(), Aleph::insert_dup_root_xt(), l, Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::HTList::reset(), and Aleph::RLINK().
|
inlineprivate |
Definition at line 661 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::COUNT(), Aleph::insert_root_xt(), KEY, l, Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), Aleph::HTList::reset(), and Aleph::RLINK().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::join_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join().
|
inlineprivatenoexcept |
Definition at line 402 of file tpl_rand_tree.H.
References Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), and Aleph::RLINK().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos().
|
inlineprivatenoexcept |
Definition at line 423 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::COUNT(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), Aleph::HTList::reset(), Aleph::RLINK(), and root().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove().
|
inlineprivatenoexcept |
Definition at line 226 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::COUNT(), Aleph::insert_root(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), Aleph::RLINK(), and root().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::search_or_insert().
|
inlinenoexcept |
Remove a key from the tree.
| [in] | key | to remove |
key was found in the tree, nullptr otherwise Definition at line 462 of file tpl_rand_tree.H.
References Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by destroy_tree(), RankTreeTest< Tree >::TearDown(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inline |
Remove the key at inorder position i
| [in] | i | inorder position to be removed |
| out_of_range | if i is greater or equal than the number of nodes of tree |
Definition at line 607 of file tpl_rand_tree.H.
References ah_out_of_range_error_if, Aleph::COUNT(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
|
inlineprivatenoexcept |
Definition at line 583 of file tpl_rand_tree.H.
References Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), Aleph::RLINK(), and root().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Search a key.
| [in] | key | to be searched |
nullptr Definition at line 475 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::maps(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), test(), TEST_F(), TEST_F(), TEST_F(), and write_rand().
|
inlinenoexcept |
Search or insert a key.
search_or_insert(p) searches in the tree the key KEY(p). If this key is found, then a pointer to the node containing it is returned. Otherwise, p is inserted.
| [in] | p | node containing a key to be searched and eventually inserted |
p is found, then a pointer to the containing key in the tree is returned. Otherwise, p is inserted and returned Definition at line 493 of file tpl_rand_tree.H.
References Aleph::COUNT(), Aleph::maps(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
|
inline |
Return the i-th node in inorder sense.
| [in] | i | inorder position to be located |
| out_of_range | if i is greater or equal that the number of nodes |
Definition at line 517 of file tpl_rand_tree.H.
References Aleph::select(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Set the random number generator seed.
Definition at line 300 of file tpl_rand_tree.H.
References Aleph::maps(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r.
|
inlinenoexcept |
Return the number of nodes that have the tree.
Definition at line 523 of file tpl_rand_tree.H.
References Aleph::COUNT(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and write_rand().
|
inlinenoexcept |
Split the tree according to a key.
| [in] | key | for splitting |
| [out] | t1 | tree with keys lesser than key |
| [out] | t2 | tree with keys greater than key |
true if tree was split; that is if key is not in the tree. Otherwise, if key is in the tree, false is returned Definition at line 622 of file tpl_rand_tree.H.
References Aleph::maps(), Aleph::split_key_rec_xt(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
|
inlinenoexcept |
Split the tree according to a key that could be in the tree.
split_dup(key, t1, t2) splits the tree according to key in two trees t1 which contains the key lesser than key and t2 which contains the keys greater or equal than key.
| [in] | key | for splitting |
| [out] | t1 | resulting tree with the keys lesser than key |
| [out] | t2 | resulting tree with the keys greater or equal than key |
Definition at line 638 of file tpl_rand_tree.H.
References Aleph::maps(), Aleph::split_key_dup_rec_xt(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by TEST().
|
inlinenoexcept |
Split a extended binary tree according to a position.
split_pos(pos, ts, tg) splits the tree two trees t1 and t2 according to a position pos. t1 contains the keys from 0 to pos - 1 inorder sense and tg the keys from pos to n -
this becames empty.| [in] | pos | position for splitting |
| [out] | t1 | tree where the rank of keys \([0, i)\) will be put |
| [out] | t2 | tree where the rank of keys \([i, n]\) will be put |
Definition at line 655 of file tpl_rand_tree.H.
References Aleph::maps(), Aleph::split_pos_rec(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by TEST().
|
inlinenoexcept |
Swap in constant time all the nodes of this with tree
Definition at line 321 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::r, and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
|
inline |
Return true if this is a consistent randomized tree.
Definition at line 502 of file tpl_rand_tree.H.
References Aleph::check_rank_tree(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
private |
Definition at line 159 of file tpl_rand_tree.H.
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::find_position(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::get_compare(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::key_comp(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::key_comp(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::operator=(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::position(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::search(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::swap().
|
private |
Definition at line 158 of file tpl_rand_tree.H.
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::~Gen_Rand_Tree(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::find_position(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::gsl_rng_object(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::init(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::operator=(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::set_seed(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::swap().
|
private |
The type of node.
Definition at line 157 of file tpl_rand_tree.H.
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::find_position(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::is_empty(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::join_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::operator=(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::position(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::search(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::select(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::size(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::split_key(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::split_pos(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::swap(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::verify().