24#ifndef TSL_HOPSCOTCH_SET_H
25#define TSL_HOPSCOTCH_SET_H
30#include <initializer_list>
78 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
79 class Allocator = std::allocator<Key>,
unsigned int NeighborhoodSize = 62,
80 bool StoreHash = false,
class GrowthPolicy = tsl::hh::power_of_two_growth_policy<2>>
99 Allocator, NeighborhoodSize, StoreHash,
123 const KeyEqual &equal = KeyEqual(),
const Allocator &alloc = Allocator())
143 template <
class InputIt>
146 const KeyEqual &equal = KeyEqual(),
const Allocator &alloc = Allocator())
152 template <
class InputIt>
158 template <
class InputIt>
160 const Allocator &alloc)
167 const KeyEqual &equal = KeyEqual(),
const Allocator &alloc = Allocator())
173 const Allocator &alloc)
179 const Allocator &alloc)
231 template <
class InputIt>
void insert(InputIt first, InputIt last) {
m_ht.
insert(first, last); }
232 void insert(std::initializer_list<value_type> ilist)
244 template <
class... Args> std::pair<iterator, bool>
emplace(Args &&...args)
273 return m_ht.
erase(key, precalculated_hash);
281 template <
class K,
class KE = KeyEqual,
282 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
295 template <
class K,
class KE = KeyEqual,
296 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
299 return m_ht.
erase(key, precalculated_hash);
316 return m_ht.
count(key, precalculated_hash);
324 template <
class K,
class KE = KeyEqual,
325 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
338 template <
class K,
class KE = KeyEqual,
339 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
342 return m_ht.
count(key, precalculated_hash);
354 return m_ht.
find(key, precalculated_hash);
364 return m_ht.
find(key, precalculated_hash);
372 template <
class K,
class KE = KeyEqual,
373 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
386 template <
class K,
class KE = KeyEqual,
387 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
390 return m_ht.
find(key, precalculated_hash);
396 template <
class K,
class KE = KeyEqual,
397 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
410 template <
class K,
class KE = KeyEqual,
411 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
414 return m_ht.
find(key, precalculated_hash);
424 bool contains(
const Key &key, 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 bool contains(
const K &key, std::size_t precalculated_hash)
const
462 std::pair<iterator, iterator>
equal_range(
const Key &key, std::size_t precalculated_hash)
467 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key)
const
475 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key,
476 std::size_t precalculated_hash)
const
486 template <
class K,
class KE = KeyEqual,
487 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
500 template <
class K,
class KE = KeyEqual,
501 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
502 std::pair<iterator, iterator>
equal_range(
const K &key, std::size_t precalculated_hash)
510 template <
class K,
class KE = KeyEqual,
511 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
512 std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const
520 template <
class K,
class KE = KeyEqual,
521 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
522 std::pair<const_iterator, const_iterator>
equal_range(
const K &key,
523 std::size_t precalculated_hash)
const
567 for (
const auto &element_lhs : lhs) {
568 const auto it_element_rhs = rhs.
find(element_lhs);
569 if (it_element_rhs == rhs.
cend()) {
592 template <
class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
593 class Allocator = std::allocator<Key>,
unsigned int NeighborhoodSize = 62,
594 bool StoreHash = false>
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
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 hopscotch_set.h:88
key_type & operator()(Key &key)
Definition hopscotch_set.h:94
Key key_type
Definition hopscotch_set.h:90
const key_type & operator()(const Key &key) const
Definition hopscotch_set.h:92
Definition hopscotch_set.h:82
void insert(InputIt first, InputIt last)
Definition hopscotch_set.h:231
typename ht::const_pointer const_pointer
Definition hopscotch_set.h:113
typename ht::key_type key_type
Definition hopscotch_set.h:103
iterator find(const K &key, std::size_t precalculated_hash)
Definition hopscotch_set.h:388
void rehash(size_type count_)
Definition hopscotch_set.h:541
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const
Definition hopscotch_set.h:467
typename ht::reference reference
Definition hopscotch_set.h:110
size_type bucket_count() const
Definition hopscotch_set.h:531
typename ht::hasher hasher
Definition hopscotch_set.h:107
std::pair< iterator, iterator > equal_range(const K &key, std::size_t precalculated_hash)
Definition hopscotch_set.h:502
iterator mutable_iterator(const_iterator pos)
Definition hopscotch_set.h:557
hopscotch_set()
Definition hopscotch_set.h:120
iterator emplace_hint(const_iterator hint, Args &&...args)
Definition hopscotch_set.h:256
hopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
Definition hopscotch_set.h:153
typename ht::key_equal key_equal
Definition hopscotch_set.h:108
void insert(std::initializer_list< value_type > ilist)
Definition hopscotch_set.h:232
float load_factor() const
Definition hopscotch_set.h:537
std::pair< iterator, iterator > equal_range(const Key &key, std::size_t precalculated_hash)
Definition hopscotch_set.h:462
std::pair< iterator, bool > emplace(Args &&...args)
Definition hopscotch_set.h:244
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:144
iterator find(const K &key)
Definition hopscotch_set.h:374
friend bool operator==(const hopscotch_set &lhs, const hopscotch_set &rhs)
Definition hopscotch_set.h:561
ht m_ht
Definition hopscotch_set.h:585
iterator find(const Key &key, std::size_t precalculated_hash)
Definition hopscotch_set.h:352
iterator erase(const_iterator first, const_iterator last)
Definition hopscotch_set.h:263
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition hopscotch_set.h:512
typename ht::pointer pointer
Definition hopscotch_set.h:112
hopscotch_set(size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
Definition hopscotch_set.h:122
typename ht::iterator iterator
Definition hopscotch_set.h:114
iterator erase(const_iterator pos)
Definition hopscotch_set.h:262
iterator insert(const_iterator hint, value_type &&value)
Definition hopscotch_set.h:226
allocator_type get_allocator() const
Definition hopscotch_set.h:194
size_type erase(const key_type &key)
Definition hopscotch_set.h:264
hopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc)
Definition hopscotch_set.h:172
void clear() noexcept
Definition hopscotch_set.h:217
const_iterator find(const K &key) const
Definition hopscotch_set.h:398
bool contains(const Key &key) const
Definition hopscotch_set.h:417
friend bool operator!=(const hopscotch_set &lhs, const hopscotch_set &rhs)
Definition hopscotch_set.h:577
float max_load_factor() const
Definition hopscotch_set.h:538
iterator find(const Key &key)
Definition hopscotch_set.h:345
std::pair< iterator, iterator > equal_range(const K &key)
Definition hopscotch_set.h:488
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:165
size_type overflow_size() const noexcept
Definition hopscotch_set.h:559
const_iterator find(const Key &key, std::size_t precalculated_hash) const
Definition hopscotch_set.h:362
typename ht::size_type size_type
Definition hopscotch_set.h:105
bool contains(const K &key, std::size_t precalculated_hash) const
Definition hopscotch_set.h:450
std::pair< const_iterator, const_iterator > equal_range(const Key &key, std::size_t precalculated_hash) const
Definition hopscotch_set.h:475
iterator begin() noexcept
Definition hopscotch_set.h:199
bool contains(const K &key) const
Definition hopscotch_set.h:436
hopscotch_set(std::initializer_list< value_type > init, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition hopscotch_set.h:178
std::pair< iterator, bool > insert(const value_type &value)
Definition hopscotch_set.h:219
iterator erase(iterator pos)
Definition hopscotch_set.h:261
void swap(hopscotch_set &other)
Definition hopscotch_set.h:302
iterator insert(const_iterator hint, const value_type &value)
Definition hopscotch_set.h:222
std::list< Key, Allocator > overflow_container_type
Definition hopscotch_set.h:97
typename ht::const_reference const_reference
Definition hopscotch_set.h:111
typename ht::difference_type difference_type
Definition hopscotch_set.h:106
std::pair< iterator, bool > insert(value_type &&value)
Definition hopscotch_set.h:220
friend void swap(hopscotch_set &lhs, hopscotch_set &rhs)
Definition hopscotch_set.h:582
void reserve(size_type count_)
Definition hopscotch_set.h:542
size_type count(const K &key, std::size_t precalculated_hash) const
Definition hopscotch_set.h:340
const_iterator begin() const noexcept
Definition hopscotch_set.h:200
size_type erase(const K &key, std::size_t precalculated_hash)
Definition hopscotch_set.h:297
bool empty() const noexcept
Definition hopscotch_set.h:210
hopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition hopscotch_set.h:159
hasher hash_function() const
Definition hopscotch_set.h:547
size_type max_bucket_count() const
Definition hopscotch_set.h:532
size_type count(const K &key) const
Definition hopscotch_set.h:326
bool contains(const Key &key, std::size_t precalculated_hash) const
Definition hopscotch_set.h:424
const_iterator find(const K &key, std::size_t precalculated_hash) const
Definition hopscotch_set.h:412
size_type count(const Key &key) const
Definition hopscotch_set.h:307
typename ht::value_type value_type
Definition hopscotch_set.h:104
hopscotch_set(const Allocator &alloc)
Definition hopscotch_set.h:138
const_iterator cbegin() const noexcept
Definition hopscotch_set.h:201
void max_load_factor(float ml)
Definition hopscotch_set.h:539
hopscotch_set & operator=(std::initializer_list< value_type > ilist)
Definition hopscotch_set.h:184
const_iterator end() const noexcept
Definition hopscotch_set.h:204
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t precalculated_hash) const
Definition hopscotch_set.h:522
size_type count(const Key &key, std::size_t precalculated_hash) const
Definition hopscotch_set.h:314
typename ht::const_iterator const_iterator
Definition hopscotch_set.h:115
size_type size() const noexcept
Definition hopscotch_set.h:211
size_type erase(const key_type &key, std::size_t precalculated_hash)
Definition hopscotch_set.h:271
typename ht::allocator_type allocator_type
Definition hopscotch_set.h:109
size_type erase(const K &key)
Definition hopscotch_set.h:283
std::pair< iterator, iterator > equal_range(const Key &key)
Definition hopscotch_set.h:455
hopscotch_set(size_type bucket_count, const Allocator &alloc)
Definition hopscotch_set.h:128
size_type max_size() const noexcept
Definition hopscotch_set.h:212
iterator end() noexcept
Definition hopscotch_set.h:203
const_iterator cend() const noexcept
Definition hopscotch_set.h:205
const_iterator find(const Key &key) const
Definition hopscotch_set.h:357
key_equal key_eq() const
Definition hopscotch_set.h:548
hopscotch_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition hopscotch_set.h:133
Definition bhopscotch_map.h:38
Definition hopscotch_hash.h:60