Go to the documentation of this file.
24 #ifndef TSL_HOPSCOTCH_SET_H
25 #define TSL_HOPSCOTCH_SET_H
31 #include <initializer_list>
34 #include <type_traits>
70 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
71 class Allocator = std::allocator<Key>,
unsigned int NeighborhoodSize = 62,
72 bool StoreHash = false,
class GrowthPolicy = tsl::hh::power_of_two_growth_policy<2>>
91 Allocator, NeighborhoodSize, StoreHash,
115 const KeyEqual &equal = KeyEqual(),
const Allocator &alloc = Allocator())
135 template <
class InputIt>
138 const KeyEqual &equal = KeyEqual(),
const Allocator &alloc = Allocator())
144 template <
class InputIt>
150 template <
class InputIt>
152 const Allocator &alloc)
159 const KeyEqual &equal = KeyEqual(),
const Allocator &alloc = Allocator())
165 const Allocator &alloc)
171 const Allocator &alloc)
223 template <
class InputIt>
void insert(InputIt first, InputIt last) {
m_ht.
insert(first, last); }
224 void insert(std::initializer_list<value_type> ilist)
235 template <
class... Args> std::pair<iterator, bool>
emplace(Args &&... args)
263 return m_ht.
erase(key, precalculated_hash);
270 template <
class K,
class KE = KeyEqual,
271 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
284 template <
class K,
class KE = KeyEqual,
285 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
288 return m_ht.
erase(key, precalculated_hash);
305 return m_ht.
count(key, precalculated_hash);
312 template <
class K,
class KE = KeyEqual,
313 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
326 template <
class K,
class KE = KeyEqual,
327 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
330 return m_ht.
count(key, precalculated_hash);
342 return m_ht.
find(key, precalculated_hash);
352 return m_ht.
find(key, precalculated_hash);
359 template <
class K,
class KE = KeyEqual,
360 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
373 template <
class K,
class KE = KeyEqual,
374 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
377 return m_ht.
find(key, precalculated_hash);
383 template <
class K,
class KE = KeyEqual,
384 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
397 template <
class K,
class KE = KeyEqual,
398 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
401 return m_ht.
find(key, precalculated_hash);
411 bool contains(
const Key &key, std::size_t precalculated_hash)
const
420 template <
class K,
class KE = KeyEqual,
421 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
434 template <
class K,
class KE = KeyEqual,
435 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
436 bool contains(
const K &key, std::size_t precalculated_hash)
const
448 std::pair<iterator, iterator>
equal_range(
const Key &key, std::size_t precalculated_hash)
453 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key)
const
461 std::pair<const_iterator, const_iterator>
equal_range(
const Key & key,
462 std::size_t precalculated_hash)
const
471 template <
class K,
class KE = KeyEqual,
472 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
485 template <
class K,
class KE = KeyEqual,
486 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
487 std::pair<iterator, iterator>
equal_range(
const K &key, std::size_t precalculated_hash)
495 template <
class K,
class KE = KeyEqual,
496 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
497 std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const
505 template <
class K,
class KE = KeyEqual,
506 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
507 std::pair<const_iterator, const_iterator>
equal_range(
const K & key,
508 std::size_t precalculated_hash)
const
552 for (
const auto &element_lhs : lhs) {
553 const auto it_element_rhs = rhs.
find(element_lhs);
554 if (it_element_rhs == rhs.
cend()) {
577 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
578 class Allocator = std::allocator<Key>,
unsigned int NeighborhoodSize = 62,
579 bool StoreHash = false>
std::pair< iterator, iterator > equal_range(const K &key)
Definition: hopscotch_hash.h:1087
Definition: hopscotch_set.h:79
float max_load_factor() const
Definition: hopscotch_hash.h:1147
iterator erase(iterator pos)
Definition: hopscotch_set.h:251
Definition: bhopscotch_map.h:37
const_iterator find(const Key &key) const
Definition: hopscotch_set.h:345
hopscotch_set & operator=(std::initializer_list< value_type > ilist)
Definition: hopscotch_set.h:176
void insert(std::initializer_list< value_type > ilist)
Definition: hopscotch_set.h:224
typename ht::const_reference const_reference
Definition: hopscotch_set.h:103
typename ht::difference_type difference_type
Definition: hopscotch_set.h:98
value_type & reference
Definition: hopscotch_hash.h:440
size_type size() const noexcept
Definition: hopscotch_set.h:203
hopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc)
Definition: hopscotch_set.h:164
std::pair< iterator, iterator > equal_range(const Key &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:448
typename ht::hasher hasher
Definition: hopscotch_set.h:99
iterator insert(const_iterator hint, value_type &&value)
Definition: hopscotch_set.h:218
bool contains(const K &key) const
Definition: hopscotch_set.h:422
const_iterator cbegin() const noexcept
Definition: hopscotch_set.h:193
std::pair< iterator, bool > insert(const value_type &value)
Definition: hopscotch_hash.h:786
void clear() noexcept
Definition: hopscotch_hash.h:776
void rehash(size_type count_)
Definition: hopscotch_hash.h:1156
Allocator allocator_type
Definition: hopscotch_hash.h:439
struct anonymous_namespace{Ioss_SmartAssert.C}::assert_initializer init
const key_type & operator()(const Key &key) const
Definition: hopscotch_set.h:84
hopscotch_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: hopscotch_set.h:125
const_iterator end() const noexcept
Definition: hopscotch_set.h:196
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:507
typename ht::reference reference
Definition: hopscotch_set.h:102
size_type overflow_size() const noexcept
Definition: hopscotch_set.h:544
allocator_type get_allocator() const
Definition: hopscotch_hash.h:724
const value_type & const_reference
Definition: hopscotch_hash.h:441
Hash hasher
Definition: hopscotch_hash.h:437
iterator find(const K &key)
Definition: hopscotch_set.h:361
size_type overflow_size() const noexcept
Definition: hopscotch_hash.h:1192
hopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: hopscotch_set.h:170
size_type bucket_count() const
Definition: hopscotch_set.h:516
size_type count(const K &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:328
bool contains(const K &key) const
Definition: hopscotch_hash.h:1080
size_type erase(const key_type &key)
Definition: hopscotch_set.h:254
typename KeySelect::key_type key_type
Definition: hopscotch_hash.h:433
size_type max_size() const noexcept
Definition: hopscotch_set.h:204
const_iterator begin() const noexcept
Definition: hopscotch_set.h:192
size_type max_bucket_count() const
Definition: hopscotch_set.h:517
ht m_ht
Definition: hopscotch_set.h:570
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition: hopscotch_set.h:246
iterator mutable_iterator(const_iterator pos)
Definition: hopscotch_set.h:542
hasher hash_function() const
Definition: hopscotch_hash.h:1170
float load_factor() const
Definition: hopscotch_hash.h:1138
std::pair< iterator, bool > emplace(Args &&... args)
Definition: hopscotch_hash.h:876
iterator insert(const_iterator hint, const value_type &value)
Definition: hopscotch_set.h:214
std::ptrdiff_t difference_type
Definition: hopscotch_hash.h:436
static const size_type DEFAULT_INIT_BUCKETS_SIZE
Definition: hopscotch_hash.h:1763
std::pair< iterator, bool > insert(value_type &&value)
Definition: hopscotch_set.h:212
size_type max_size() const noexcept
Definition: hopscotch_hash.h:771
Key value_type
Definition: hopscotch_hash.h:434
size_type erase(const key_type &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:261
std::pair< iterator, iterator > equal_range(const K &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:487
hopscotch_set(std::initializer_list< value_type > init, size_type bucket_count=ht::DEFAULT_INIT_BUCKETS_SIZE, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
Definition: hopscotch_set.h:157
void max_load_factor(float ml)
Definition: hopscotch_set.h:524
hopscotch_set(const Allocator &alloc)
Definition: hopscotch_set.h:130
iterator end() noexcept
Definition: hopscotch_hash.h:751
size_type size() const noexcept
Definition: hopscotch_hash.h:769
typename ht::const_pointer const_pointer
Definition: hopscotch_set.h:105
typename ht::allocator_type allocator_type
Definition: hopscotch_set.h:101
KeyEqual key_equal
Definition: hopscotch_hash.h:438
void reserve(size_type count_)
Definition: hopscotch_hash.h:1162
std::size_t size_type
Definition: hopscotch_hash.h:435
const_iterator find(const K &key) const
Definition: hopscotch_set.h:385
bool contains(const Key &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:411
std::pair< iterator, bool > insert(const value_type &value)
Definition: hopscotch_set.h:211
hasher hash_function() const
Definition: hopscotch_set.h:532
friend void swap(hopscotch_set &lhs, hopscotch_set &rhs)
Definition: hopscotch_set.h:567
hopscotch_iterator< true > const_iterator
Definition: hopscotch_hash.h:445
iterator begin() noexcept
Definition: hopscotch_hash.h:729
iterator find(const K &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:375
size_type count(const K &key) const
Definition: hopscotch_set.h:314
const_iterator find(const Key &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:350
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const
Definition: hopscotch_set.h:453
iterator find(const Key &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:340
iterator erase(iterator pos)
Definition: hopscotch_hash.h:921
iterator find(const K &key)
Definition: hopscotch_hash.h:1063
Definition: hopscotch_set.h:73
iterator end() noexcept
Definition: hopscotch_set.h:195
std::pair< iterator, iterator > equal_range(const Key &key)
Definition: hopscotch_set.h:441
const value_type * const_pointer
Definition: hopscotch_hash.h:443
iterator erase(const_iterator first, const_iterator last)
Definition: hopscotch_set.h:253
value_type * pointer
Definition: hopscotch_hash.h:442
iterator erase(const_iterator pos)
Definition: hopscotch_set.h:252
size_type count(const Key &key) const
Definition: hopscotch_set.h:296
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition: hopscotch_hash.h:881
const_iterator cbegin() const noexcept
Definition: hopscotch_hash.h:741
key_equal key_eq() const
Definition: hopscotch_hash.h:1172
friend bool operator==(const hopscotch_set &lhs, const hopscotch_set &rhs)
Definition: hopscotch_set.h:546
Definition: hopscotch_hash.h:69
hopscotch_iterator< false > iterator
Definition: hopscotch_hash.h:444
const_iterator find(const K &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:399
size_type erase(const K &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:286
allocator_type get_allocator() const
Definition: hopscotch_set.h:186
void clear() noexcept
Definition: hopscotch_set.h:209
void swap(hopscotch_hash &other)
Definition: hopscotch_hash.h:980
key_type & operator()(Key &key)
Definition: hopscotch_set.h:86
hopscotch_set(size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
Definition: hopscotch_set.h:114
iterator begin() noexcept
Definition: hopscotch_set.h:191
bool empty() const noexcept
Definition: hopscotch_hash.h:767
std::pair< const_iterator, const_iterator > equal_range(const Key &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:461
typename ht::key_type key_type
Definition: hopscotch_set.h:95
Key key_type
Definition: hopscotch_set.h:82
float max_load_factor() const
Definition: hopscotch_set.h:523
size_type count(const K &key) const
Definition: hopscotch_hash.h:1056
friend bool operator!=(const hopscotch_set &lhs, const hopscotch_set &rhs)
Definition: hopscotch_set.h:562
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition: hopscotch_set.h:497
size_type erase(const K &key)
Definition: hopscotch_set.h:272
void reserve(size_type count_)
Definition: hopscotch_set.h:527
bool contains(const K &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:436
const_iterator cend() const noexcept
Definition: hopscotch_set.h:197
hopscotch_set(InputIt first, InputIt last, size_type bucket_count=ht::DEFAULT_INIT_BUCKETS_SIZE, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
Definition: hopscotch_set.h:136
typename ht::iterator iterator
Definition: hopscotch_set.h:106
bool empty() const noexcept
Definition: hopscotch_set.h:202
hopscotch_set()
Definition: hopscotch_set.h:112
key_equal key_eq() const
Definition: hopscotch_set.h:533
size_type count(const Key &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:303
const_iterator cend() const noexcept
Definition: hopscotch_hash.h:758
size_type max_bucket_count() const
Definition: hopscotch_hash.h:1128
iterator find(const Key &key)
Definition: hopscotch_set.h:333
std::list< Key, Allocator > overflow_container_type
Definition: hopscotch_set.h:89
typename ht::const_iterator const_iterator
Definition: hopscotch_set.h:107
float load_factor() const
Definition: hopscotch_set.h:522
std::pair< iterator, bool > emplace(Args &&... args)
Definition: hopscotch_set.h:235
std::pair< iterator, iterator > equal_range(const K &key)
Definition: hopscotch_set.h:473
hopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: hopscotch_set.h:151
void insert(InputIt first, InputIt last)
Definition: hopscotch_set.h:223
typename ht::pointer pointer
Definition: hopscotch_set.h:104
bool contains(const Key &key) const
Definition: hopscotch_set.h:404
typename ht::value_type value_type
Definition: hopscotch_set.h:96
void rehash(size_type count_)
Definition: hopscotch_set.h:526
hopscotch_set(size_type bucket_count, const Allocator &alloc)
Definition: hopscotch_set.h:120
size_type bucket_count() const
Definition: hopscotch_hash.h:1114
iterator mutable_iterator(const_iterator pos)
Definition: hopscotch_hash.h:1177
hopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
Definition: hopscotch_set.h:145
void swap(hopscotch_set &other)
Definition: hopscotch_set.h:291
typename ht::size_type size_type
Definition: hopscotch_set.h:97
Definition: hopscotch_growth_policy.h:250
typename ht::key_equal key_equal
Definition: hopscotch_set.h:100