00001 #ifndef MMANN_REDBLACKNODE_H 00002 #define MMANN_REDBLACKNODE_H 00003 00011 00012 #include "AVLRedBlackNode.h" 00013 00018 template <class Data> 00019 class RedBlackNode 00020 { 00021 public: 00022 00024 RedBlackNode(Data* NodeData); 00025 00027 ~RedBlackNode(); 00028 00030 RedBlackNode<Data>* m_Left; 00031 00033 RedBlackNode<Data>* m_Right; 00034 00036 RedBlackNode<Data>* m_Up; 00037 00039 RedBlackNodeColor m_Color; 00040 00042 Data* m_Data; 00043 }; 00044 00045 template <class Data> 00046 RedBlackNode<Data>::RedBlackNode(Data* NodeData) 00047 { 00048 m_Left = m_Right = m_Up = NULL; 00049 m_Color = BLACK; 00050 m_Data = NodeData; 00051 } 00052 00053 template <class Data> 00054 RedBlackNode<Data>::~RedBlackNode() 00055 { 00056 } 00057 00061 template <class Data> 00062 void DeleteAllRedBlackNodes(RedBlackNode<Data>* Node, DeleteTreeDataEnum DeleteTreeData) 00063 { 00064 if (Node->m_Left != NULL) 00065 DeleteAllRedBlackNodes(Node->m_Left, DeleteTreeData); 00066 if (Node->m_Right != NULL) 00067 DeleteAllRedBlackNodes(Node->m_Right, DeleteTreeData); 00068 00069 switch(DeleteTreeData) 00070 { 00071 case NO_DELETE_TREE_ITEM: 00072 break; 00073 case DELETE_TREE_ITEM: 00074 delete Node->m_Data; 00075 break; 00076 case DELETE_TREE_ITEM_ARRAY: 00077 delete [] Node->m_Data; 00078 break; 00079 default: 00080 //This shouldn't happen 00081 assert(false); 00082 } 00083 00084 delete Node; 00085 } 00086 00087 00088 #endif