c4afa2f97810080d49ce314ba6e583a56bb2e8e5.svn-base (894B)
1 #ifndef BINARY_TREE_H 2 #define BINARY_TREE_H 3 4 #define NULL 0 5 6 class Node 7 { 8 public: 9 10 Node() : mParent(NULL), mLeft(NULL), mRight(NULL), mActive(false) 11 {} 12 13 Node(Node* parent) : mParent(parent), mLeft(NULL), mRight(NULL), mActive(false) 14 {} 15 16 Node(int item, void* data) : mParent(NULL), mActive(false) //Used to create root node 17 { 18 PopulateNode(item, data); 19 } 20 21 bool Insert(int i, void* data); 22 23 Node* Search(int i); 24 25 bool InsertNode(Node* n); 26 27 bool InsertNodeAtRoot(Node* n); 28 29 void Delete(); 30 31 bool DisableTree(); 32 33 bool IsActive() 34 { 35 return mActive; 36 } 37 38 int GetItem() 39 { 40 return mItem; 41 } 42 43 void* GetData() 44 { 45 return mData; 46 } 47 48 Node* mParent; 49 Node* mLeft; 50 Node* mRight; 51 52 protected: 53 54 void PopulateNode(int item, void* data); //Should only be called by inactive nodes 55 56 int mItem; 57 58 void* mData; 59 60 bool mActive; 61 }; 62 63 64 class BinaryTree 65 { 66 public: 67 protected: 68 69 Node mRoot; 70 }; 71 #endif