Go to the documentation of this file.
24 #ifndef TSL_BHOPSCOTCH_SET_H
25 #define TSL_BHOPSCOTCH_SET_H
31 #include <initializer_list>
34 #include <type_traits>
53 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
54 class Compare = std::less<Key>,
class Allocator = std::allocator<Key>,
55 unsigned int NeighborhoodSize = 62,
bool StoreHash = false,
56 class GrowthPolicy = tsl::hh::power_of_two_growth_policy<2>>
75 Allocator, NeighborhoodSize, StoreHash,
100 const KeyEqual & equal = KeyEqual(),
101 const Allocator &alloc = Allocator(),
const Compare &comp = Compare())
121 template <
class InputIt>
124 const Hash &hash = Hash(),
const KeyEqual &equal = KeyEqual(),
125 const Allocator &alloc = Allocator())
131 template <
class InputIt>
137 template <
class InputIt>
139 const Allocator &alloc)
146 const Hash &hash = Hash(),
const KeyEqual &equal = KeyEqual(),
147 const Allocator &alloc = Allocator())
153 const Allocator &alloc)
159 const Allocator &alloc)
211 template <
class InputIt>
void insert(InputIt first, InputIt last) {
m_ht.
insert(first, last); }
212 void insert(std::initializer_list<value_type> ilist)
223 template <
class... Args> std::pair<iterator, bool>
emplace(Args &&... args)
251 return m_ht.
erase(key, precalculated_hash);
259 template <
class K,
class KE = KeyEqual,
class CP = Compare,
260 typename std::enable_if<has_is_transparent<KE>::value &&
261 has_is_transparent<CP>::value>::type * =
nullptr>
274 template <
class K,
class KE = KeyEqual,
class CP = Compare,
275 typename std::enable_if<has_is_transparent<KE>::value &&
276 has_is_transparent<CP>::value>::type * =
nullptr>
279 return m_ht.
erase(key, precalculated_hash);
296 return m_ht.
count(key, precalculated_hash);
304 template <
class K,
class KE = KeyEqual,
class CP = Compare,
305 typename std::enable_if<has_is_transparent<KE>::value &&
306 has_is_transparent<CP>::value>::type * =
nullptr>
319 template <
class K,
class KE = KeyEqual,
class CP = Compare,
320 typename std::enable_if<has_is_transparent<KE>::value &&
321 has_is_transparent<CP>::value>::type * =
nullptr>
324 return m_ht.
count(key, precalculated_hash);
336 return m_ht.
find(key, precalculated_hash);
346 return m_ht.
find(key, precalculated_hash);
354 template <
class K,
class KE = KeyEqual,
class CP = Compare,
355 typename std::enable_if<has_is_transparent<KE>::value &&
356 has_is_transparent<CP>::value>::type * =
nullptr>
369 template <
class K,
class KE = KeyEqual,
class CP = Compare,
370 typename std::enable_if<has_is_transparent<KE>::value &&
371 has_is_transparent<CP>::value>::type * =
nullptr>
374 return m_ht.
find(key, precalculated_hash);
380 template <
class K,
class KE = KeyEqual,
class CP = Compare,
381 typename std::enable_if<has_is_transparent<KE>::value &&
382 has_is_transparent<CP>::value>::type * =
nullptr>
395 template <
class K,
class KE = KeyEqual,
class CP = Compare,
396 typename std::enable_if<has_is_transparent<KE>::value &&
397 has_is_transparent<CP>::value>::type * =
nullptr>
400 return m_ht.
find(key, precalculated_hash);
410 bool contains(
const Key &key, std::size_t precalculated_hash)
const
419 template <
class K,
class KE = KeyEqual,
420 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
433 template <
class K,
class KE = KeyEqual,
434 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
435 bool contains(
const K &key, std::size_t precalculated_hash)
const
447 std::pair<iterator, iterator>
equal_range(
const Key &key, std::size_t precalculated_hash)
452 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key)
const
460 std::pair<const_iterator, const_iterator>
equal_range(
const Key & key,
461 std::size_t precalculated_hash)
const
471 template <
class K,
class KE = KeyEqual,
class CP = Compare,
472 typename std::enable_if<has_is_transparent<KE>::value &&
473 has_is_transparent<CP>::value>::type * =
nullptr>
486 template <
class K,
class KE = KeyEqual,
class CP = Compare,
487 typename std::enable_if<has_is_transparent<KE>::value &&
488 has_is_transparent<CP>::value>::type * =
nullptr>
489 std::pair<iterator, iterator>
equal_range(
const K &key, std::size_t precalculated_hash)
497 template <
class K,
class KE = KeyEqual,
class CP = Compare,
498 typename std::enable_if<has_is_transparent<KE>::value &&
499 has_is_transparent<CP>::value>::type * =
nullptr>
500 std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const
508 template <
class K,
class KE = KeyEqual,
class CP = Compare,
509 typename std::enable_if<has_is_transparent<KE>::value &&
510 has_is_transparent<CP>::value>::type * =
nullptr>
511 std::pair<const_iterator, const_iterator>
equal_range(
const K & key,
512 std::size_t precalculated_hash)
const
557 for (
const auto &element_lhs : lhs) {
558 const auto it_element_rhs = rhs.
find(element_lhs);
559 if (it_element_rhs == rhs.
cend()) {
582 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
583 class Compare = std::less<Key>,
class Allocator = std::allocator<Key>,
584 unsigned int NeighborhoodSize = 62,
bool StoreHash = false>
586 bhopscotch_set<Key, Hash, KeyEqual, Compare, Allocator, NeighborhoodSize, StoreHash,
std::pair< iterator, iterator > equal_range(const K &key)
Definition: hopscotch_hash.h:1087
float max_load_factor() const
Definition: hopscotch_hash.h:1147
Definition: bhopscotch_map.h:37
iterator erase(const_iterator first, const_iterator last)
Definition: bhopscotch_set.h:241
float max_load_factor() const
Definition: bhopscotch_set.h:527
bhopscotch_set & operator=(std::initializer_list< value_type > ilist)
Definition: bhopscotch_set.h:164
size_type overflow_size() const noexcept
Definition: bhopscotch_set.h:549
std::set< Key, Compare, Allocator > overflow_container_type
Definition: bhopscotch_set.h:73
bhopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
Definition: bhopscotch_set.h:132
bhopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: bhopscotch_set.h:158
void rehash(size_type count_)
Definition: bhopscotch_set.h:530
value_type & reference
Definition: hopscotch_hash.h:440
Key key_type
Definition: bhopscotch_set.h:66
void max_load_factor(float ml)
Definition: bhopscotch_set.h:528
bool empty() const noexcept
Definition: bhopscotch_set.h:190
size_type count(const K &key) const
Definition: bhopscotch_set.h:307
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
typename ht::size_type size_type
Definition: bhopscotch_set.h:81
std::pair< iterator, bool > insert(const value_type &value)
Definition: bhopscotch_set.h:199
iterator find(const K &key)
Definition: bhopscotch_set.h:357
bool contains(const K &key) const
Definition: bhopscotch_set.h:421
std::pair< iterator, iterator > equal_range(const Key &key, std::size_t precalculated_hash)
Definition: bhopscotch_set.h:447
allocator_type get_allocator() const
Definition: hopscotch_hash.h:724
bhopscotch_set(size_type bucket_count, const Allocator &alloc)
Definition: bhopscotch_set.h:106
const value_type & const_reference
Definition: hopscotch_hash.h:441
Hash hasher
Definition: hopscotch_hash.h:437
size_type erase(const K &key)
Definition: bhopscotch_set.h:262
size_type overflow_size() const noexcept
Definition: hopscotch_hash.h:1192
bool contains(const K &key) const
Definition: hopscotch_hash.h:1080
bool contains(const Key &key) const
Definition: bhopscotch_set.h:403
typename KeySelect::key_type key_type
Definition: hopscotch_hash.h:433
bhopscotch_set()
Definition: bhopscotch_set.h:97
bhopscotch_set(size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator(), const Compare &comp=Compare())
Definition: bhopscotch_set.h:99
hasher hash_function() const
Definition: hopscotch_hash.h:1170
float load_factor() const
Definition: hopscotch_hash.h:1138
key_compare key_comp() const
Definition: bhopscotch_set.h:538
std::pair< iterator, bool > emplace(Args &&... args)
Definition: hopscotch_hash.h:876
std::ptrdiff_t difference_type
Definition: hopscotch_hash.h:436
static const size_type DEFAULT_INIT_BUCKETS_SIZE
Definition: hopscotch_hash.h:1763
float load_factor() const
Definition: bhopscotch_set.h:526
size_type erase(const key_type &key)
Definition: bhopscotch_set.h:242
typename ht::const_iterator const_iterator
Definition: bhopscotch_set.h:92
typename ht::const_pointer const_pointer
Definition: bhopscotch_set.h:90
U::key_compare key_comp() const
Definition: hopscotch_hash.h:1196
iterator find(const Key &key)
Definition: bhopscotch_set.h:327
size_type max_size() const noexcept
Definition: hopscotch_hash.h:771
const_iterator cend() const noexcept
Definition: bhopscotch_set.h:185
Key value_type
Definition: hopscotch_hash.h:434
Definition: bhopscotch_set.h:57
bhopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: bhopscotch_set.h:138
iterator end() noexcept
Definition: hopscotch_hash.h:751
size_type size() const noexcept
Definition: hopscotch_hash.h:769
std::pair< iterator, iterator > equal_range(const Key &key)
Definition: bhopscotch_set.h:440
KeyEqual key_equal
Definition: hopscotch_hash.h:438
hasher hash_function() const
Definition: bhopscotch_set.h:536
void clear() noexcept
Definition: bhopscotch_set.h:197
void reserve(size_type count_)
Definition: hopscotch_hash.h:1162
iterator begin() noexcept
Definition: bhopscotch_set.h:179
std::size_t size_type
Definition: hopscotch_hash.h:435
std::pair< iterator, bool > insert(value_type &&value)
Definition: bhopscotch_set.h:200
size_type max_size() const noexcept
Definition: bhopscotch_set.h:192
std::pair< const_iterator, const_iterator > equal_range(const Key &key, std::size_t precalculated_hash) const
Definition: bhopscotch_set.h:460
Definition: bhopscotch_set.h:63
key_type & operator()(Key &key)
Definition: bhopscotch_set.h:70
hopscotch_iterator< true > const_iterator
Definition: hopscotch_hash.h:445
bhopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc)
Definition: bhopscotch_set.h:152
iterator begin() noexcept
Definition: hopscotch_hash.h:729
size_type count(const Key &key) const
Definition: bhopscotch_set.h:287
iterator erase(const_iterator pos)
Definition: bhopscotch_set.h:240
typename ht::const_reference const_reference
Definition: bhopscotch_set.h:88
bhopscotch_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition: bhopscotch_set.h:111
void insert(std::initializer_list< value_type > ilist)
Definition: bhopscotch_set.h:212
iterator erase(iterator pos)
Definition: hopscotch_hash.h:921
bool contains(const Key &key, std::size_t precalculated_hash) const
Definition: bhopscotch_set.h:410
iterator find(const Key &key, std::size_t precalculated_hash)
Definition: bhopscotch_set.h:334
iterator find(const K &key)
Definition: hopscotch_hash.h:1063
friend void swap(bhopscotch_set &lhs, bhopscotch_set &rhs)
Definition: bhopscotch_set.h:572
const_iterator end() const noexcept
Definition: bhopscotch_set.h:184
Compare key_compare
Definition: bhopscotch_set.h:85
const value_type * const_pointer
Definition: hopscotch_hash.h:443
value_type * pointer
Definition: hopscotch_hash.h:442
size_type size() const noexcept
Definition: bhopscotch_set.h:191
const_iterator find(const K &key, std::size_t precalculated_hash) const
Definition: bhopscotch_set.h:398
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition: hopscotch_hash.h:881
const_iterator cbegin() const noexcept
Definition: hopscotch_hash.h:741
iterator end() noexcept
Definition: bhopscotch_set.h:183
key_equal key_eq() const
Definition: bhopscotch_set.h:537
key_equal key_eq() const
Definition: hopscotch_hash.h:1172
bool contains(const K &key, std::size_t precalculated_hash) const
Definition: bhopscotch_set.h:435
allocator_type get_allocator() const
Definition: bhopscotch_set.h:174
const_iterator find(const Key &key) const
Definition: bhopscotch_set.h:339
Definition: hopscotch_hash.h:69
hopscotch_iterator< false > iterator
Definition: hopscotch_hash.h:444
typename ht::allocator_type allocator_type
Definition: bhopscotch_set.h:86
iterator find(const K &key, std::size_t precalculated_hash)
Definition: bhopscotch_set.h:372
ht m_ht
Definition: bhopscotch_set.h:575
size_type bucket_count() const
Definition: bhopscotch_set.h:520
const key_type & operator()(const Key &key) const
Definition: bhopscotch_set.h:68
bhopscotch_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: bhopscotch_set.h:144
typename ht::iterator iterator
Definition: bhopscotch_set.h:91
void swap(hopscotch_hash &other)
Definition: hopscotch_hash.h:980
size_type count(const Key &key, std::size_t precalculated_hash) const
Definition: bhopscotch_set.h:294
bhopscotch_set(const Allocator &alloc)
Definition: bhopscotch_set.h:116
const_iterator find(const Key &key, std::size_t precalculated_hash) const
Definition: bhopscotch_set.h:344
bool empty() const noexcept
Definition: hopscotch_hash.h:767
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const
Definition: bhopscotch_set.h:452
size_type count(const K &key) const
Definition: hopscotch_hash.h:1056
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition: bhopscotch_set.h:500
std::pair< iterator, bool > emplace(Args &&... args)
Definition: bhopscotch_set.h:223
size_type erase(const key_type &key, std::size_t precalculated_hash)
Definition: bhopscotch_set.h:249
size_type erase(const K &key, std::size_t precalculated_hash)
Definition: bhopscotch_set.h:277
size_type count(const K &key, std::size_t precalculated_hash) const
Definition: bhopscotch_set.h:322
typename ht::hasher hasher
Definition: bhopscotch_set.h:83
friend bool operator==(const bhopscotch_set &lhs, const bhopscotch_set &rhs)
Definition: bhopscotch_set.h:551
const_iterator cend() const noexcept
Definition: hopscotch_hash.h:758
size_type max_bucket_count() const
Definition: hopscotch_hash.h:1128
size_type max_bucket_count() const
Definition: bhopscotch_set.h:521
const_iterator cbegin() const noexcept
Definition: bhopscotch_set.h:181
iterator insert(const_iterator hint, value_type &&value)
Definition: bhopscotch_set.h:206
typename ht::pointer pointer
Definition: bhopscotch_set.h:89
typename ht::value_type value_type
Definition: bhopscotch_set.h:80
friend bool operator!=(const bhopscotch_set &lhs, const bhopscotch_set &rhs)
Definition: bhopscotch_set.h:567
const_iterator begin() const noexcept
Definition: bhopscotch_set.h:180
typename ht::key_type key_type
Definition: bhopscotch_set.h:79
iterator erase(iterator pos)
Definition: bhopscotch_set.h:239
std::pair< iterator, iterator > equal_range(const K &key)
Definition: bhopscotch_set.h:474
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t precalculated_hash) const
Definition: bhopscotch_set.h:511
typename ht::key_equal key_equal
Definition: bhopscotch_set.h:84
void insert(InputIt first, InputIt last)
Definition: bhopscotch_set.h:211
bhopscotch_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: bhopscotch_set.h:122
std::pair< iterator, iterator > equal_range(const K &key, std::size_t precalculated_hash)
Definition: bhopscotch_set.h:489
void reserve(size_type count_)
Definition: bhopscotch_set.h:531
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition: bhopscotch_set.h:234
const_iterator find(const K &key) const
Definition: bhopscotch_set.h:383
typename ht::difference_type difference_type
Definition: bhopscotch_set.h:82
size_type bucket_count() const
Definition: hopscotch_hash.h:1114
iterator mutable_iterator(const_iterator pos)
Definition: hopscotch_hash.h:1177
iterator insert(const_iterator hint, const value_type &value)
Definition: bhopscotch_set.h:202
typename ht::reference reference
Definition: bhopscotch_set.h:87
void swap(bhopscotch_set &other)
Definition: bhopscotch_set.h:282
iterator mutable_iterator(const_iterator pos)
Definition: bhopscotch_set.h:547
Definition: hopscotch_growth_policy.h:250