Claw  1.7.3
avl.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_AVL_HPP__
31 #define __CLAW_AVL_HPP__
32 
33 #include <claw/avl_base.hpp>
34 
35 namespace claw
36 {
37  //---------------------------------------------------------------------------
42  template < class K, class Comp = std::less<K> >
43  class avl
44  {
45  private:
48 
49  public:
51  typedef K value_type;
52 
54  typedef K key_type;
55 
57  typedef K referent_type;
58 
60  typedef Comp key_less;
61 
63  typedef const K& const_reference;
64 
66  typedef typename impl_type::avl_const_iterator const_iterator;
67 
68  public:
69  avl();
70  explicit avl( const avl<K, Comp>& that );
71  template<typename InputIterator>
72  avl( InputIterator first, InputIterator last );
73 
74  void insert( const K& key );
75  template<typename InputIterator>
76  void insert( InputIterator first, InputIterator last );
77 
78  void erase( const K& key );
79  void clear();
80 
81  unsigned int size() const;
82  bool empty() const;
83 
84  const_iterator begin() const;
85  const_iterator end() const;
86  const_iterator find( const K& key ) const;
87  const_iterator find_nearest_greater( const K& key ) const;
88  const_iterator find_nearest_lower( const K& key ) const;
91 
92  avl<K, Comp>& operator=( const avl<K, Comp>& that );
93  bool operator==( const avl<K, Comp>& that ) const;
94  bool operator!=( const avl<K, Comp>& that ) const;
95  bool operator<( const avl<K, Comp>& that ) const;
96  bool operator>( const avl<K, Comp>& that ) const;
97  bool operator<=( const avl<K, Comp>& that ) const;
98  bool operator>=( const avl<K, Comp>& that ) const;
99 
100  private:
102  impl_type m_tree;
103 
104  }; // class avl
105 } // namespace claw
106 
107 #include <claw/impl/avl.tpp>
108 
109 #endif // __CLAW_AVL_HPP__