00001 #ifndef MMANN_AVLREDBLACKNODE_H 00002 #define MMANN_AVLREDBLACKNODE_H 00003 00011 00012 #include <assert.h> 00013 #include "AGenericTree.h" 00014 00016 enum RedBlackNodeColor {BLACK, RED}; 00017 00022 template <class Data> 00023 class AVLRedBlackNode 00024 { 00025 public: 00027 AVLRedBlackNode(DeleteTreeDataEnum DeleteTreeData); 00028 00030 virtual ~AVLRedBlackNode(); 00031 00033 AVLRedBlackNode<Data>* m_Left; 00034 00036 AVLRedBlackNode<Data>* m_Right; 00037 00039 RedBlackNodeColor m_Color; 00040 00042 Data* m_Data; 00043 00045 DeleteTreeDataEnum m_DeleteTreeData; 00046 }; 00047 00048 00049 template <class Data> 00050 AVLRedBlackNode<Data>::AVLRedBlackNode(DeleteTreeDataEnum DeleteTreeData) 00051 { 00052 m_Left = m_Right = NULL; 00053 m_Color = BLACK; 00054 m_Data = NULL; 00055 m_DeleteTreeData = DeleteTreeData; 00056 } 00057 00058 template <class Data> 00059 AVLRedBlackNode<Data>::~AVLRedBlackNode() 00060 { 00061 switch(m_DeleteTreeData) 00062 { 00063 case NO_DELETE_TREE_ITEM: 00064 break; 00065 case DELETE_TREE_ITEM: 00066 delete m_Data; 00067 break; 00068 case DELETE_TREE_ITEM_ARRAY: 00069 delete [] m_Data; 00070 break; 00071 default: 00072 //This shouldn't happen 00073 assert(false); 00074 } 00075 } 00076 00077 #endif