24#ifndef TSL_BHOPSCOTCH_SET_H
25#define TSL_BHOPSCOTCH_SET_H
30#include <initializer_list>
56 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
57 class Compare = std::less<Key>,
class Allocator = std::allocator<Key>,
58 unsigned int NeighborhoodSize = 62,
bool StoreHash = false,
59 class GrowthPolicy = tsl::hh::power_of_two_growth_policy<2>>
78 Allocator, NeighborhoodSize, StoreHash,
103 const KeyEqual &equal = KeyEqual(),
104 const Allocator &alloc = Allocator(),
const Compare &comp = Compare())
124 template <
class InputIt>
127 const Hash &hash = Hash(),
const KeyEqual &equal = KeyEqual(),
128 const Allocator &alloc = Allocator())
134 template <
class InputIt>
140 template <
class InputIt>
142 const Allocator &alloc)
149 const Hash &hash = Hash(),
const KeyEqual &equal = KeyEqual(),
150 const Allocator &alloc = Allocator())
156 const Allocator &alloc)
162 const Allocator &alloc)
214 template <
class InputIt>
void insert(InputIt first, InputIt last) {
m_ht.
insert(first, last); }
215 void insert(std::initializer_list<value_type> ilist)
227 template <
class... Args> std::pair<iterator, bool>
emplace(Args &&...args)
256 return m_ht.
erase(key, precalculated_hash);
264 template <
class K,
class KE = KeyEqual,
class CP = Compare,
265 typename std::enable_if<has_is_transparent<KE>::value &&
266 has_is_transparent<CP>::value>::type * =
nullptr>
279 template <
class K,
class KE = KeyEqual,
class CP = Compare,
280 typename std::enable_if<has_is_transparent<KE>::value &&
281 has_is_transparent<CP>::value>::type * =
nullptr>
284 return m_ht.
erase(key, precalculated_hash);
301 return m_ht.
count(key, precalculated_hash);
309 template <
class K,
class KE = KeyEqual,
class CP = Compare,
310 typename std::enable_if<has_is_transparent<KE>::value &&
311 has_is_transparent<CP>::value>::type * =
nullptr>
324 template <
class K,
class KE = KeyEqual,
class CP = Compare,
325 typename std::enable_if<has_is_transparent<KE>::value &&
326 has_is_transparent<CP>::value>::type * =
nullptr>
329 return m_ht.
count(key, precalculated_hash);
341 return m_ht.
find(key, precalculated_hash);
351 return m_ht.
find(key, precalculated_hash);
359 template <
class K,
class KE = KeyEqual,
class CP = Compare,
360 typename std::enable_if<has_is_transparent<KE>::value &&
361 has_is_transparent<CP>::value>::type * =
nullptr>
374 template <
class K,
class KE = KeyEqual,
class CP = Compare,
375 typename std::enable_if<has_is_transparent<KE>::value &&
376 has_is_transparent<CP>::value>::type * =
nullptr>
379 return m_ht.
find(key, precalculated_hash);
385 template <
class K,
class KE = KeyEqual,
class CP = Compare,
386 typename std::enable_if<has_is_transparent<KE>::value &&
387 has_is_transparent<CP>::value>::type * =
nullptr>
400 template <
class K,
class KE = KeyEqual,
class CP = Compare,
401 typename std::enable_if<has_is_transparent<KE>::value &&
402 has_is_transparent<CP>::value>::type * =
nullptr>
405 return m_ht.
find(key, precalculated_hash);
415 bool contains(
const Key &key, std::size_t precalculated_hash)
const
425 template <
class K,
class KE = KeyEqual,
426 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
439 template <
class K,
class KE = KeyEqual,
440 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
441 bool contains(
const K &key, std::size_t precalculated_hash)
const
453 std::pair<iterator, iterator>
equal_range(
const Key &key, std::size_t precalculated_hash)
458 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key)
const
466 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key,
467 std::size_t precalculated_hash)
const
477 template <
class K,
class KE = KeyEqual,
class CP = Compare,
478 typename std::enable_if<has_is_transparent<KE>::value &&
479 has_is_transparent<CP>::value>::type * =
nullptr>
492 template <
class K,
class KE = KeyEqual,
class CP = Compare,
493 typename std::enable_if<has_is_transparent<KE>::value &&
494 has_is_transparent<CP>::value>::type * =
nullptr>
495 std::pair<iterator, iterator>
equal_range(
const K &key, std::size_t precalculated_hash)
503 template <
class K,
class KE = KeyEqual,
class CP = Compare,
504 typename std::enable_if<has_is_transparent<KE>::value &&
505 has_is_transparent<CP>::value>::type * =
nullptr>
506 std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const
514 template <
class K,
class KE = KeyEqual,
class CP = Compare,
515 typename std::enable_if<has_is_transparent<KE>::value &&
516 has_is_transparent<CP>::value>::type * =
nullptr>
517 std::pair<const_iterator, const_iterator>
equal_range(
const K &key,
518 std::size_t precalculated_hash)
const
563 for (
const auto &element_lhs : lhs) {
564 const auto it_element_rhs = rhs.
find(element_lhs);
565 if (it_element_rhs == rhs.
cend()) {
588 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
589 class Compare = std::less<Key>,
class Allocator = std::allocator<Key>,
590 unsigned int NeighborhoodSize = 62,
bool StoreHash = false>
592 bhopscotch_set<Key, Hash, KeyEqual, Compare, Allocator, NeighborhoodSize, StoreHash,
Definition bhopscotch_set.h:67
Key key_type
Definition bhopscotch_set.h:69
key_type & operator()(Key &key)
Definition bhopscotch_set.h:73
const key_type & operator()(const Key &key) const
Definition bhopscotch_set.h:71
Definition bhopscotch_set.h:61
iterator mutable_iterator(const_iterator pos)
Definition bhopscotch_set.h:553
const_iterator find(const K &key, std::size_t precalculated_hash) const
Definition bhopscotch_set.h:403
size_type count(const Key &key) const
Definition bhopscotch_set.h:292
bhopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
Definition bhopscotch_set.h:135
bhopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition bhopscotch_set.h:161
size_type count(const K &key) const
Definition bhopscotch_set.h:312
bool contains(const Key &key) const
Definition bhopscotch_set.h:408
void rehash(size_type count_)
Definition bhopscotch_set.h:536
typename ht::reference reference
Definition bhopscotch_set.h:90
iterator find(const Key &key)
Definition bhopscotch_set.h:332
std::pair< iterator, bool > insert(const value_type &value)
Definition bhopscotch_set.h:202
size_type max_size() const noexcept
Definition bhopscotch_set.h:195
iterator erase(const_iterator first, const_iterator last)
Definition bhopscotch_set.h:246
size_type overflow_size() const noexcept
Definition bhopscotch_set.h:555
ht m_ht
Definition bhopscotch_set.h:581
size_type max_bucket_count() const
Definition bhopscotch_set.h:527
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition bhopscotch_set.h:506
std::pair< const_iterator, const_iterator > equal_range(const Key &key, std::size_t precalculated_hash) const
Definition bhopscotch_set.h:466
std::pair< iterator, bool > insert(value_type &&value)
Definition bhopscotch_set.h:203
size_type erase(const K &key, std::size_t precalculated_hash)
Definition bhopscotch_set.h:282
size_type erase(const K &key)
Definition bhopscotch_set.h:267
const_iterator cend() const noexcept
Definition bhopscotch_set.h:188
std::pair< iterator, iterator > equal_range(const Key &key)
Definition bhopscotch_set.h:446
typename ht::key_type key_type
Definition bhopscotch_set.h:82
iterator find(const K &key, std::size_t precalculated_hash)
Definition bhopscotch_set.h:377
size_type bucket_count() const
Definition bhopscotch_set.h:526
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const
Definition bhopscotch_set.h:458
bhopscotch_set & operator=(std::initializer_list< value_type > ilist)
Definition bhopscotch_set.h:167
typename ht::pointer pointer
Definition bhopscotch_set.h:92
allocator_type get_allocator() const
Definition bhopscotch_set.h:177
void swap(bhopscotch_set &other)
Definition bhopscotch_set.h:287
bhopscotch_set(size_type bucket_count, const Allocator &alloc)
Definition bhopscotch_set.h:109
std::set< Key, Compare, Allocator > overflow_container_type
Definition bhopscotch_set.h:76
friend bool operator==(const bhopscotch_set &lhs, const bhopscotch_set &rhs)
Definition bhopscotch_set.h:557
typename ht::allocator_type allocator_type
Definition bhopscotch_set.h:89
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:102
typename ht::value_type value_type
Definition bhopscotch_set.h:83
const_iterator begin() const noexcept
Definition bhopscotch_set.h:183
size_type erase(const key_type &key, std::size_t precalculated_hash)
Definition bhopscotch_set.h:254
bool contains(const K &key, std::size_t precalculated_hash) const
Definition bhopscotch_set.h:441
size_type count(const Key &key, std::size_t precalculated_hash) const
Definition bhopscotch_set.h:299
const_iterator cbegin() const noexcept
Definition bhopscotch_set.h:184
iterator begin() noexcept
Definition bhopscotch_set.h:182
iterator emplace_hint(const_iterator hint, Args &&...args)
Definition bhopscotch_set.h:239
size_type count(const K &key, std::size_t precalculated_hash) const
Definition bhopscotch_set.h:327
hasher hash_function() const
Definition bhopscotch_set.h:542
std::pair< iterator, iterator > equal_range(const Key &key, std::size_t precalculated_hash)
Definition bhopscotch_set.h:453
bhopscotch_set()
Definition bhopscotch_set.h:100
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:125
std::pair< iterator, iterator > equal_range(const K &key)
Definition bhopscotch_set.h:480
friend bool operator!=(const bhopscotch_set &lhs, const bhopscotch_set &rhs)
Definition bhopscotch_set.h:573
typename ht::difference_type difference_type
Definition bhopscotch_set.h:85
typename ht::const_reference const_reference
Definition bhopscotch_set.h:91
const_iterator find(const Key &key, std::size_t precalculated_hash) const
Definition bhopscotch_set.h:349
void insert(std::initializer_list< value_type > ilist)
Definition bhopscotch_set.h:215
bhopscotch_set(const Allocator &alloc)
Definition bhopscotch_set.h:119
size_type size() const noexcept
Definition bhopscotch_set.h:194
typename ht::hasher hasher
Definition bhopscotch_set.h:86
iterator insert(const_iterator hint, const value_type &value)
Definition bhopscotch_set.h:205
bhopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition bhopscotch_set.h:141
std::pair< iterator, bool > emplace(Args &&...args)
Definition bhopscotch_set.h:227
friend void swap(bhopscotch_set &lhs, bhopscotch_set &rhs)
Definition bhopscotch_set.h:578
float max_load_factor() const
Definition bhopscotch_set.h:533
bhopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc)
Definition bhopscotch_set.h:155
typename ht::iterator iterator
Definition bhopscotch_set.h:94
Compare key_compare
Definition bhopscotch_set.h:88
key_equal key_eq() const
Definition bhopscotch_set.h:543
const_iterator end() const noexcept
Definition bhopscotch_set.h:187
size_type erase(const key_type &key)
Definition bhopscotch_set.h:247
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:147
std::pair< iterator, iterator > equal_range(const K &key, std::size_t precalculated_hash)
Definition bhopscotch_set.h:495
float load_factor() const
Definition bhopscotch_set.h:532
void insert(InputIt first, InputIt last)
Definition bhopscotch_set.h:214
const_iterator find(const K &key) const
Definition bhopscotch_set.h:388
iterator end() noexcept
Definition bhopscotch_set.h:186
const_iterator find(const Key &key) const
Definition bhopscotch_set.h:344
void reserve(size_type count_)
Definition bhopscotch_set.h:537
iterator erase(iterator pos)
Definition bhopscotch_set.h:244
typename ht::const_iterator const_iterator
Definition bhopscotch_set.h:95
iterator find(const K &key)
Definition bhopscotch_set.h:362
bool empty() const noexcept
Definition bhopscotch_set.h:193
typename ht::const_pointer const_pointer
Definition bhopscotch_set.h:93
iterator insert(const_iterator hint, value_type &&value)
Definition bhopscotch_set.h:209
iterator find(const Key &key, std::size_t precalculated_hash)
Definition bhopscotch_set.h:339
typename ht::size_type size_type
Definition bhopscotch_set.h:84
iterator erase(const_iterator pos)
Definition bhopscotch_set.h:245
bool contains(const K &key) const
Definition bhopscotch_set.h:427
bhopscotch_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition bhopscotch_set.h:114
void max_load_factor(float ml)
Definition bhopscotch_set.h:534
typename ht::key_equal key_equal
Definition bhopscotch_set.h:87
key_compare key_comp() const
Definition bhopscotch_set.h:544
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t precalculated_hash) const
Definition bhopscotch_set.h:517
void clear() noexcept
Definition bhopscotch_set.h:200
bool contains(const Key &key, std::size_t precalculated_hash) const
Definition bhopscotch_set.h:415
Definition hopscotch_hash.h:431
const_iterator cend() const noexcept
Definition hopscotch_hash.h:772
std::pair< iterator, bool > emplace(Args &&...args)
Definition hopscotch_hash.h:890
void swap(hopscotch_hash &other)
Definition hopscotch_hash.h:994
std::size_t size_type
Definition hopscotch_hash.h:446
Hash hasher
Definition hopscotch_hash.h:448
value_type & reference
Definition hopscotch_hash.h:451
bool contains(const K &key) const
Definition hopscotch_hash.h:1094
const_iterator cbegin() const noexcept
Definition hopscotch_hash.h:755
size_type max_size() const noexcept
Definition hopscotch_hash.h:785
hopscotch_iterator< true > const_iterator
Definition hopscotch_hash.h:456
float max_load_factor() const
Definition hopscotch_hash.h:1162
value_type * pointer
Definition hopscotch_hash.h:453
size_type count(const K &key) const
Definition hopscotch_hash.h:1070
U::key_compare key_comp() const
Definition hopscotch_hash.h:1211
std::pair< iterator, bool > insert(const value_type &value)
Definition hopscotch_hash.h:800
key_equal key_eq() const
Definition hopscotch_hash.h:1187
std::ptrdiff_t difference_type
Definition hopscotch_hash.h:447
static const size_type DEFAULT_INIT_BUCKETS_SIZE
Definition hopscotch_hash.h:1786
float load_factor() const
Definition hopscotch_hash.h:1153
allocator_type get_allocator() const
Definition hopscotch_hash.h:738
bool empty() const noexcept
Definition hopscotch_hash.h:781
KeyEqual key_equal
Definition hopscotch_hash.h:449
iterator erase(iterator pos)
Definition hopscotch_hash.h:935
iterator begin() noexcept
Definition hopscotch_hash.h:743
const value_type * const_pointer
Definition hopscotch_hash.h:454
std::pair< iterator, iterator > equal_range(const K &key)
Definition hopscotch_hash.h:1101
Allocator allocator_type
Definition hopscotch_hash.h:450
size_type bucket_count() const
Definition hopscotch_hash.h:1128
size_type max_bucket_count() const
Definition hopscotch_hash.h:1143
void clear() noexcept
Definition hopscotch_hash.h:790
hasher hash_function() const
Definition hopscotch_hash.h:1185
size_type size() const noexcept
Definition hopscotch_hash.h:783
hopscotch_iterator< false > iterator
Definition hopscotch_hash.h:455
iterator emplace_hint(const_iterator hint, Args &&...args)
Definition hopscotch_hash.h:895
typename KeySelect::key_type key_type
Definition hopscotch_hash.h:444
void rehash(size_type count_)
Definition hopscotch_hash.h:1171
const value_type & const_reference
Definition hopscotch_hash.h:452
iterator end() noexcept
Definition hopscotch_hash.h:765
iterator mutable_iterator(const_iterator pos)
Definition hopscotch_hash.h:1192
void reserve(size_type count_)
Definition hopscotch_hash.h:1177
iterator find(const K &key)
Definition hopscotch_hash.h:1077
size_type overflow_size() const noexcept
Definition hopscotch_hash.h:1207
ValueType value_type
Definition hopscotch_hash.h:445
Definition hopscotch_growth_policy.h:350
Definition bhopscotch_map.h:38
Definition hopscotch_hash.h:60