Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/avl/Tree.h>
Classes | |
class | Node |
Public Member Functions | |
virtual | ~Tree (void) |
bool | isEmpty (void) |
int | count (void) |
Node * | get (Node *node) |
bool | contains (Node *node) |
void | visit (Visitor *visitor) |
void | search (Visitor *visitor) |
void | insert (Node *node) |
void | remove (Node *node) |
void | clean (void) |
Public Member Functions inherited from BinTree | |
BinTree (void) | |
bool | isEmpty (void) const |
bool | contains (Node *node) |
int | count (void) const |
Node * | root (void) const |
void | setRoot (Node *node) |
void | visit (Visitor *visitor) const |
void | visitPreOrder (Visitor *visitor) const |
void | visitPostOrder (Visitor *visitor) const |
void | search (Visitor *visitor) const |
void | clear (void) |
Protected Member Functions | |
virtual int | compare (Node *node1, Node *node2)=0 |
virtual void | free (Node *node) |
Implementation of the Adelson-Velskii and Landis (AVL) tree algorithm. In order to use this class, you must make a class inheriting this class and overload the compare() protected method. Nodes inserted in the tree must also inherit from the AVLTree::AVLNode class.
This method is called for comparing nodes. It must be overloaded for getting an actual implementation of AVL tree.
node1 | First node to compare. |
node2 | Second node to compare. |
Referenced by Tree::get().
Test if the given node value is contained in the tree.
References Tree::get().
|
inline |
Dump the content of tree. For debugging purpose, only. This method is called for freeing a node in the tree. This method may be overloaded for providing special freeing method. Not overloaded, do nothing.
node | Node to free. |
Tree::Node * get | ( | Node * | node | ) |
Get a tree node equal to the given one.
node | Node to test for equality. |
References Tree::Node::_left(), Tree::Node::_right(), and Tree::compare().
Referenced by Tree::contains().
Test if the tree is empty.
Look for a special node in the given tree.For each node, the process() method of the visitor is called. If it returns 0, search stops. If it returns, <0 traversal continue with left child else with the right child.
visitor | Visitor to use. |
Visit the node of the tree.
visitor | The method process() of this object is called with each tree node. |