00001 /* 00002 CLAW - a C++ Library Absolutely Wonderful 00003 00004 CLAW is a free library without any particular aim but being useful to 00005 anyone. 00006 00007 Copyright (C) 2005-2008 Julien Jorge 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 contact: julien_jorge@yahoo.fr 00024 */ 00030 #ifndef __CLAW_TREE_HPP__ 00031 #define __CLAW_TREE_HPP__ 00032 00033 #include <list> 00034 00035 namespace claw 00036 { 00041 template<typename T> 00042 class tree 00043 { 00044 public: 00046 typedef T value_type; 00047 00049 typedef tree<T> self_type; 00050 00051 private: 00053 typedef std::list< tree<T> > child_list; 00054 00055 public: 00056 typedef typename child_list::iterator iterator; 00057 typedef typename child_list::const_iterator const_iterator; 00058 00059 public: 00060 tree(); 00061 explicit tree( const T& that ); 00062 00063 bool operator==( const self_type& that ) const; 00064 00065 bool is_leaf() const; 00066 00067 self_type& add_child( const T& v ); 00068 self_type& add_child( const self_type& v ); 00069 00070 iterator find( const T& v ); 00071 const_iterator find( const T& v ) const; 00072 00073 iterator begin(); 00074 iterator end(); 00075 00076 const_iterator begin() const; 00077 const_iterator end() const; 00078 00079 public: 00081 T value; 00082 00083 private: 00085 child_list m_child; 00086 00087 }; // class tree 00088 } // namespace claw 00089 00090 #include <claw/impl/tree.tpp> 00091 00092 #endif // __CLAW_TREE_HPP__