26#include <CommonIdentifiers.h>
30 template<
typename Value,
typename HashFunctions,
typename Traits>
class HashSet;
31 template<
typename Value,
typename HashFunctions,
typename Traits>
36 template<typename ValueArg, typename HashArg = typename DefaultHash<ValueArg>::Hash,
37 typename TraitsArg = HashTraits<ValueArg> >
class HashSet {
39 typedef HashArg HashFunctions;
40 typedef TraitsArg ValueTraits;
46 typedef HashTable<ValueType, ValueType, IdentityExtractor<ValueType>,
50 typedef HashTableIteratorAdapter<HashTableType, ValueType>
iterator;
51 typedef HashTableConstIteratorAdapter<HashTableType, ValueType> const_iterator;
61 const_iterator
begin()
const;
62 const_iterator
end()
const;
73 template<
typename T,
typename HashTranslator>
iterator find(
const T&);
74 template<
typename T,
typename HashTranslator> const_iterator
find(
const T&)
const;
75 template<
typename T,
typename HashTranslator>
bool contains(
const T&)
const;
87 template<
typename T,
typename HashTranslator> pair<iterator, bool>
add(
const T&);
94 friend void deleteAllValues<>(
const HashSet&);
100 static const T&
extract(
const T& t) {
return t; }
103 template<
typename ValueType,
typename ValueTraits,
typename T,
typename Translator>
105 static unsigned hash(
const T& key) {
return Translator::hash(key); }
106 static bool equal(
const ValueType& a,
const T& b) {
return Translator::equal(a, b); }
107 static void translate(ValueType& location,
const T& key,
const T&,
unsigned hashCode)
109 Translator::translate(location, key, hashCode);
113 template<
typename T,
typename U,
typename V>
116 m_impl.swap(other.m_impl);
119 template<
typename T,
typename U,
typename V>
122 return m_impl.
size();
125 template<
typename T,
typename U,
typename V>
131 template<
typename T,
typename U,
typename V>
137 template<
typename T,
typename U,
typename V>
140 return m_impl.
begin();
143 template<
typename T,
typename U,
typename V>
149 template<
typename T,
typename U,
typename V>
152 return m_impl.
begin();
155 template<
typename T,
typename U,
typename V>
161 template<
typename T,
typename U,
typename V>
164 return m_impl.
find(value);
167 template<
typename T,
typename U,
typename V>
170 return m_impl.
find(value);
173 template<
typename T,
typename U,
typename V>
179 template<
typename Value,
typename HashFunctions,
typename Traits>
180 template<
typename T,
typename Translator>
184 typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, Translator> Adapter;
185 return m_impl.template find<T, Adapter>(value);
188 template<
typename Value,
typename HashFunctions,
typename Traits>
189 template<
typename T,
typename Translator>
190 typename HashSet<Value, HashFunctions, Traits>::const_iterator
193 typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, Translator> Adapter;
194 return m_impl.template find<T, Adapter>(value);
197 template<
typename Value,
typename HashFunctions,
typename Traits>
198 template<
typename T,
typename Translator>
201 typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, Translator> Adapter;
202 return m_impl.template contains<T, Adapter>(value);
205 template<
typename T,
typename U,
typename V>
208 return m_impl.
add(value);
211 template<
typename Value,
typename HashFunctions,
typename Traits>
212 template<
typename T,
typename Translator>
213 pair<typename HashSet<Value, HashFunctions, Traits>::iterator,
bool>
216 typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, Translator> Adapter;
217 return m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
220 template<
typename T,
typename U,
typename V>
223 if (it.m_impl == m_impl.end())
225 m_impl.checkTableConsistency();
226 m_impl.removeWithoutEntryConsistencyCheck(it.m_impl);
229 template<
typename T,
typename U,
typename V>
235 template<
typename T,
typename U,
typename V>
241 template<
typename ValueType,
typename HashTableType>
244 typedef typename HashTableType::const_iterator iterator;
245 iterator end = collection.end();
246 for (iterator it = collection.begin(); it != end; ++it)
250 template<
typename T,
typename U,
typename V>
253 deleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
256 template<
typename T,
typename U,
typename V,
typename W>
257 inline void copyToVector(
const HashSet<T, U, V>& collection, W& vector)
259 typedef typename HashSet<T, U, V>::const_iterator iterator;
261 vector.resize(collection.size());
263 iterator it = collection.begin();
264 iterator end = collection.end();
265 for (
unsigned i = 0; it != end; ++it, ++i)
iterator find(const ValueType &)
void remove(const ValueType &)
ValueTraits::TraitType ValueType
pair< iterator, bool > add(const T &)
pair< iterator, bool > add(const ValueType &)
bool contains(const ValueType &) const
void copyToVector(const HashCountedSet< Value, HashFunctions, Traits > &collection, VectorType &vector)
void deleteAllValues(const HashMap< T, U, V, W, X > &collection)
static bool equal(const ValueType &a, const T &b)
static void translate(ValueType &location, const T &key, const T &, unsigned hashCode)
static unsigned hash(const T &key)