IOSS 2.0
Loading...
Searching...
No Matches
hopscotch_set.h
Go to the documentation of this file.
1/**
2 * MIT License
3 *
4 * Copyright (c) 2017 Thibaut Goetghebuer-Planchon <tessil@gmx.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef TSL_HOPSCOTCH_SET_H
25#define TSL_HOPSCOTCH_SET_H
26
27#include <algorithm>
28#include <cstddef>
29#include <functional>
30#include <initializer_list>
31#include <list>
32#include <memory>
33#include <type_traits>
34#include <utility>
35
36#include "hopscotch_hash.h"
37
38namespace tsl {
39
40 /**
41 * Implementation of a hash set using the hopscotch hashing algorithm.
42 *
43 * The Key must be either nothrow move-constructible, copy-constructible or
44 * both.
45 *
46 * The size of the neighborhood (NeighborhoodSize) must be > 0 and <= 62 if
47 * StoreHash is false. When StoreHash is true, 32-bits of the hash will be
48 * stored alongside the neighborhood limiting the NeighborhoodSize to <= 30.
49 * There is no memory usage difference between 'NeighborhoodSize 62; StoreHash
50 * false' and 'NeighborhoodSize 30; StoreHash true'.
51 *
52 * Storing the hash may improve performance on insert during the rehash process
53 * if the hash takes time to compute. It may also improve read performance if
54 * the KeyEqual function takes time (or incurs a cache-miss). If used with
55 * simple Hash and KeyEqual it may slow things down.
56 *
57 * StoreHash can only be set if the GrowthPolicy is set to
58 * tsl::power_of_two_growth_policy.
59 *
60 * GrowthPolicy defines how the set grows and consequently how a hash value is
61 * mapped to a bucket. By default the set uses tsl::power_of_two_growth_policy.
62 * This policy keeps the number of buckets to a power of two and uses a mask to
63 * set the hash to a bucket instead of the slow modulo. You may define your own
64 * growth policy, check tsl::power_of_two_growth_policy for the interface.
65 *
66 * If the destructor of Key throws an exception, behaviour of the class is
67 * undefined.
68 *
69 * Iterators invalidation:
70 * - clear, operator=, reserve, rehash: always invalidate the iterators.
71 * - insert, emplace, emplace_hint, operator[]: if there is an effective
72 * insert, invalidate the iterators if a displacement is needed to resolve a
73 * collision (which mean that most of the time, insert will invalidate the
74 * iterators). Or if there is a rehash.
75 * - erase: iterator on the erased element is the only one which become
76 * invalid.
77 */
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>>
82 {
83 private:
84 template <typename U>
86
88 {
89 public:
90 using key_type = Key;
91
92 const key_type &operator()(const Key &key) const { return key; }
93
94 key_type &operator()(Key &key) { return key; }
95 };
96
97 using overflow_container_type = std::list<Key, Allocator>;
98 using ht = detail_hopscotch_hash::hopscotch_hash<Key, KeySelect, void, Hash, KeyEqual,
99 Allocator, NeighborhoodSize, StoreHash,
100 GrowthPolicy, overflow_container_type>;
101
102 public:
103 using key_type = typename ht::key_type;
104 using value_type = typename ht::value_type;
105 using size_type = typename ht::size_type;
107 using hasher = typename ht::hasher;
108 using key_equal = typename ht::key_equal;
110 using reference = typename ht::reference;
112 using pointer = typename ht::pointer;
114 using iterator = typename ht::iterator;
116
117 /*
118 * Constructors
119 */
120 hopscotch_set() : hopscotch_set(ht::DEFAULT_INIT_BUCKETS_SIZE) {}
121
122 explicit hopscotch_set(size_type bucket_count, const Hash &hash = Hash(),
123 const KeyEqual &equal = KeyEqual(), const Allocator &alloc = Allocator())
124 : m_ht(bucket_count, hash, equal, alloc, ht::DEFAULT_MAX_LOAD_FACTOR)
125 {
126 }
127
128 hopscotch_set(size_type bucket_count, const Allocator &alloc)
129 : hopscotch_set(bucket_count, Hash(), KeyEqual(), alloc)
130 {
131 }
132
133 hopscotch_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
134 : hopscotch_set(bucket_count, hash, KeyEqual(), alloc)
135 {
136 }
137
138 explicit hopscotch_set(const Allocator &alloc)
139 : hopscotch_set(ht::DEFAULT_INIT_BUCKETS_SIZE, alloc)
140 {
141 }
142
143 template <class InputIt>
144 hopscotch_set(InputIt first, InputIt last,
145 size_type bucket_count = ht::DEFAULT_INIT_BUCKETS_SIZE, const Hash &hash = Hash(),
146 const KeyEqual &equal = KeyEqual(), const Allocator &alloc = Allocator())
147 : hopscotch_set(bucket_count, hash, equal, alloc)
148 {
149 insert(first, last);
150 }
151
152 template <class InputIt>
153 hopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
154 : hopscotch_set(first, last, bucket_count, Hash(), KeyEqual(), alloc)
155 {
156 }
157
158 template <class InputIt>
159 hopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash,
160 const Allocator &alloc)
161 : hopscotch_set(first, last, bucket_count, hash, KeyEqual(), alloc)
162 {
163 }
164
165 hopscotch_set(std::initializer_list<value_type> init,
166 size_type bucket_count = ht::DEFAULT_INIT_BUCKETS_SIZE, const Hash &hash = Hash(),
167 const KeyEqual &equal = KeyEqual(), const Allocator &alloc = Allocator())
168 : hopscotch_set(init.begin(), init.end(), bucket_count, hash, equal, alloc)
169 {
170 }
171
172 hopscotch_set(std::initializer_list<value_type> init, size_type bucket_count,
173 const Allocator &alloc)
174 : hopscotch_set(init.begin(), init.end(), bucket_count, Hash(), KeyEqual(), alloc)
175 {
176 }
177
178 hopscotch_set(std::initializer_list<value_type> init, size_type bucket_count, const Hash &hash,
179 const Allocator &alloc)
180 : hopscotch_set(init.begin(), init.end(), bucket_count, hash, KeyEqual(), alloc)
181 {
182 }
183
184 hopscotch_set &operator=(std::initializer_list<value_type> ilist)
185 {
186 m_ht.clear();
187
188 m_ht.reserve(ilist.size());
189 m_ht.insert(ilist.begin(), ilist.end());
190
191 return *this;
192 }
193
195
196 /*
197 * Iterators
198 */
199 iterator begin() noexcept { return m_ht.begin(); }
200 const_iterator begin() const noexcept { return m_ht.begin(); }
201 const_iterator cbegin() const noexcept { return m_ht.cbegin(); }
202
203 iterator end() noexcept { return m_ht.end(); }
204 const_iterator end() const noexcept { return m_ht.end(); }
205 const_iterator cend() const noexcept { return m_ht.cend(); }
206
207 /*
208 * Capacity
209 */
210 bool empty() const noexcept { return m_ht.empty(); }
211 size_type size() const noexcept { return m_ht.size(); }
212 size_type max_size() const noexcept { return m_ht.max_size(); }
213
214 /*
215 * Modifiers
216 */
217 void clear() noexcept { m_ht.clear(); }
218
219 std::pair<iterator, bool> insert(const value_type &value) { return m_ht.insert(value); }
220 std::pair<iterator, bool> insert(value_type &&value) { return m_ht.insert(std::move(value)); }
221
223 {
224 return m_ht.insert(hint, value);
225 }
227 {
228 return m_ht.insert(hint, std::move(value));
229 }
230
231 template <class InputIt> void insert(InputIt first, InputIt last) { m_ht.insert(first, last); }
232 void insert(std::initializer_list<value_type> ilist)
233 {
234 m_ht.insert(ilist.begin(), ilist.end());
235 }
236
237 /**
238 * Due to the way elements are stored, emplace will need to move or copy the
239 * key-value once. The method is equivalent to
240 * insert(value_type(std::forward<Args>(args)...));
241 *
242 * Mainly here for compatibility with the std::unordered_map interface.
243 */
244 template <class... Args> std::pair<iterator, bool> emplace(Args &&...args)
245 {
246 return m_ht.emplace(std::forward<Args>(args)...);
247 }
248
249 /**
250 * Due to the way elements are stored, emplace_hint will need to move or copy
251 * the key-value once. The method is equivalent to insert(hint,
252 * value_type(std::forward<Args>(args)...));
253 *
254 * Mainly here for compatibility with the std::unordered_map interface.
255 */
256 template <class... Args> iterator emplace_hint(const_iterator hint, Args &&...args)
257 {
258 return m_ht.emplace_hint(hint, std::forward<Args>(args)...);
259 }
260
261 iterator erase(iterator pos) { return m_ht.erase(pos); }
262 iterator erase(const_iterator pos) { return m_ht.erase(pos); }
263 iterator erase(const_iterator first, const_iterator last) { return m_ht.erase(first, last); }
264 size_type erase(const key_type &key) { return m_ht.erase(key); }
265
266 /**
267 * Use the hash value 'precalculated_hash' instead of hashing the key. The
268 * hash value should be the same as hash_function()(key). Useful to speed-up
269 * the lookup to the value if you already have the hash.
270 */
271 size_type erase(const key_type &key, std::size_t precalculated_hash)
272 {
273 return m_ht.erase(key, precalculated_hash);
274 }
275
276 /**
277 * This overload only participates in the overload resolution if the typedef
278 * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
279 * to Key.
280 */
281 template <class K, class KE = KeyEqual,
282 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
283 size_type erase(const K &key)
284 {
285 return m_ht.erase(key);
286 }
287
288 /**
289 * @copydoc erase(const K& key)
290 *
291 * Use the hash value 'precalculated_hash' instead of hashing the key. The
292 * hash value should be the same as hash_function()(key). Useful to speed-up
293 * the lookup to the value if you already have the hash.
294 */
295 template <class K, class KE = KeyEqual,
296 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
297 size_type erase(const K &key, std::size_t precalculated_hash)
298 {
299 return m_ht.erase(key, precalculated_hash);
300 }
301
302 void swap(hopscotch_set &other) { other.m_ht.swap(m_ht); }
303
304 /*
305 * Lookup
306 */
307 size_type count(const Key &key) const { return m_ht.count(key); }
308
309 /**
310 * Use the hash value 'precalculated_hash' instead of hashing the key. The
311 * hash value should be the same as hash_function()(key). Useful to speed-up
312 * the lookup if you already have the hash.
313 */
314 size_type count(const Key &key, std::size_t precalculated_hash) const
315 {
316 return m_ht.count(key, precalculated_hash);
317 }
318
319 /**
320 * This overload only participates in the overload resolution if the typedef
321 * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
322 * to Key.
323 */
324 template <class K, class KE = KeyEqual,
325 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
326 size_type count(const K &key) const
327 {
328 return m_ht.count(key);
329 }
330
331 /**
332 * @copydoc count(const K& key) const
333 *
334 * Use the hash value 'precalculated_hash' instead of hashing the key. The
335 * hash value should be the same as hash_function()(key). Useful to speed-up
336 * the lookup if you already have the hash.
337 */
338 template <class K, class KE = KeyEqual,
339 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
340 size_type count(const K &key, std::size_t precalculated_hash) const
341 {
342 return m_ht.count(key, precalculated_hash);
343 }
344
345 iterator find(const Key &key) { return m_ht.find(key); }
346
347 /**
348 * Use the hash value 'precalculated_hash' instead of hashing the key. The
349 * hash value should be the same as hash_function()(key). Useful to speed-up
350 * the lookup if you already have the hash.
351 */
352 iterator find(const Key &key, std::size_t precalculated_hash)
353 {
354 return m_ht.find(key, precalculated_hash);
355 }
356
357 const_iterator find(const Key &key) const { return m_ht.find(key); }
358
359 /**
360 * @copydoc find(const Key& key, std::size_t precalculated_hash)
361 */
362 const_iterator find(const Key &key, std::size_t precalculated_hash) const
363 {
364 return m_ht.find(key, precalculated_hash);
365 }
366
367 /**
368 * This overload only participates in the overload resolution if the typedef
369 * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
370 * to Key.
371 */
372 template <class K, class KE = KeyEqual,
373 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
374 iterator find(const K &key)
375 {
376 return m_ht.find(key);
377 }
378
379 /**
380 * @copydoc find(const K& key)
381 *
382 * Use the hash value 'precalculated_hash' instead of hashing the key. The
383 * hash value should be the same as hash_function()(key). Useful to speed-up
384 * the lookup if you already have the hash.
385 */
386 template <class K, class KE = KeyEqual,
387 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
388 iterator find(const K &key, std::size_t precalculated_hash)
389 {
390 return m_ht.find(key, precalculated_hash);
391 }
392
393 /**
394 * @copydoc find(const K& key)
395 */
396 template <class K, class KE = KeyEqual,
397 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
398 const_iterator find(const K &key) const
399 {
400 return m_ht.find(key);
401 }
402
403 /**
404 * @copydoc find(const K& key)
405 *
406 * Use the hash value 'precalculated_hash' instead of hashing the key. The
407 * hash value should be the same as hash_function()(key). Useful to speed-up
408 * the lookup if you already have the hash.
409 */
410 template <class K, class KE = KeyEqual,
411 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
412 const_iterator find(const K &key, std::size_t precalculated_hash) const
413 {
414 return m_ht.find(key, precalculated_hash);
415 }
416
417 bool contains(const Key &key) const { return m_ht.contains(key); }
418
419 /**
420 * Use the hash value 'precalculated_hash' instead of hashing the key. The
421 * hash value should be the same as hash_function()(key). Useful to speed-up
422 * the lookup if you already have the hash.
423 */
424 bool contains(const Key &key, std::size_t precalculated_hash) const
425 {
426 return m_ht.contains(key, precalculated_hash);
427 }
428
429 /**
430 * This overload only participates in the overload resolution if the typedef
431 * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
432 * to Key.
433 */
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) const
437 {
438 return m_ht.contains(key);
439 }
440
441 /**
442 * @copydoc contains(const K& key) const
443 *
444 * Use the hash value 'precalculated_hash' instead of hashing the key. The
445 * hash value should be the same as hash_function()(key). Useful to speed-up
446 * the lookup if you already have the hash.
447 */
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
451 {
452 return m_ht.contains(key, precalculated_hash);
453 }
454
455 std::pair<iterator, iterator> equal_range(const Key &key) { return m_ht.equal_range(key); }
456
457 /**
458 * Use the hash value 'precalculated_hash' instead of hashing the key. The
459 * hash value should be the same as hash_function()(key). Useful to speed-up
460 * the lookup if you already have the hash.
461 */
462 std::pair<iterator, iterator> equal_range(const Key &key, std::size_t precalculated_hash)
463 {
464 return m_ht.equal_range(key, precalculated_hash);
465 }
466
467 std::pair<const_iterator, const_iterator> equal_range(const Key &key) const
468 {
469 return m_ht.equal_range(key);
470 }
471
472 /**
473 * @copydoc equal_range(const Key& key, std::size_t precalculated_hash)
474 */
475 std::pair<const_iterator, const_iterator> equal_range(const Key &key,
476 std::size_t precalculated_hash) const
477 {
478 return m_ht.equal_range(key, precalculated_hash);
479 }
480
481 /**
482 * This overload only participates in the overload resolution if the typedef
483 * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
484 * to Key.
485 */
486 template <class K, class KE = KeyEqual,
487 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
488 std::pair<iterator, iterator> equal_range(const K &key)
489 {
490 return m_ht.equal_range(key);
491 }
492
493 /**
494 * @copydoc equal_range(const K& key)
495 *
496 * Use the hash value 'precalculated_hash' instead of hashing the key. The
497 * hash value should be the same as hash_function()(key). Useful to speed-up
498 * the lookup if you already have the hash.
499 */
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)
503 {
504 return m_ht.equal_range(key, precalculated_hash);
505 }
506
507 /**
508 * @copydoc equal_range(const K& key)
509 */
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
513 {
514 return m_ht.equal_range(key);
515 }
516
517 /**
518 * @copydoc equal_range(const K& key, std::size_t precalculated_hash)
519 */
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
524 {
525 return m_ht.equal_range(key, precalculated_hash);
526 }
527
528 /*
529 * Bucket interface
530 */
533
534 /*
535 * Hash policy
536 */
537 float load_factor() const { return m_ht.load_factor(); }
538 float max_load_factor() const { return m_ht.max_load_factor(); }
539 void max_load_factor(float ml) { m_ht.max_load_factor(ml); }
540
541 void rehash(size_type count_) { m_ht.rehash(count_); }
542 void reserve(size_type count_) { m_ht.reserve(count_); }
543
544 /*
545 * Observers
546 */
548 key_equal key_eq() const { return m_ht.key_eq(); }
549
550 /*
551 * Other
552 */
553
554 /**
555 * Convert a const_iterator to an iterator.
556 */
558
559 size_type overflow_size() const noexcept { return m_ht.overflow_size(); }
560
561 friend bool operator==(const hopscotch_set &lhs, const hopscotch_set &rhs)
562 {
563 if (lhs.size() != rhs.size()) {
564 return false;
565 }
566
567 for (const auto &element_lhs : lhs) {
568 const auto it_element_rhs = rhs.find(element_lhs);
569 if (it_element_rhs == rhs.cend()) {
570 return false;
571 }
572 }
573
574 return true;
575 }
576
577 friend bool operator!=(const hopscotch_set &lhs, const hopscotch_set &rhs)
578 {
579 return !operator==(lhs, rhs);
580 }
581
582 friend void swap(hopscotch_set &lhs, hopscotch_set &rhs) { lhs.swap(rhs); }
583
584 private:
586 };
587
588 /**
589 * Same as `tsl::hopscotch_set<Key, Hash, KeyEqual, Allocator, NeighborhoodSize,
590 * StoreHash, tsl::hh::prime_growth_policy>`.
591 */
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>
595 using hopscotch_pg_set = hopscotch_set<Key, Hash, KeyEqual, Allocator, NeighborhoodSize,
597
598} // end namespace tsl
599
600#endif
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