#include <AVLRedBlackTree.h>
Inheritance diagram for AVLRedBlackTree< Data, ConfigData >:
Public Member Functions | |
AVLRedBlackTree (ACompareNodesAlgorithm< Data, ConfigData > *Compare, DeleteTreeDataEnum DeleteTreeData=NO_DELETE_TREE_ITEM, ConfigData *pConfigData=NULL) | |
Constructor. | |
virtual | ~AVLRedBlackTree () |
Destructor. | |
AVLRedBlackTree< Data, ConfigData > * | Copy () |
Make a copy of the tree (creates new nodes). | |
virtual Data * | Search (Data *NodeData, bool *NodeInserted) |
Find a data item. If not found, insert it. | |
virtual Data * | Find (Data *NodeData) |
Find a data item. If not found, return NULL. | |
Data * | Traverse (TraverseNode< Data > *TravNode) |
Walks the tree in inorder, looking for a data item. If not found, return NULL. | |
Data * | FindClose (const Data *NodeData) |
Search tree for a data item close to the value of Item, and return it. | |
Data * | Delete (const Data *NodeData) |
Delete a node from the tree. | |
void | Verify (bool *IsDone) |
Verify the validity of the tree. | |
bool | Compare (AVLRedBlackTree< Data, ConfigData > *Tree) |
Compares two AVLRedBlackTrees. | |
bool | CompareNodes (AVLRedBlackNode< Data > *Node1, AVLRedBlackNode< Data > *Node2) |
Compares two nodes and their children. | |
Private Attributes | |
AVLRedBlackNode< Data > * | m_Root |
Root node of the tree. | |
int | m_Count |
Number of nodes in the tree. |
Basically a red/black balanced tree has the following properties:-*
1) Every node is either red or black (color is RED or BLACK)
2) A leaf (NULL pointer) is considered black
3) If a node is red then its children are black
4) Every path from a node to a leaf contains the same no of black nodes
3) & 4) above guarantee that the longest path (alternating red and black nodes) is only twice as long as the shortest path (all black nodes). Thus the tree remains fairly balanced.
Definition at line 60 of file AVLRedBlackTree.h.
|
going Right; Definition at line 149 of file AVLRedBlackTree.h. References AVLRedBlackNode< Data >::m_Left, AVLRedBlackNode< Data >::m_Right, AVLRedBlackTree< Data, ConfigData >::m_Root, and RB_MAX_HEIGHT. |
|
Definition at line 271 of file AVLRedBlackTree.h. References AVLRedBlackTree< Data, ConfigData >::CompareNodes(), AGenericTree< Data, ConfigData >::m_CompareNodes, AGenericTree< Data, ConfigData >::m_ConfigData, and AVLRedBlackTree< Data, ConfigData >::m_Root. Referenced by AVLRedBlackTree< Data, ConfigData >::CompareNodes(), and TestAVLRedBlackTree(). |
|
Definition at line 769 of file AVLRedBlackTree.h. References AVLRedBlackTree< Data, ConfigData >::Compare(), AVLRedBlackNode< Data >::m_Color, AVLRedBlackNode< Data >::m_Data, AVLRedBlackNode< Data >::m_Left, and AVLRedBlackNode< Data >::m_Right. Referenced by AVLRedBlackTree< Data, ConfigData >::Compare(). |
|
Definition at line 196 of file AVLRedBlackTree.h. References AVLRedBlackNode< Data >::m_Color, AGenericTree< Data, ConfigData >::m_CompareNodes, AGenericTree< Data, ConfigData >::m_ConfigData, AVLRedBlackTree< Data, ConfigData >::m_Count, AVLRedBlackNode< Data >::m_Data, AGenericTree< Data, ConfigData >::m_DeleteTreeData, AVLRedBlackNode< Data >::m_Left, AVLRedBlackNode< Data >::m_Right, AVLRedBlackTree< Data, ConfigData >::m_Root, and RB_MAX_HEIGHT. Referenced by TestAVLRedBlackTree(). |
|
Definition at line 527 of file AVLRedBlackTree.h. References AVLRedBlackNode< Data >::m_Color, AGenericTree< Data, ConfigData >::m_CompareNodes, AGenericTree< Data, ConfigData >::m_ConfigData, AVLRedBlackTree< Data, ConfigData >::m_Count, AVLRedBlackNode< Data >::m_Data, AVLRedBlackNode< Data >::m_Left, AVLRedBlackNode< Data >::m_Right, AVLRedBlackTree< Data, ConfigData >::m_Root, and RB_MAX_HEIGHT. Referenced by TestAVLRedBlackTree(). |
|
Implements AGenericTree< Data, ConfigData >. Definition at line 478 of file AVLRedBlackTree.h. References AGenericTree< Data, ConfigData >::m_CompareNodes, AGenericTree< Data, ConfigData >::m_ConfigData, AVLRedBlackNode< Data >::m_Data, AVLRedBlackNode< Data >::m_Left, AVLRedBlackNode< Data >::m_Right, and AVLRedBlackTree< Data, ConfigData >::m_Root. |
|
Search tree for an item close to the value of Item, and return it. This function will return a null pointer only if tree is empty.
Definition at line 497 of file AVLRedBlackTree.h. References AGenericTree< Data, ConfigData >::m_CompareNodes, AGenericTree< Data, ConfigData >::m_ConfigData, AVLRedBlackNode< Data >::m_Data, AVLRedBlackNode< Data >::m_Left, AVLRedBlackNode< Data >::m_Right, and AVLRedBlackTree< Data, ConfigData >::m_Root. |
|
Implements AGenericTree< Data, ConfigData >. Definition at line 324 of file AVLRedBlackTree.h. References AVLRedBlackNode< Data >::m_Color, AGenericTree< Data, ConfigData >::m_CompareNodes, AGenericTree< Data, ConfigData >::m_ConfigData, AVLRedBlackTree< Data, ConfigData >::m_Count, AVLRedBlackNode< Data >::m_Data, AGenericTree< Data, ConfigData >::m_DeleteTreeData, AVLRedBlackNode< Data >::m_Left, AVLRedBlackNode< Data >::m_Right, AVLRedBlackTree< Data, ConfigData >::m_Root, and RB_MAX_HEIGHT. Referenced by TestAVLRedBlackTree(). |
|
Definition at line 284 of file AVLRedBlackTree.h. References TraverseNode< Data >::m_Initialize, TraverseNode< Data >::m_Node, AVLRedBlackTree< Data, ConfigData >::m_Root, TraverseNode< Data >::m_Stack, and TraverseNode< Data >::m_TopOfStack. |
|
The tree is verified by the number of nodes in the tree matching m_Count
Definition at line 808 of file AVLRedBlackTree.h. References AVLRedBlackTree< Data, ConfigData >::m_Count, AVLRedBlackTree< Data, ConfigData >::m_Root, and RecurseTree(). |