#include <tpl_binTree.H>
Inheritance diagram for Aleph::BinTree< Key, Compare >:
Collaboration diagram for Aleph::BinTree< Key, Compare >:Public Types | |
| using | Base = GenBinTree< BinNode, Key, Compare > |
| using | Node = BinNode< Key > |
Public Member Functions | |
| void | swap (GenBinTree &tree) noexcept |
Swap this with tree in constant time. | |
| Compare & | key_comp () noexcept |
| return the comparison criteria | |
| Compare & | get_compare () noexcept |
| Node * | search (const Key &key) const noexcept |
| bool | verify () const |
Return true if the tree is a consistent (correct) binary search tree. | |
| Node *& | getRoot () |
| Return the root of tree. | |
| bool | verifyBin () const |
| Node * | insert (Node *p) noexcept |
| Node * | insert_dup (Node *p) noexcept |
| Node * | search_or_insert (Node *p) noexcept |
| bool | split (const Key &key, GenBinTree &l, GenBinTree &r) noexcept |
| void | split_dup (const Key &key, GenBinTree &l, GenBinTree &r) noexcept |
| Node * | remove (const Key &key) noexcept |
| void | join (GenBinTree &tree, GenBinTree &dup) noexcept |
| void | join_dup (GenBinTree &t) noexcept |
| void | join_exclusive (GenBinTree &t) noexcept |
Binary search tree with nodes without virtual destructors,
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
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); othewise, nullptr is returned
|
inlinenoexceptinherited |
Insert a node in the tree.
This method does not fail. It always inserts.
| [in] | p | pointer to the node to insert |
p pointer
|
inlinenoexceptinherited |
Join tree with this. Duplicated keys of tree are put in dup parameter.
| [in,out] | tree | to join with this |
| [out] | dup | tree where the duplicated key belonging to tree are put. |
|
inlinenoexceptinherited |
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 | tree to join with this keys are inserted |
|
inlinenoexceptinherited |
Join exclusive of this with t
Exclusive means that all the keys of this are lesser than all the keys of t. This knowlege allows a more effcient 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 | tree to exclusively join with this keys are inserted |
|
inlinenoexceptinherited |
Remove a key from the tree
| [in] | key | to remove |
key was found in the tree, nullptr otherwise
|
inlinenoexceptinherited |
Search a key.
| [in] | key | to be searched |
nullptr
|
inlinenoexceptinherited |
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
|
inlinenoexceptinherited |
Split the tree according to a key
split(key, l, r) splits the tree according to key. That is, if key is not present in the tree, then the tree is split in two trees l which contains the key lesser than key and r which contains the keys greater than key. If key is found in the tree, then the split is not done
| [in] | key | for splitting |
| [out] | l | resulting tree with the keys lesser than key |
| [out] | r | resulting tree with the keys greater than key |
false otherwise
|
inlinenoexceptinherited |
Split the tree according to a key that could be in the tree
split_dup(key, l, r) splits the tree according to key in two trees l which contains the key lesser than key and r which contains the keys greater or equal than key.
| [in] | key | for splitting |
| [out] | l | resulting tree with the keys lesser than key |
| [out] | r | resulting tree with the keys greater or equal than key |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.