Claw  1.7.3
tree.hpp
Go to the documentation of this file.
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23  contact: julien.jorge@gamned.org
24 */
30 #ifndef __CLAW_TREE_HPP__
31 #define __CLAW_TREE_HPP__
32 
33 #include <list>
34 
35 namespace claw
36 {
41  template<typename T>
42  class tree
43  {
44  public:
46  typedef T value_type;
47 
49  typedef tree<T> self_type;
50 
51  private:
53  typedef std::list< tree<T> > child_list;
54 
55  public:
56  typedef typename child_list::iterator iterator;
57  typedef typename child_list::const_iterator const_iterator;
58 
59  public:
60  tree();
61  explicit tree( const T& that );
62 
63  bool operator==( const self_type& that ) const;
64 
65  bool is_leaf() const;
66 
67  self_type& add_child( const T& v );
68  self_type& add_child( const self_type& v );
69 
70  iterator find( const T& v );
71  const_iterator find( const T& v ) const;
72 
73  iterator begin();
74  iterator end();
75 
76  const_iterator begin() const;
77  const_iterator end() const;
78 
79  public:
81  T value;
82 
83  private:
85  child_list m_child;
86 
87  }; // class tree
88 } // namespace claw
89 
90 #include <claw/impl/tree.tpp>
91 
92 #endif // __CLAW_TREE_HPP__