Util--  1.1
hash_set.hh
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * $Id: hash_set.hh 959 2005-03-11 13:19:19Z fpy $
3  */
4 #ifndef UTILMM_HASH_SET_HEADER
5 # define UTILMM_HASH_SET_HEADER
6 #include "utilmm/config/config.h"
7 
9 
11 
12 namespace utilmm {
13 
28  template< typename Key, class Hash = hash<Key>,
29  class Equal = std::equal_to<Key> >
30  class hash_set {
31  private:
33  typedef hash_toolbox::table< Key, Key const, key_extractor,
34  Hash, Equal > container_type;
35  typedef typename container_type::key_arg key_arg;
36 
37  container_type the_table;
38 
39  public:
57 
62  void swap(hash_set &other) {
63  the_table.swap(other.the_table);
64  }
65 
70  size_t size() const {
71  return the_table.size();
72  }
77  size_t max_size() const {
78  return the_table.max_size();
79  }
80 
85  bool empty() const {
86  return the_table.empty();
87  }
88 
93  iterator begin() {
94  return the_table.begin();
95  }
100  iterator end() {
101  return the_table.end();
102  }
107  const_iterator begin() const {
108  return the_table.begin();
109  }
114  const_iterator end() const {
115  return the_table.end();
116  }
117 
128  iterator find(key_arg key) {
129  return the_table.equal_range(key).first;
130  }
135  const_iterator find(key_arg key) const {
136  return the_table.equal_range(key).first;
137  }
138 
148  iterator insert(key_arg key) {
149  return the_table.insert_unique(key).first;
150  }
151 
156  void erase(iterator const &first, iterator const &last) {
157  the_table.erase(first, last);
158  }
165  void erase(iterator const &i) {
166  if( end()!=i )
167  erase(i, i+1);
168  }
175  void erase(key_arg key) {
176  erase(find(key));
177  }
178 
183  void clear() {
184  the_table.clear();
185  }
186 
187  }; // class utilmm::hash_set<>
188 
189 } // namespace utilmm
190 
191 #endif // UTILMM_HASH_SET_HEADER
192 
const_iterator end() const
end of table
Definition: hash_set.hh:114
size_t size() const
element count
Definition: hash_set.hh:70
container_type::value_type value_type
Value type for cells.
Definition: hash_set.hh:46
size_t max_size() const
max element number
Definition: hash_set.hh:77
std::pair< iterator, iterator > equal_range(key_arg key)
equality range
void swap(table &other)
swapping values function
void erase(iterator const &i)
Remove element.
Definition: hash_set.hh:165
bool empty() const
Emptyness test.
Definition: hash_set.hh:85
size_type max_size() const
max elmement number
void erase(iterator const &first, iterator const &last)
Remove elements.
void erase(key_arg key)
remove element
Definition: hash_set.hh:175
Identity functor.
Definition: utils.hh:24
Hashing based table.
Definition: table.hh:46
container_type::const_iterator const_iterator
const iterator type
Definition: hash_set.hh:56
iterator end()
End of table.
void clear()
Remove all elements.
Definition: hash_set.hh:183
container_type::iterator iterator
iterator type
Definition: hash_set.hh:51
size_type size() const
element count
iterator end()
end of table
Definition: hash_set.hh:100
void clear()
remove all elements
bool empty() const
Emptyness test.
set with hashing access
Definition: hash_set.hh:30
std::pair< iterator, bool > insert_unique(value_arg v)
Unique key insertion.
iterator begin()
Beginning of table.
void swap(hash_set &other)
swapping function
Definition: hash_set.hh:62
iterator begin()
beginning of table
Definition: hash_set.hh:93
Definition: auto_flag.hh:6
const_iterator find(key_arg key) const
Search key.
Definition: hash_set.hh:135
iterator for table
Definition: iter.hh:24
iterator insert(key_arg key)
Cell insertion.
Definition: hash_set.hh:148
const iterator for table
Definition: iter.hh:38
void erase(iterator const &first, iterator const &last)
Remove range.
Definition: hash_set.hh:156
Declaration of utilmm::hash_toolbox::table.
const_iterator begin() const
beginning of table
Definition: hash_set.hh:107
iterator find(key_arg key)
Search for element.
Definition: hash_set.hh:128
Key const value_type
Value type for cells.
Definition: table.hh:49
Som usefull functors.
arg_traits< key_type >::type key_arg
Definition: table.hh:56

Generated on Mon Oct 22 2018 18:39:28 for Util-- by doxygen 1.8.13
SourceForge.net Project Page