00001 #ifndef MMANN_AVLNODE_H 00002 #define MMANN_AVLNODE_H 00003 00011 00013 template <class Data> 00014 class AVLNode 00015 { 00016 public: 00018 AVLNode(Data* data); 00019 00021 virtual ~AVLNode(); 00022 00024 AVLNode<Data>* m_Left; 00025 00027 AVLNode<Data>* m_Right; 00028 00030 Data* m_Data; 00031 00033 signed char m_Balance; 00034 }; 00035 00036 template <class Data> 00037 AVLNode<Data>::AVLNode(Data* data) 00038 { 00039 m_Left = m_Right = NULL; 00040 m_Balance = 0; 00041 m_Data = data; 00042 } 00043 00044 template<class Data> 00045 AVLNode<Data>::~AVLNode() 00046 { 00047 } 00048 00052 template <class Data> 00053 void DeleteAllAVLNodes(AVLNode<Data>* Node, DeleteTreeDataEnum DeleteTreeData) 00054 { 00055 if (Node->m_Left != NULL) 00056 DeleteAllAVLNodes(Node->m_Left, DeleteTreeData); 00057 if (Node->m_Right != NULL) 00058 DeleteAllAVLNodes(Node->m_Right, DeleteTreeData); 00059 00060 switch(DeleteTreeData) 00061 { 00062 case NO_DELETE_TREE_ITEM: 00063 break; 00064 case DELETE_TREE_ITEM: 00065 delete Node->m_Data; 00066 break; 00067 case DELETE_TREE_ITEM_ARRAY: 00068 delete [] Node->m_Data; 00069 break; 00070 default: 00071 //This shouldn't happen 00072 assert(false); 00073 } 00074 00075 delete Node; 00076 } 00077 00078 #endif