|
|
| BinTreeXt_Operation (Cmp cmp=Cmp()) noexcept |
| | Initialize the functor with comparison criteria cmp
|
| |
| long | inorder_position (Node *r, const Key &key, Node *&p) noexcept |
| |
| long | find_position (Node *r, const Key &key, Node *&p) noexcept |
| |
| bool | split_key_rec (Node *root, const Key &key, Node *&l, Node *&r) noexcept |
| |
| void | split_key_dup_rec (Node *root, const Key &key, Node *&l, Node *&r) noexcept |
| |
| Node * | insert_root (Node *&root, Node *p) noexcept |
| |
| Node * | insert_dup_root (Node *&root, Node *p) noexcept |
| |
|
Cmp & | key_comp () noexcept |
| | Return the comarison criteria.
|
| |
| Cmp & | get_compare () noexcept |
| |
| Node * | search (Node *root, const Key &key) noexcept |
| |
| Node * | search_parent (Node *root, const Key &key, Node *&parent) noexcept |
| |
| Node * | search_rank_parent (Node *root, const Key &key) noexcept |
| |
| Node * | insert (Node *&root, Node *p) noexcept |
| |
| Node * | insert_dup (Node *&root, Node *p) noexcept |
| |
| Node * | search_or_insert (Node *&r, Node *p) noexcept |
| |
| bool | split_key_rec (Node *&root, const Key &key, Node *&ts, Node *&tg) noexcept |
| |
| Node * | remove (Node *&root, const Key &key) noexcept |
| |
| Node * | join_preorder (Node *t1, Node *t2, Node *&dup) noexcept |
| |
| Node * | join (Node *t1, Node *t2, Node *&dup) noexcept |
| |
| void | split_key (Node *root, const Key &key, Node *&l, Node *&r) noexcept |
| |
| Node * | insert_root_rec (Node *root, Node *p) noexcept |
| |
| Node * | search_or_insert_root_rec (Node *root, Node *p) noexcept |
| |
template<class Node, class Cmp = Aleph::less<typename Node::key_type>>
class Aleph::BinTreeXt_Operation< Node, Cmp >
Functor encompassing basic operation for extended binary search trees.
- See also
- BinNode
template<class Node , class Cmp = Aleph::less<typename Node::key_type>>
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:
- if
key is lesser than the minimum key of tree, then -1 is returned and p is the node with the smallest key.
- If
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.
- For any other case, the returned value is the position that would have
key if this was in the tree and p is the node whose key is inmediataly greater than key.
- Parameters
-
| [in] | r | root of tree |
| [in] | key | to be searched |
| [out] | p | reference to pointer to node |
- Returns
- the positions of
key in the tree
template<class Node , class Cmp = Aleph::less<typename Node::key_type>>
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.
- Parameters
-
| [in,out] | root | of tree |
| [in] | p | pointer to the to insert |
- Returns
- pointer to the isnerted node
p that has became root
template<class Node , class Cmp = Aleph::less<typename Node::key_type>>
Fast union of two binary search trees
join(t1, t2, dup) joins the nodes of t1 with the nodes of t2. The duplicated keys of t2 are copied in the binary search tree dup.
- Parameters
-
| [in] | t1 | root of first tree |
| [in] | t2 | root of second tree |
| [out] | dup | tree where the duplicated keys of t2 are put |
- Returns
- pointer to the root of resulting join
template<class Node , class Cmp = Aleph::less<typename Node::key_type>>
Search or insert a node in a binary search tree.
search_or_insert(root, p) searches in root a node containing p->get_key(). If found, then this node is returned. Otherwise p is inserted and returned.
- Parameters
-
| [in,out] | r | roor of tree |
| [in] | p | node to search or insert |
- Returns
p if its key was not in the tree; otherwise, a pointer containing the tree is returned.
template<class Node , class Cmp = Aleph::less<typename Node::key_type>>
Split a binary search tree according to a key.
split_key(root, key, l, r) splits the tree root according to key. At the end, l contains all the keays lesser than key and r all the keys greater or equal than key.
- Parameters
-
| [in,out] | root | of tree to split |
| [in] | key | for splitting |
| [out] | l | tree with keys lesser than key |
| [out] | r | tree with keys greater or equal than key |
template<class Node , class Cmp = Aleph::less<typename Node::key_type>>
Split an extended binary search tree accoding 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.
- Parameters
-
| [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 |
template<class Node , class Cmp = Aleph::less<typename Node::key_type>>
Split recursively according to a key.
split_key_rec(root, key, ts, tg) splits the tree with root in two trees t1 which contain the keys lesser than key and t2 which contains the keys greater than key.
The split only is performed if key is not in the tree.
- Parameters
-
| [in,out] | root | of tree |
| [in] | key | for slitting |
| [out] | ts | tree with keys lesser than key |
| [out] | tg | tree with keys greater than key |
- Returns
true if the tree wa split; that if key was not in the tree. Otherwise the split is not performed and it return false
template<class Node , class Cmp = Aleph::less<typename Node::key_type>>
Split an extended binary search tree accoding to a key
split_key_rec(root, key, l, r) splits a tree according a non existing key
- Parameters
-
| [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 |
- Returns
true if tree was split; that is if key is not in the tree. Otherwise, if key is in the tree, false is returned