Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/inhstruct/SortedBinTree.h>
Public Member Functions | |
virtual | ~SortedBinTree (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 | clear (void) |
Protected Member Functions | |
virtual int | compare (Node *node1, Node *node2)=0 |
Protected 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) |
This class provides a sorted binary tree structure absed on inheritance of its content nodes.
|
inlinevirtual |
Remove all items from the tree.
References BinTree::clear().
This method must be defined by inherited classes for providing a node comparing policy.
node1 | First node is comparison. |
node2 | Second node in comparison. |
Referenced by SortedBinTree::get().
Test if the tree contains the given value.
value | Value to look for. |
Test if the tree contains a node equals to the given one.
node | Node to look for. |
References SortedBinTree::get().
|
inline |
Count the items in the tree.
Count the number of nodes in the tree.
References BinTree::count().
SortedBinTree::Node * get | ( | Node * | node | ) |
Get the item matching the given value.
value | Value to look for. |
Look for the item matching the given value.
value | Value to look for. |
def | Default value to return if the value is not found. |
Get the node from the tree that is equal to the given one.
node | Node to test for. |
References SortedBinTree::compare(), BinTree::Node::left(), BinTree::Node::right(), and BinTree::root().
Referenced by SortedBinTree::contains().
Add the given node to the tree.
node | Node to add. |
References SortedBinTree::isEmpty(), BinTree::root(), and BinTree::setRoot().
Test if the tree is empty.
Test if the tree is empty.
References BinTree::isEmpty().
Referenced by SortedBinTree::insert().
Remove a node equals to the given one from the tree.
node | Node to remove. |
References BinTree::root(), and BinTree::setRoot().
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 in order the nodes of the tree.
visitor | Visitor object to call for each node. |