|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Functor encompassing basic operation for extended binary search trees. More...
#include <tpl_binTreeOps.H>
Public Types | |
| using | Key = typename Node::key_type |
Public Types inherited from Aleph::BinTree_Operation< Node, Cmp > | |
| using | Key = typename Node::key_type |
| using | key_type = typename Node::key_type |
| The type of key. | |
Public Member Functions | |
| BinTreeXt_Operation (Cmp cmp=Cmp()) noexcept(std::is_nothrow_constructible_v< Cmp, Cmp & >) | |
Initialize the functor with comparison criteria cmp. | |
| long | inorder_position (Node *r, const Key &key, Node *&p) noexcept(nothrow_compare_v< Cmp, Key >) |
| Compute the inorder position of a key. | |
| long | find_position (Node *r, const Key &key, Node *&p) noexcept(nothrow_compare_v< Cmp, Key >) |
| Find the inorder position of a key in an extended binary search tree. | |
| bool | split_key_rec (Node *root, const Key &key, Node *&l, Node *&r) noexcept(nothrow_compare_v< Cmp, Key >) |
| Split an extended binary search tree according to a key. | |
| void | split_key_dup_rec (Node *root, const Key &key, Node *&l, Node *&r) noexcept(nothrow_compare_v< Cmp, Key >) |
| Split an extended binary search tree according to a key which can be in the tree. | |
| Node * | insert_root (Node *&root, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
Insert a node p as root of an extended binary search tree. | |
| Node * | insert_dup_root (Node *&root, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
| Insert a node as root of an extended binary search tree. | |
Public Member Functions inherited from Aleph::BinTree_Operation< Node, Cmp > | |
| Cmp & | key_comp () noexcept |
| Return the comparison criteria. | |
| Cmp & | get_compare () noexcept |
See key_comp(). | |
| BinTree_Operation (Cmp cmp_=Cmp()) noexcept(std::is_nothrow_constructible_v< Cmp, Cmp & >) | |
| The type of key. | |
| Node * | search (Node *root, const Key &key) noexcept(nothrow_compare_v< Cmp, Key >) |
| Search a node with a specific key. | |
| Node * | search_parent (Node *root, const Key &key, Node *&parent) noexcept(nothrow_compare_v< Cmp, Key >) |
| Search a key and find its node and parent. | |
| Node * | search_rank_parent (Node *root, const Key &key) noexcept(nothrow_compare_v< Cmp, Key >) |
| Rank search of a key in a binary search tree. | |
| Node * | insert (Node *&root, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
Insert a node p in a binary search tree. | |
| Node * | insert_dup (Node *&root, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
Insert a node p in a binary search tree. | |
| Node * | search_or_insert (Node *&r, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
| Search or insert a node in a binary search tree. | |
| bool | split_key_rec (Node *&root, const Key &key, Node *&ts, Node *&tg) noexcept(nothrow_compare_v< Cmp, Key >) |
| Split recursively according to a key. | |
| void | split_key_dup_rec (Node *&root, const typename Node::key_type &key, Node *&ts, Node *&tg) noexcept(nothrow_compare_v< Cmp, Key >) |
| Split a tree according to a key value. | |
| Node * | remove (Node *&root, const Key &key) noexcept(nothrow_compare_v< Cmp, Key >) |
| Remove a key from a binary search tree. | |
| Node * | insert_root (Node *&root, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
Insert the node p as the root of a binary search tree. | |
| Node * | insert_dup_root (Node *&root, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
Insert node p as root of a binary search tree. | |
| Node * | join_preorder (Node *t1, Node *t2, Node *&dup) noexcept |
| Union of two binary search trees. | |
| Node * | join (Node *t1, Node *t2, Node *&dup) noexcept |
| Fast union of two binary search trees. | |
| void | split_key (Node *root, const Key &key, Node *&l, Node *&r) noexcept |
| Split a binary search tree according to a key. | |
| Node * | insert_root_rec (Node *root, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
| Insert a node as root in a binary search tree. | |
| Node * | search_or_insert_root_rec (Node *root, Node *p) noexcept(nothrow_compare_v< Cmp, Key >) |
Search and eventually insert p as root in a binary search tree. | |
Additional Inherited Members | |
Protected Attributes inherited from Aleph::BinTree_Operation< Node, Cmp > | |
| Cmp | cmp |
Functor encompassing basic operation for extended binary search trees.
Its operations compare before they change the tree, and are noexcept only if the comparison cannot throw (nothrow_compare_v): what it throws reaches the caller, with the tree as it was.
Definition at line 707 of file tpl_binTreeOps.H.
| using Aleph::BinTreeXt_Operation< Node, Cmp >::Key = typename Node::key_type |
Definition at line 710 of file tpl_binTreeOps.H.
|
inlinenoexcept |
Initialize the functor with comparison criteria cmp.
| [in] | cmp | the comparison criteria, which the functor copies. |
| anything | that the copy of Cmp throws; it is noexcept only if that copy cannot throw, so that what it throws reaches the caller. |
Definition at line 719 of file tpl_binTreeOps.H.
|
inlinenoexcept |
Find the inorder position of a key in an extended binary search tree.
find_position(r, key, p) searches key in the tree with root r. If key is found then its inorder position is returned and a pointer to the node containing the key is written in output parameter p. Otherwise, the function returns the position that would have key if this was in the tree. At this regard, there are three cases:
key is lesser than the minimum key of tree, then -1 is returned and p is the node with the smallest key.key is greater than the maximum key in the tree, then the number of keys is returned and p is the node with the maximum key in the tree.key if this was in the tree and p is the node whose key is immediately greater than key.| [in] | r | root of the tree |
| [in] | key | to be searched |
| [out] | p | reference to pointer to node |
key in the tree | anything | that the comparison throws; the search does not modify the tree, and p is written only at the end. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 794 of file tpl_binTreeOps.H.
References Aleph::BinTree_Operation< Node, Cmp >::cmp, Aleph::COUNT(), KEY, LLINK, Aleph::next(), r, and RLINK.
Referenced by Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::find_position().
|
inlinenoexcept |
Insert a node as root of an extended binary search tree.
insert_dup_root(root, p) inserts the node p as the new root of the tree root.
This insertion allows duplicates.
| [in,out] | root | of tree |
| [in] | p | pointer to the to insert |
p that has become root | anything | that the comparison throws; the split compares before it changes the tree, so the tree is left as it was. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 972 of file tpl_binTreeOps.H.
References Aleph::COUNT(), KEY, LLINK, RLINK, root(), and Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_dup_rec().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup().
|
inlinenoexcept |
Split an extended binary search tree according to a key which can be in the tree.
split_key__dup_rec(root, key, l, r) splits a tree according a key. The key can be in the tree.
| [in,out] | root | pointer to tree root |
| [in] | key | for splitting |
| [out] | l | tree with keys lesser than key |
| [out] | r | tree with keys greater than key |
| anything | that the comparison throws; it compares on the way down and links and counts on the way back, so the tree, l and r are left as they were. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 901 of file tpl_binTreeOps.H.
References Aleph::BinTree_Operation< Node, Cmp >::cmp, Aleph::COUNT(), KEY, l, LLINK, r, RLINK, root(), and Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_dup_rec().
Referenced by Aleph::BinTreeXt_Operation< Node, Cmp >::insert_dup_root(), and Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_dup_rec().
|
inlinenoexcept |
Split an extended binary search tree according to a key.
split_key_rec(root, key, l, r) splits a tree according a non-existing key
| [in,out] | root | pointer to tree root |
| [in] | key | for splitting |
| [out] | l | tree with keys lesser than key |
| [out] | r | 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 | anything | that the comparison throws; it compares on the way down and links and counts on the way back, so the tree, l and r are left as they were. |
noexcept only if the comparison cannot throw, so that what it throws reaches the caller. Definition at line 854 of file tpl_binTreeOps.H.
References Aleph::BinTree_Operation< Node, Cmp >::cmp, Aleph::COUNT(), KEY, l, LLINK, r, RLINK, root(), and Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_rec().
Referenced by Aleph::BinTreeXt_Operation< Node, Cmp >::insert_root(), and Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_rec().