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 std::pair<iterator, iterator>
equal_range(
const Key &key, std::size_t precalculated_hash)
416 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key)
const 424 std::pair<const_iterator, const_iterator>
equal_range(
const Key & key,
425 std::size_t precalculated_hash)
const 434 template <
class K,
class KE = KeyEqual,
435 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
448 template <
class K,
class KE = KeyEqual,
449 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
450 std::pair<iterator, iterator>
equal_range(
const K &key, std::size_t precalculated_hash)
458 template <
class K,
class KE = KeyEqual,
459 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
460 std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const 468 template <
class K,
class KE = KeyEqual,
469 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
470 std::pair<const_iterator, const_iterator>
equal_range(
const K & key,
471 std::size_t precalculated_hash)
const 515 for (
const auto &element_lhs : lhs) {
516 const auto it_element_rhs = rhs.
find(element_lhs);
517 if (it_element_rhs == rhs.
cend()) {
540 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
541 class Allocator = std::allocator<Key>,
unsigned int NeighborhoodSize = 62,
542 bool StoreHash = false>
hopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc)
Definition: hopscotch_set.h:164
Definition: hopscotch_hash.h:69
void reserve(size_type count_)
Definition: hopscotch_hash.h:1162
std::size_t size_type
Definition: hopscotch_hash.h:445
iterator find(const K &key)
Definition: hopscotch_hash.h:1071
key_equal key_eq() const
Definition: hopscotch_set.h:496
size_type bucket_count() const
Definition: hopscotch_hash.h:1114
const value_type & const_reference
Definition: hopscotch_hash.h:451
typename ht::const_iterator const_iterator
Definition: hopscotch_set.h:107
iterator insert(const_iterator hint, value_type &&value)
Definition: hopscotch_set.h:218
std::pair< iterator, iterator > equal_range(const Key &key)
Definition: hopscotch_set.h:404
typename ht::allocator_type allocator_type
Definition: hopscotch_set.h:101
Allocator allocator_type
Definition: hopscotch_hash.h:449
typename ht::const_pointer const_pointer
Definition: hopscotch_set.h:105
std::pair< iterator, bool > insert(value_type &&value)
Definition: hopscotch_set.h:212
iterator erase(iterator pos)
Definition: hopscotch_set.h:251
std::ptrdiff_t difference_type
Definition: hopscotch_hash.h:446
const_iterator cbegin() const noexcept
Definition: hopscotch_hash.h:749
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
std::pair< iterator, bool > insert(const value_type &value)
Definition: hopscotch_hash.h:793
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
const_iterator find(const K &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:399
hopscotch_set & operator=(std::initializer_list< value_type > ilist)
Definition: hopscotch_set.h:176
static const size_type DEFAULT_INIT_BUCKETS_SIZE
Definition: hopscotch_hash.h:1755
std::pair< iterator, bool > insert(const value_type &value)
Definition: hopscotch_set.h:211
iterator end() noexcept
Definition: hopscotch_hash.h:759
iterator begin() noexcept
Definition: hopscotch_set.h:191
Definition: hopscotch_growth_policy.h:37
const_iterator end() const noexcept
Definition: hopscotch_set.h:196
const_iterator begin() const noexcept
Definition: hopscotch_set.h:192
Key value_type
Definition: hopscotch_hash.h:444
hopscotch_set(size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
Definition: hopscotch_set.h:114
void reserve(size_type count_)
Definition: hopscotch_set.h:490
typename ht::hasher hasher
Definition: hopscotch_set.h:99
iterator end() noexcept
Definition: hopscotch_set.h:195
size_type erase(const K &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:286
iterator insert(const_iterator hint, const value_type &value)
Definition: hopscotch_set.h:214
iterator begin() noexcept
Definition: hopscotch_hash.h:737
typename ht::key_equal key_equal
Definition: hopscotch_set.h:100
hasher hash_function() const
Definition: hopscotch_hash.h:1170
friend bool operator!=(const hopscotch_set &lhs, const hopscotch_set &rhs)
Definition: hopscotch_set.h:525
key_type & operator()(Key &key)
Definition: hopscotch_set.h:86
float max_load_factor() const
Definition: hopscotch_hash.h:1147
bool empty() const noexcept
Definition: hopscotch_set.h:202
iterator find(const K &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:375
iterator find(const K &key)
Definition: hopscotch_set.h:361
void rehash(size_type count_)
Definition: hopscotch_set.h:489
std::pair< iterator, iterator > equal_range(const K &key)
Definition: hopscotch_set.h:436
Key key_type
Definition: hopscotch_set.h:82
Hash hasher
Definition: hopscotch_hash.h:447
hopscotch_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: hopscotch_set.h:125
hasher hash_function() const
Definition: hopscotch_set.h:495
void swap(hopscotch_set &other)
Definition: hopscotch_set.h:291
iterator mutable_iterator(const_iterator pos)
Definition: hopscotch_hash.h:1177
bool empty() const noexcept
Definition: hopscotch_hash.h:774
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition: hopscotch_hash.h:888
hopscotch_iterator< true > const_iterator
Definition: hopscotch_hash.h:455
size_type size() const noexcept
Definition: hopscotch_hash.h:776
hopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: hopscotch_set.h:151
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:470
std::pair< iterator, iterator > equal_range(const K &key)
Definition: hopscotch_hash.h:1088
size_type size() const noexcept
Definition: hopscotch_set.h:203
std::pair< iterator, bool > emplace(Args &&... args)
Definition: hopscotch_set.h:235
friend bool operator==(const hopscotch_set &lhs, const hopscotch_set &rhs)
Definition: hopscotch_set.h:509
typename KeySelect::key_type key_type
Definition: hopscotch_hash.h:443
ht m_ht
Definition: hopscotch_set.h:533
typename ht::value_type value_type
Definition: hopscotch_set.h:96
typename ht::iterator iterator
Definition: hopscotch_set.h:106
float load_factor() const
Definition: hopscotch_set.h:485
typename ht::difference_type difference_type
Definition: hopscotch_set.h:98
size_type count(const K &key) const
Definition: hopscotch_set.h:314
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition: hopscotch_set.h:460
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 count(const Key &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:303
typename ht::reference reference
Definition: hopscotch_set.h:102
std::pair< iterator, bool > emplace(Args &&... args)
Definition: hopscotch_hash.h:883
std::list< Key, Allocator > overflow_container_type
Definition: hopscotch_set.h:89
KeyEqual key_equal
Definition: hopscotch_hash.h:448
std::pair< const_iterator, const_iterator > equal_range(const Key &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:424
void swap(hopscotch_hash &other)
Definition: hopscotch_hash.h:987
size_type bucket_count() const
Definition: hopscotch_set.h:479
hopscotch_set(const Allocator &alloc)
Definition: hopscotch_set.h:130
typename ht::key_type key_type
Definition: hopscotch_set.h:95
const_iterator find(const Key &key) const
Definition: hopscotch_set.h:345
Definition: hopscotch_set.h:79
size_type erase(const key_type &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:261
friend void swap(hopscotch_set &lhs, hopscotch_set &rhs)
Definition: hopscotch_set.h:530
hopscotch_set(size_type bucket_count, const Allocator &alloc)
Definition: hopscotch_set.h:120
typename ht::pointer pointer
Definition: hopscotch_set.h:104
const_iterator find(const Key &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:350
void insert(InputIt first, InputIt last)
Definition: hopscotch_set.h:223
std::pair< iterator, iterator > equal_range(const K &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:450
hopscotch_iterator< false > iterator
Definition: hopscotch_hash.h:454
key_equal key_eq() const
Definition: hopscotch_hash.h:1172
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const
Definition: hopscotch_set.h:416
const key_type & operator()(const Key &key) const
Definition: hopscotch_set.h:84
iterator mutable_iterator(const_iterator pos)
Definition: hopscotch_set.h:505
hopscotch_set()
Definition: hopscotch_set.h:112
hopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
Definition: hopscotch_set.h:145
size_type max_bucket_count() const
Definition: hopscotch_hash.h:1128
Definition: hopscotch_growth_policy.h:250
typename ht::size_type size_type
Definition: hopscotch_set.h:97
size_type count(const K &key) const
Definition: hopscotch_hash.h:1064
size_type erase(const key_type &key)
Definition: hopscotch_set.h:254
value_type & reference
Definition: hopscotch_hash.h:450
size_type erase(const K &key)
Definition: hopscotch_set.h:272
typename ht::const_reference const_reference
Definition: hopscotch_set.h:103
size_type count(const K &key, std::size_t precalculated_hash) const
Definition: hopscotch_set.h:328
size_type max_bucket_count() const
Definition: hopscotch_set.h:480
void clear() noexcept
Definition: hopscotch_set.h:209
struct anonymous_namespace{Ioss_SmartAssert.C}::assert_initializer init
const value_type * const_pointer
Definition: hopscotch_hash.h:453
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition: hopscotch_set.h:246
iterator erase(const_iterator first, const_iterator last)
Definition: hopscotch_set.h:253
const_iterator cbegin() const noexcept
Definition: hopscotch_set.h:193
Definition: hopscotch_set.h:73
float max_load_factor() const
Definition: hopscotch_set.h:486
float load_factor() const
Definition: hopscotch_hash.h:1138
size_type overflow_size() const noexcept
Definition: hopscotch_hash.h:1191
iterator erase(const_iterator pos)
Definition: hopscotch_set.h:252
size_type max_size() const noexcept
Definition: hopscotch_set.h:204
void rehash(size_type count_)
Definition: hopscotch_hash.h:1156
iterator find(const Key &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:340
size_type overflow_size() const noexcept
Definition: hopscotch_set.h:507
iterator find(const Key &key)
Definition: hopscotch_set.h:333
std::pair< iterator, iterator > equal_range(const Key &key, std::size_t precalculated_hash)
Definition: hopscotch_set.h:411
size_type max_size() const noexcept
Definition: hopscotch_hash.h:778
void clear() noexcept
Definition: hopscotch_hash.h:783
const_iterator cend() const noexcept
Definition: hopscotch_hash.h:766
const_iterator cend() const noexcept
Definition: hopscotch_set.h:197
void max_load_factor(float ml)
Definition: hopscotch_set.h:487
size_type count(const Key &key) const
Definition: hopscotch_set.h:296
void insert(std::initializer_list< value_type > ilist)
Definition: hopscotch_set.h:224
allocator_type get_allocator() const
Definition: hopscotch_hash.h:732
iterator erase(iterator pos)
Definition: hopscotch_hash.h:928
const_iterator find(const K &key) const
Definition: hopscotch_set.h:385
value_type * pointer
Definition: hopscotch_hash.h:452
allocator_type get_allocator() const
Definition: hopscotch_set.h:186