00001 /* 00002 Free Download Manager Copyright (c) 2003-2007 FreeDownloadManager.ORG 00003 Open Download Manager Copyright (c) 2008-2010 OpenDownloadManager.ORG 00004 */ 00005 00006 #ifndef __FSTREE_H_ 00007 #define __FSTREE_H_ 00008 00009 namespace fs 00010 { 00011 00012 template <class T> 00013 class tree 00014 { 00015 public: 00016 tree () 00017 { 00018 m_pRoot = NULL; 00019 m_pLeft = NULL; 00020 m_pRight = NULL; 00021 } 00022 00023 ~tree () 00024 { 00025 Clear (); 00026 } 00027 00028 void Clear () 00029 { 00030 if (m_pLeft) 00031 delete m_pLeft; 00032 00033 if (m_pRight) 00034 delete m_pRight; 00035 00036 m_pLeft = m_pRight = NULL; 00037 } 00038 00039 void Data (const T& data) 00040 { 00041 m_data = data; 00042 } 00043 00044 T Data () 00045 { 00046 return m_data; 00047 } 00048 00049 void Left (tree* pTree) 00050 { 00051 if (m_pLeft) 00052 delete m_pLeft; 00053 00054 m_pLeft = pTree; 00055 } 00056 00057 tree* Left () const 00058 { 00059 return m_pLeft; 00060 } 00061 00062 void Right (tree* pTree) 00063 { 00064 if (m_pRight) 00065 delete m_pRight; 00066 00067 m_pRight = pTree; 00068 } 00069 00070 tree* Right () const 00071 { 00072 return m_pRight; 00073 } 00074 00075 void Root (tree* pTree) 00076 { 00077 if (m_pRoot) 00078 delete m_pRoot; 00079 00080 m_pRoot = pTree; 00081 } 00082 00083 tree* Root () const 00084 { 00085 return m_pRoot; 00086 } 00087 00088 protected: 00089 tree *m_pRoot; 00090 tree *m_pLeft; 00091 tree *m_pRight; 00092 T m_data; 00093 00094 private: 00095 tree (tree&) {} 00096 tree operator = (tree&) {} 00097 }; 00098 00099 }; 00100 00101 #endif
1.5.6