14 #ifndef EASTL_HASH_SET_H
15 #define EASTL_HASH_SET_H
18 #include <EASTL/internal/config.h>
19 #include <EASTL/internal/hashtable.h>
20 #include <EASTL/functional.h>
21 #include <EASTL/utility.h>
23 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
36 #ifndef EASTL_HASH_SET_DEFAULT_NAME
37 #define EASTL_HASH_SET_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " hash_set"
45 #ifndef EASTL_HASH_MULTISET_DEFAULT_NAME
46 #define EASTL_HASH_MULTISET_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " hash_multiset"
52 #ifndef EASTL_HASH_SET_DEFAULT_ALLOCATOR
53 #define EASTL_HASH_SET_DEFAULT_ALLOCATOR allocator_type(EASTL_HASH_SET_DEFAULT_NAME)
58 #ifndef EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR
59 #define EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR allocator_type(EASTL_HASH_MULTISET_DEFAULT_NAME)
99 template <
typename Value,
typename Hash = eastl::hash<Value>,
typename Predicate = eastl::equal_to<Value>,
100 typename Allocator = EASTLAllocatorType,
bool bCacheHashCode = false>
102 :
public hashtable<Value, Value, Allocator, eastl::use_self<Value>, Predicate,
103 Hash, mod_range_hashing, default_ranged_hash,
104 prime_rehash_policy, bCacheHashCode, false, true>
111 typedef typename base_type::size_type size_type;
112 typedef typename base_type::value_type value_type;
113 typedef typename base_type::allocator_type allocator_type;
134 explicit hash_set(size_type nBucketCount,
const Hash& hashFunction = Hash(),
const Predicate& predicate = Predicate(),
135 const allocator_type&
allocator = EASTL_HASH_SET_DEFAULT_ALLOCATOR)
154 hash_set(this_type&& x,
const allocator_type& allocator)
166 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_SET_DEFAULT_ALLOCATOR)
178 template <
typename FowardIterator>
179 hash_set(FowardIterator first, FowardIterator last, size_type nBucketCount = 0,
const Hash& hashFunction = Hash(),
180 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_SET_DEFAULT_ALLOCATOR)
187 this_type& operator=(
const this_type& x)
189 return static_cast<this_type&
>(base_type::operator=(x));
195 return static_cast<this_type&
>(base_type::operator=(ilist));
199 this_type& operator=(this_type&& x)
201 return static_cast<this_type&
>(base_type::operator=(
eastl::move(x)));
209 template <
typename Value,
typename Hash,
typename Predicate,
typename Allocator,
bool bCacheHashCode,
typename UserPredicate>
213 for (
auto i = c.begin(), last = c.end(); i != last;)
233 template <
typename Value,
typename Hash = eastl::hash<Value>,
typename Predicate = eastl::equal_to<Value>,
234 typename Allocator = EASTLAllocatorType,
bool bCacheHashCode = false>
236 :
public hashtable<Value, Value, Allocator, eastl::use_self<Value>, Predicate,
237 Hash, mod_range_hashing, default_ranged_hash,
238 prime_rehash_policy, bCacheHashCode, false, false>
245 typedef typename base_type::size_type size_type;
246 typedef typename base_type::value_type value_type;
247 typedef typename base_type::allocator_type allocator_type;
268 explicit hash_multiset(size_type nBucketCount,
const Hash& hashFunction = Hash(),
269 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR)
288 hash_multiset(this_type&& x,
const allocator_type& allocator)
300 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR)
312 template <
typename FowardIterator>
313 hash_multiset(FowardIterator first, FowardIterator last, size_type nBucketCount = 0,
const Hash& hashFunction = Hash(),
314 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR)
321 this_type& operator=(
const this_type& x)
323 return static_cast<this_type&
>(base_type::operator=(x));
329 return static_cast<this_type&
>(base_type::operator=(ilist));
333 this_type& operator=(this_type&& x)
335 return static_cast<this_type&
>(base_type::operator=(
eastl::move(x)));
343 template <
typename Value,
typename Hash,
typename Predicate,
typename Allocator,
bool bCacheHashCode,
typename UserPredicate>
347 for (
auto i = c.begin(), last = c.end(); i != last;)
366 template <
typename Value,
typename Hash,
typename Predicate,
typename Allocator,
bool bCacheHashCode>
367 inline bool operator==(
const hash_set<Value, Hash, Predicate, Allocator, bCacheHashCode>& a,
368 const hash_set<Value, Hash, Predicate, Allocator, bCacheHashCode>& b)
370 typedef typename hash_set<Value, Hash, Predicate, Allocator, bCacheHashCode>::const_iterator const_iterator;
373 if(a.size() != b.size())
378 for(const_iterator ai = a.begin(), aiEnd = a.end(), biEnd = b.end(); ai != aiEnd; ++ai)
380 const_iterator bi = b.find(*ai);
382 if((bi == biEnd) || !(*ai == *bi))
389 template <
typename Value,
typename Hash,
typename Predicate,
typename Allocator,
bool bCacheHashCode>
390 inline bool operator!=(
const hash_set<Value, Hash, Predicate, Allocator, bCacheHashCode>& a,
391 const hash_set<Value, Hash, Predicate, Allocator, bCacheHashCode>& b)
397 template <
typename Value,
typename Hash,
typename Predicate,
typename Allocator,
bool bCacheHashCode>
398 inline bool operator==(
const hash_multiset<Value, Hash, Predicate, Allocator, bCacheHashCode>& a,
399 const hash_multiset<Value, Hash, Predicate, Allocator, bCacheHashCode>& b)
401 typedef typename hash_multiset<Value, Hash, Predicate, Allocator, bCacheHashCode>::const_iterator const_iterator;
402 typedef typename eastl::iterator_traits<const_iterator>::difference_type difference_type;
405 if(a.size() != b.size())
415 for(const_iterator ai = a.begin(), aiEnd = a.end(); ai != aiEnd; ai = aRange.second)
417 aRange = a.equal_range(*ai);
418 bRange = b.equal_range(*ai);
421 const difference_type aDistance = eastl::distance(aRange.first, aRange.second);
422 const difference_type bDistance = eastl::distance(bRange.first, bRange.second);
424 if(aDistance != bDistance)
431 if(!(*aRange.first == *bRange.first))
446 template <
typename Value,
typename Hash,
typename Predicate,
typename Allocator,
bool bCacheHashCode>
447 inline bool operator!=(
const hash_multiset<Value, Hash, Predicate, Allocator, bCacheHashCode>& a,
448 const hash_multiset<Value, Hash, Predicate, Allocator, bCacheHashCode>& b)
Definition: allocator.h:52
Definition: hash_set.h:239
hash_multiset(const allocator_type &allocator=EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR)
Definition: hash_set.h:255
hash_multiset(size_type nBucketCount, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR)
Definition: hash_set.h:268
hash_multiset(FowardIterator first, FowardIterator last, size_type nBucketCount=0, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR)
Definition: hash_set.h:313
hash_multiset(std::initializer_list< value_type > ilist, size_type nBucketCount=0, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_MULTISET_DEFAULT_ALLOCATOR)
Definition: hash_set.h:299
Definition: hash_set.h:105
hash_set(const allocator_type &allocator=EASTL_HASH_SET_DEFAULT_ALLOCATOR)
Definition: hash_set.h:121
hash_set(size_type nBucketCount, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_SET_DEFAULT_ALLOCATOR)
Definition: hash_set.h:134
hash_set(std::initializer_list< value_type > ilist, size_type nBucketCount=0, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_SET_DEFAULT_ALLOCATOR)
Definition: hash_set.h:165
hash_set(FowardIterator first, FowardIterator last, size_type nBucketCount=0, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_SET_DEFAULT_ALLOCATOR)
Definition: hash_set.h:179
Definition: hashtable.h:830
Definition: initializer_list.h:38
EA Standard Template Library.
Definition: algorithm.h:288
OutputIterator move(InputIterator first, InputIterator last, OutputIterator result)
Definition: copy_help.h:170
bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2)
Definition: algorithm.h:3749
Definition: hashtable.h:406
Definition: hashtable.h:107
Definition: hashtable.h:392
Definition: utility.h:371
Definition: hashtable.h:415
Definition: utility.h:580