00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __UT_Tree_h__
00031 #define __UT_Tree_h__
00032
00033 #include <stdlib.h>
00034
00035
00036 template <class T> class UT_Tree
00037 {
00038 public:
00039 UT_Tree()
00040 {
00041 myLeft = NULL;
00042 myRight = NULL;
00043 }
00044 virtual ~UT_Tree()
00045 {
00046 delete myLeft;
00047 delete myRight;
00048 }
00049
00050
00051
00052
00053 void addSibling( UT_Tree<T> *new_sibling )
00054 {
00055 if( myRight == NULL )
00056 myRight = new_sibling;
00057 else
00058 myRight->addSibling( new_sibling );
00059 }
00060 void addChild( UT_Tree<T> *new_child )
00061 {
00062 if( myLeft == NULL )
00063 myLeft = new_child;
00064 else
00065 myLeft->addSibling( new_child );
00066 }
00067 T *getFirstChild() { return (T *)myLeft; }
00068 T *getNextSibling() { return (T *)myRight; }
00069
00070
00071
00072
00073 void setLeft( UT_Tree<T> *new_child ) { myLeft = new_child; }
00074 void setRight( UT_Tree<T> *new_child ) { myRight = new_child; }
00075 T *getLeft() { return (T *)myLeft; }
00076 T *getRight() { return (T *)myRight; }
00077
00078 private:
00079 UT_Tree( const UT_Tree<T> © );
00080 UT_Tree<T> &operator =( const UT_Tree<T> © );
00081
00082 private:
00083 UT_Tree<T> * myLeft;
00084 UT_Tree<T> * myRight;
00085 };
00086
00087
00088 #endif // __UT_Tree_h__