Phoenix
Object-oriented orthogonally persistent operating system
|
Implementation template for red-black tree class. More...
#include <RBTree.h>
Public Member Functions | |
virtual int | Compare (EntryBase *e1, EntryBase *e2) |
This method should be overloaded in derived class. | |
virtual int | Compare (EntryBase *e, void *key) |
This method should be overloaded in derived class. | |
T * | InsertProbe (T *obj, Entry *e) |
Try to insert an object in the tree. | |
T * | Insert (T *obj, Entry *e) |
Insert an object in the tree. | |
T * | Lookup (key_t &key) |
Lookup object by a key. | |
void | Delete (Entry *e) |
Delete a node by its entry in user object. | |
T * | Delete (key_t &key) |
Delete a node by its key. | |
T * | Lowest () |
Get the object with the lowest value. | |
T * | Highest () |
Get the object with the highest value. |
Implementation template for red-black tree class.
Usage example:
class MyItem { public: int Compare(MyItem &item); int Compare(int key); typedef class RBTree<Item, &MyItem::Compare, int, &MyItem::Compare> MyTree; private: friend class RBTree<MyItem, &MyItem::Compare, int, &MyItem::Compare>; MyTree::Entry _rbEntry; }; MyItem::MyTree tree;
T | Class for objects which are stored in a tree. |
Comparator | method of class T which can be used to compare two objects. It should have the following prototype: int Compare(T &obj); |
key_t | Type for key. |
KeyComparator | Method to compare object with a key value. The method must return positive value if key value is greater than this object value, negative value if it is less, and zero if they are equal. It should have the following prototype: int Compare(key_t &key); |
virtual int RBTree< T, Comparator, key_t, KeyComparator >::Compare | ( | EntryBase * | e1, |
EntryBase * | e2 | ||
) | [inline, virtual] |
This method should be overloaded in derived class.
It must compare two nodes.
e1 | The first node to compare. |
e2 | The second node to compare. |
Implements RBTreeBase.
virtual int RBTree< T, Comparator, key_t, KeyComparator >::Compare | ( | EntryBase * | e, |
void * | key | ||
) | [inline, virtual] |
This method should be overloaded in derived class.
It must compare a node with a key.
e | Node to compare. |
key | Pointer to a key. |
Implements RBTreeBase.
void RBTree< T, Comparator, key_t, KeyComparator >::Delete | ( | Entry * | e | ) | [inline] |
Delete a node by its entry in user object.
e | Tree entry of a node to delete. |
T* RBTree< T, Comparator, key_t, KeyComparator >::Delete | ( | key_t & | key | ) | [inline] |
Delete a node by its key.
key | Key of the node to delete. |
T* RBTree< T, Comparator, key_t, KeyComparator >::Highest | ( | ) | [inline] |
Get the object with the highest value.
Reimplemented from RBTreeBase.
T* RBTree< T, Comparator, key_t, KeyComparator >::Insert | ( | T * | obj, |
Entry * | e | ||
) | [inline] |
Insert an object in the tree.
The object is inserted only if there is no another object with the same key in the tree.
obj | Object to insert. |
e | Pointer to the tree entry. |
T* RBTree< T, Comparator, key_t, KeyComparator >::InsertProbe | ( | T * | obj, |
Entry * | e | ||
) | [inline] |
Try to insert an object in the tree.
The object is inserted only if there is no another object with the same key in the tree.
obj | Object to insert. |
e | Pointer to the tree entry. |
T* RBTree< T, Comparator, key_t, KeyComparator >::Lookup | ( | key_t & | key | ) | [inline] |
Lookup object by a key.
key | Key for lookup. |
T* RBTree< T, Comparator, key_t, KeyComparator >::Lowest | ( | ) | [inline] |
Get the object with the lowest value.
Reimplemented from RBTreeBase.