IOSS 2.0
Loading...
Searching...
No Matches
bhopscotch_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_BHOPSCOTCH_SET_H
25#define TSL_BHOPSCOTCH_SET_H
26
27#include <algorithm>
28#include <cstddef>
29#include <functional>
30#include <initializer_list>
31#include <memory>
32#include <set>
33#include <type_traits>
34#include <utility>
35
36#include "hopscotch_hash.h"
37
38namespace tsl {
39
40 /**
41 * Similar to tsl::hopscotch_set but instead of using a list for overflowing
42 * elements it uses a binary search tree. It thus needs an additional template
43 * parameter Compare. Compare should be arithmetically coherent with KeyEqual.
44 *
45 * The binary search tree allows the set to have a worst-case scenario of O(log
46 * n) for search and delete, even if the hash function maps all the elements to
47 * the same bucket. For insert, the amortized worst case is O(log n), but the
48 * worst case is O(n) in case of rehash.
49 *
50 * This makes the set resistant to DoS attacks (but doesn't preclude you to have
51 * a good hash function, as an element in the bucket array is faster to retrieve
52 * than in the tree).
53 *
54 * @copydoc hopscotch_set
55 */
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>>
61 {
62 private:
63 template <typename U>
65
67 {
68 public:
69 using key_type = Key;
70
71 const key_type &operator()(const Key &key) const { return key; }
72
73 key_type &operator()(Key &key) { return key; }
74 };
75
76 using overflow_container_type = std::set<Key, Compare, Allocator>;
77 using ht = tsl::detail_hopscotch_hash::hopscotch_hash<Key, KeySelect, void, Hash, KeyEqual,
78 Allocator, NeighborhoodSize, StoreHash,
79 GrowthPolicy, overflow_container_type>;
80
81 public:
82 using key_type = typename ht::key_type;
83 using value_type = typename ht::value_type;
84 using size_type = typename ht::size_type;
86 using hasher = typename ht::hasher;
87 using key_equal = typename ht::key_equal;
88 using key_compare = Compare;
90 using reference = typename ht::reference;
92 using pointer = typename ht::pointer;
94 using iterator = typename ht::iterator;
96
97 /*
98 * Constructors
99 */
100 bhopscotch_set() : bhopscotch_set(ht::DEFAULT_INIT_BUCKETS_SIZE) {}
101
102 explicit bhopscotch_set(size_type bucket_count, const Hash &hash = Hash(),
103 const KeyEqual &equal = KeyEqual(),
104 const Allocator &alloc = Allocator(), const Compare &comp = Compare())
105 : m_ht(bucket_count, hash, equal, alloc, ht::DEFAULT_MAX_LOAD_FACTOR, comp)
106 {
107 }
108
109 bhopscotch_set(size_type bucket_count, const Allocator &alloc)
110 : bhopscotch_set(bucket_count, Hash(), KeyEqual(), alloc)
111 {
112 }
113
114 bhopscotch_set(size_type bucket_count, const Hash &hash, const Allocator &alloc)
115 : bhopscotch_set(bucket_count, hash, KeyEqual(), alloc)
116 {
117 }
118
119 explicit bhopscotch_set(const Allocator &alloc)
120 : bhopscotch_set(ht::DEFAULT_INIT_BUCKETS_SIZE, alloc)
121 {
122 }
123
124 template <class InputIt>
125 bhopscotch_set(InputIt first, InputIt last,
127 const Hash &hash = Hash(), const KeyEqual &equal = KeyEqual(),
128 const Allocator &alloc = Allocator())
129 : bhopscotch_set(bucket_count, hash, equal, alloc)
130 {
131 insert(first, last);
132 }
133
134 template <class InputIt>
135 bhopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
136 : bhopscotch_set(first, last, bucket_count, Hash(), KeyEqual(), alloc)
137 {
138 }
139
140 template <class InputIt>
141 bhopscotch_set(InputIt first, InputIt last, size_type bucket_count, const Hash &hash,
142 const Allocator &alloc)
143 : bhopscotch_set(first, last, bucket_count, hash, KeyEqual(), alloc)
144 {
145 }
146
147 bhopscotch_set(std::initializer_list<value_type> init,
149 const Hash &hash = Hash(), const KeyEqual &equal = KeyEqual(),
150 const Allocator &alloc = Allocator())
151 : bhopscotch_set(init.begin(), init.end(), bucket_count, hash, equal, alloc)
152 {
153 }
154
155 bhopscotch_set(std::initializer_list<value_type> init, size_type bucket_count,
156 const Allocator &alloc)
157 : bhopscotch_set(init.begin(), init.end(), bucket_count, Hash(), KeyEqual(), alloc)
158 {
159 }
160
161 bhopscotch_set(std::initializer_list<value_type> init, size_type bucket_count, const Hash &hash,
162 const Allocator &alloc)
163 : bhopscotch_set(init.begin(), init.end(), bucket_count, hash, KeyEqual(), alloc)
164 {
165 }
166
167 bhopscotch_set &operator=(std::initializer_list<value_type> ilist)
168 {
169 m_ht.clear();
170
171 m_ht.reserve(ilist.size());
172 m_ht.insert(ilist.begin(), ilist.end());
173
174 return *this;
175 }
176
178
179 /*
180 * Iterators
181 */
182 iterator begin() noexcept { return m_ht.begin(); }
183 const_iterator begin() const noexcept { return m_ht.begin(); }
184 const_iterator cbegin() const noexcept { return m_ht.cbegin(); }
185
186 iterator end() noexcept { return m_ht.end(); }
187 const_iterator end() const noexcept { return m_ht.end(); }
188 const_iterator cend() const noexcept { return m_ht.cend(); }
189
190 /*
191 * Capacity
192 */
193 bool empty() const noexcept { return m_ht.empty(); }
194 size_type size() const noexcept { return m_ht.size(); }
195 size_type max_size() const noexcept { return m_ht.max_size(); }
196
197 /*
198 * Modifiers
199 */
200 void clear() noexcept { m_ht.clear(); }
201
202 std::pair<iterator, bool> insert(const value_type &value) { return m_ht.insert(value); }
203 std::pair<iterator, bool> insert(value_type &&value) { return m_ht.insert(std::move(value)); }
204
206 {
207 return m_ht.insert(hint, value);
208 }
210 {
211 return m_ht.insert(hint, std::move(value));
212 }
213
214 template <class InputIt> void insert(InputIt first, InputIt last) { m_ht.insert(first, last); }
215 void insert(std::initializer_list<value_type> ilist)
216 {
217 m_ht.insert(ilist.begin(), ilist.end());
218 }
219
220 /**
221 * Due to the way elements are stored, emplace will need to move or copy the
222 * key-value once. The method is equivalent to
223 * insert(value_type(std::forward<Args>(args)...));
224 *
225 * Mainly here for compatibility with the std::unordered_map interface.
226 */
227 template <class... Args> std::pair<iterator, bool> emplace(Args &&...args)
228 {
229 return m_ht.emplace(std::forward<Args>(args)...);
230 }
231
232 /**
233 * Due to the way elements are stored, emplace_hint will need to move or copy
234 * the key-value once. The method is equivalent to insert(hint,
235 * value_type(std::forward<Args>(args)...));
236 *
237 * Mainly here for compatibility with the std::unordered_map interface.
238 */
239 template <class... Args> iterator emplace_hint(const_iterator hint, Args &&...args)
240 {
241 return m_ht.emplace_hint(hint, std::forward<Args>(args)...);
242 }
243
244 iterator erase(iterator pos) { return m_ht.erase(pos); }
245 iterator erase(const_iterator pos) { return m_ht.erase(pos); }
246 iterator erase(const_iterator first, const_iterator last) { return m_ht.erase(first, last); }
247 size_type erase(const key_type &key) { return m_ht.erase(key); }
248
249 /**
250 * Use the hash value 'precalculated_hash' instead of hashing the key. The
251 * hash value should be the same as hash_function()(key). Useful to speed-up
252 * the lookup to the value if you already have the hash.
253 */
254 size_type erase(const key_type &key, std::size_t precalculated_hash)
255 {
256 return m_ht.erase(key, precalculated_hash);
257 }
258
259 /**
260 * This overload only participates in the overload resolution if the typedef
261 * KeyEqual::is_transparent and Compare::is_transparent exist. If so, K must
262 * be hashable and comparable to Key.
263 */
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>
267 size_type erase(const K &key)
268 {
269 return m_ht.erase(key);
270 }
271
272 /**
273 * @copydoc erase(const K& key)
274 *
275 * Use the hash value 'precalculated_hash' instead of hashing the key. The
276 * hash value should be the same as hash_function()(key). Useful to speed-up
277 * the lookup to the value if you already have the hash.
278 */
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>
282 size_type erase(const K &key, std::size_t precalculated_hash)
283 {
284 return m_ht.erase(key, precalculated_hash);
285 }
286
287 void swap(bhopscotch_set &other) { other.m_ht.swap(m_ht); }
288
289 /*
290 * Lookup
291 */
292 size_type count(const Key &key) const { return m_ht.count(key); }
293
294 /**
295 * Use the hash value 'precalculated_hash' instead of hashing the key. The
296 * hash value should be the same as hash_function()(key). Useful to speed-up
297 * the lookup if you already have the hash.
298 */
299 size_type count(const Key &key, std::size_t precalculated_hash) const
300 {
301 return m_ht.count(key, precalculated_hash);
302 }
303
304 /**
305 * This overload only participates in the overload resolution if the typedef
306 * KeyEqual::is_transparent and Compare::is_transparent exist. If so, K must
307 * be hashable and comparable to Key.
308 */
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>
312 size_type count(const K &key) const
313 {
314 return m_ht.count(key);
315 }
316
317 /**
318 * @copydoc count(const K& key) const
319 *
320 * Use the hash value 'precalculated_hash' instead of hashing the key. The
321 * hash value should be the same as hash_function()(key). Useful to speed-up
322 * the lookup if you already have the hash.
323 */
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>
327 size_type count(const K &key, std::size_t precalculated_hash) const
328 {
329 return m_ht.count(key, precalculated_hash);
330 }
331
332 iterator find(const Key &key) { return m_ht.find(key); }
333
334 /**
335 * Use the hash value 'precalculated_hash' instead of hashing the key. The
336 * hash value should be the same as hash_function()(key). Useful to speed-up
337 * the lookup if you already have the hash.
338 */
339 iterator find(const Key &key, std::size_t precalculated_hash)
340 {
341 return m_ht.find(key, precalculated_hash);
342 }
343
344 const_iterator find(const Key &key) const { return m_ht.find(key); }
345
346 /**
347 * @copydoc find(const Key& key, std::size_t precalculated_hash)
348 */
349 const_iterator find(const Key &key, std::size_t precalculated_hash) const
350 {
351 return m_ht.find(key, precalculated_hash);
352 }
353
354 /**
355 * This overload only participates in the overload resolution if the typedef
356 * KeyEqual::is_transparent and Compare::is_transparent exist. If so, K must
357 * be hashable and comparable to Key.
358 */
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>
362 iterator find(const K &key)
363 {
364 return m_ht.find(key);
365 }
366
367 /**
368 * @copydoc find(const K& key)
369 *
370 * Use the hash value 'precalculated_hash' instead of hashing the key. The
371 * hash value should be the same as hash_function()(key). Useful to speed-up
372 * the lookup if you already have the hash.
373 */
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>
377 iterator find(const K &key, std::size_t precalculated_hash)
378 {
379 return m_ht.find(key, precalculated_hash);
380 }
381
382 /**
383 * @copydoc find(const K& key)
384 */
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>
388 const_iterator find(const K &key) const
389 {
390 return m_ht.find(key);
391 }
392
393 /**
394 * @copydoc find(const K& key)
395 *
396 * Use the hash value 'precalculated_hash' instead of hashing the key. The
397 * hash value should be the same as hash_function()(key). Useful to speed-up
398 * the lookup if you already have the hash.
399 */
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>
403 const_iterator find(const K &key, std::size_t precalculated_hash) const
404 {
405 return m_ht.find(key, precalculated_hash);
406 }
407
408 bool contains(const Key &key) const { return m_ht.contains(key); }
409
410 /**
411 * Use the hash value 'precalculated_hash' instead of hashing the key. The
412 * hash value should be the same as hash_function()(key). Useful to speed-up
413 * the lookup if you already have the hash.
414 */
415 bool contains(const Key &key, std::size_t precalculated_hash) const
416 {
417 return m_ht.contains(key, precalculated_hash);
418 }
419
420 /**
421 * This overload only participates in the overload resolution if the typedef
422 * KeyEqual::is_transparent exists. If so, K must be hashable and comparable
423 * to Key.
424 */
425 template <class K, class KE = KeyEqual,
426 typename std::enable_if<has_is_transparent<KE>::value>::type * = nullptr>
427 bool contains(const K &key) const
428 {
429 return m_ht.contains(key);
430 }
431
432 /**
433 * @copydoc contains(const K& key) const
434 *
435 * Use the hash value 'precalculated_hash' instead of hashing the key. The
436 * hash value should be the same as hash_function()(key). Useful to speed-up
437 * the lookup if you already have the hash.
438 */
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
442 {
443 return m_ht.contains(key, precalculated_hash);
444 }
445
446 std::pair<iterator, iterator> equal_range(const Key &key) { return m_ht.equal_range(key); }
447
448 /**
449 * Use the hash value 'precalculated_hash' instead of hashing the key. The
450 * hash value should be the same as hash_function()(key). Useful to speed-up
451 * the lookup if you already have the hash.
452 */
453 std::pair<iterator, iterator> equal_range(const Key &key, std::size_t precalculated_hash)
454 {
455 return m_ht.equal_range(key, precalculated_hash);
456 }
457
458 std::pair<const_iterator, const_iterator> equal_range(const Key &key) const
459 {
460 return m_ht.equal_range(key);
461 }
462
463 /**
464 * @copydoc equal_range(const Key& key, std::size_t precalculated_hash)
465 */
466 std::pair<const_iterator, const_iterator> equal_range(const Key &key,
467 std::size_t precalculated_hash) const
468 {
469 return m_ht.equal_range(key, precalculated_hash);
470 }
471
472 /**
473 * This overload only participates in the overload resolution if the typedef
474 * KeyEqual::is_transparent and Compare::is_transparent exist. If so, K must
475 * be hashable and comparable to Key.
476 */
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>
480 std::pair<iterator, iterator> equal_range(const K &key)
481 {
482 return m_ht.equal_range(key);
483 }
484
485 /**
486 * @copydoc equal_range(const K& key)
487 *
488 * Use the hash value 'precalculated_hash' instead of hashing the key. The
489 * hash value should be the same as hash_function()(key). Useful to speed-up
490 * the lookup if you already have the hash.
491 */
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)
496 {
497 return m_ht.equal_range(key, precalculated_hash);
498 }
499
500 /**
501 * @copydoc equal_range(const K& key)
502 */
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
507 {
508 return m_ht.equal_range(key);
509 }
510
511 /**
512 * @copydoc equal_range(const K& key, std::size_t precalculated_hash)
513 */
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
519 {
520 return m_ht.equal_range(key, precalculated_hash);
521 }
522
523 /*
524 * Bucket interface
525 */
528
529 /*
530 * Hash policy
531 */
532 float load_factor() const { return m_ht.load_factor(); }
533 float max_load_factor() const { return m_ht.max_load_factor(); }
534 void max_load_factor(float ml) { m_ht.max_load_factor(ml); }
535
536 void rehash(size_type count_) { m_ht.rehash(count_); }
537 void reserve(size_type count_) { m_ht.reserve(count_); }
538
539 /*
540 * Observers
541 */
543 key_equal key_eq() const { return m_ht.key_eq(); }
544 key_compare key_comp() const { return m_ht.key_comp(); }
545
546 /*
547 * Other
548 */
549
550 /**
551 * Convert a const_iterator to an iterator.
552 */
554
555 size_type overflow_size() const noexcept { return m_ht.overflow_size(); }
556
557 friend bool operator==(const bhopscotch_set &lhs, const bhopscotch_set &rhs)
558 {
559 if (lhs.size() != rhs.size()) {
560 return false;
561 }
562
563 for (const auto &element_lhs : lhs) {
564 const auto it_element_rhs = rhs.find(element_lhs);
565 if (it_element_rhs == rhs.cend()) {
566 return false;
567 }
568 }
569
570 return true;
571 }
572
573 friend bool operator!=(const bhopscotch_set &lhs, const bhopscotch_set &rhs)
574 {
575 return !operator==(lhs, rhs);
576 }
577
578 friend void swap(bhopscotch_set &lhs, bhopscotch_set &rhs) { lhs.swap(rhs); }
579
580 private:
582 };
583
584 /**
585 * Same as `tsl::bhopscotch_set<Key, Hash, KeyEqual, Compare, Allocator,
586 * NeighborhoodSize, StoreHash, tsl::hh::prime_growth_policy>`.
587 */
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,
594
595} // end namespace tsl
596
597#endif
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