Balanced binary tree (AVL tree).
In general, operators '>' and '==' must be overloaded fot type T. See method descriptions for details.
| template <class C> Node* |
Add a node to the tree. | |||
| template <class C> Node* |
Add a node to the tree without actual node's
value assignment. | |||
| void |
Remove a node from the tree. | |||
| void |
Clear the tree (i.e., delete all nodes from the tree). | |||
| template <class C> Node* |
Find a node with the specified key value by
unconditional traversal of the whole tree. | |||
| template <class C> Node* |
Find a node with the specified key value by
unconditional traversal of the whole tree. |
Add a node to the tree.
Operator '>' must be overloaded for comparison between types T and C.
The value passed to this method will be assigned to the value field of the Node structure using the appropriate conversion constructor for type T.
template <class C> Node* add (C value)
| value : | The value that will be associated with the new node. |
Add a node to the tree without actual node's value assignment.
Operator '>' must be overloaded for comparison between types T and C.
This method acts just like the add method, except that it does not assign the passed value to the newly created Node structure, and thus the copying/conversion constructor is not called.
This method is useful, if the value of type C is actually the key for this AVL tree, but there is no appropriate conversion constructor for type T.
template <class C> Node* addFor (C value)
| value : | The value that will be associated with the new node. |
Clear the tree (i.e., delete all nodes from the tree).
void clear ()
Find a node with the specified key value by unconditional traversal of the whole tree.
Operators '==' and '>' must be overloaded for comparison between types T and C.
If there is no node with the key value requested, then NULL will be returned.
template <class C> Node* lookup (C c)
| c : | The key value of the node to find. |
Find a node with the specified key value by unconditional traversal of the whole tree.
This is an ineffective (O(N) complexity) way of searching for a node in the tree.
Operator '==' must be overloaded for comparison between types T and C.
If there is no node with the key value requested, then NULL will be returned.
template <class C> Node* lookupByTraversal (C c)
| c : | The key value of the node to find. |