24#ifndef TSL_ROBIN_MAP_H
25#define TSL_ROBIN_MAP_H
29#include <initializer_list>
86 template <
class Key,
class T,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
87 class Allocator = std::allocator<std::pair<Key, T>>,
bool StoreHash = false,
88 class GrowthPolicy = tsl::rh::power_of_two_growth_policy<2>>
101 return key_value.first;
114 return key_value.second;
121 KeyEqual, Allocator, StoreHash, GrowthPolicy>;
146 const KeyEqual &equal = KeyEqual(),
const Allocator &alloc = Allocator())
163 template <
class InputIt>
165 const Hash &hash = Hash(),
const KeyEqual &equal = KeyEqual(),
166 const Allocator &alloc = Allocator())
172 template <
class InputIt>
178 template <
class InputIt>
180 const Allocator &alloc)
187 const KeyEqual &equal = KeyEqual(),
const Allocator &alloc = Allocator())
193 const Allocator &alloc)
199 const Allocator &alloc)
241 template <class P, typename std::enable_if<std::is_constructible<value_type, P &&>::value>::type
243 std::pair<iterator, bool>
insert(P &&value)
255 template <class P, typename std::enable_if<std::is_constructible<value_type, P &&>::value>::type
267 template <
class InputIt>
void insert(InputIt first, InputIt last) {
m_ht.
insert(first, last); }
269 void insert(std::initializer_list<value_type> ilist)
301 template <
class... Args> std::pair<iterator, bool>
emplace(Args &&...args)
318 template <
class... Args>
329 template <
class... Args>
352 return m_ht.
erase(key, precalculated_hash);
360 template <
class K,
class KE = KeyEqual,
361 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
372 template <
class K,
class KE = KeyEqual,
373 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
376 return m_ht.
erase(key, precalculated_hash);
391 T &
at(
const Key &key, std::size_t precalculated_hash)
393 return m_ht.
at(key, precalculated_hash);
396 const T &
at(
const Key &key)
const {
return m_ht.
at(key); }
400 const T &
at(
const Key &key, std::size_t precalculated_hash)
const
402 return m_ht.
at(key, precalculated_hash);
410 template <
class K,
class KE = KeyEqual,
411 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
422 template <
class K,
class KE = KeyEqual,
423 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
424 T &
at(
const K &key, std::size_t precalculated_hash)
426 return m_ht.
at(key, precalculated_hash);
431 template <
class K,
class KE = KeyEqual,
432 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
433 const T &
at(
const K &key)
const
440 template <
class K,
class KE = KeyEqual,
441 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
442 const T &
at(
const K &key, std::size_t precalculated_hash)
const
444 return m_ht.
at(key, precalculated_hash);
459 return m_ht.
count(key, precalculated_hash);
467 template <
class K,
class KE = KeyEqual,
468 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
479 template <
class K,
class KE = KeyEqual,
480 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
483 return m_ht.
count(key, precalculated_hash);
495 return m_ht.
find(key, precalculated_hash);
504 return m_ht.
find(key, precalculated_hash);
512 template <
class K,
class KE = KeyEqual,
513 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
524 template <
class K,
class KE = KeyEqual,
525 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
528 return m_ht.
find(key, precalculated_hash);
533 template <
class K,
class KE = KeyEqual,
534 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
545 template <
class K,
class KE = KeyEqual,
546 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
549 return m_ht.
find(key, precalculated_hash);
559 bool contains(
const Key &key, std::size_t precalculated_hash)
const
569 template <
class K,
class KE = KeyEqual,
570 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
581 template <
class K,
class KE = KeyEqual,
582 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
583 bool contains(
const K &key, std::size_t precalculated_hash)
const
595 std::pair<iterator, iterator>
equal_range(
const Key &key, std::size_t precalculated_hash)
600 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key)
const
607 std::pair<const_iterator, const_iterator>
equal_range(
const Key &key,
608 std::size_t precalculated_hash)
const
618 template <
class K,
class KE = KeyEqual,
619 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
630 template <
class K,
class KE = KeyEqual,
631 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
632 std::pair<iterator, iterator>
equal_range(
const K &key, std::size_t precalculated_hash)
639 template <
class K,
class KE = KeyEqual,
640 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
641 std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const
648 template <
class K,
class KE = KeyEqual,
649 typename std::enable_if<has_is_transparent<KE>::value>::type * =
nullptr>
650 std::pair<const_iterator, const_iterator>
equal_range(
const K &key,
651 std::size_t precalculated_hash)
const
713 template <
class Serializer>
void serialize(Serializer &serializer)
const
744 template <
class Deserializer>
759 for (
const auto &element_lhs : lhs) {
760 const auto it_element_rhs = rhs.
find(element_lhs.first);
761 if (it_element_rhs == rhs.
cend() || element_lhs.second != it_element_rhs->second) {
784 template <
class Key,
class T,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,
785 class Allocator = std::allocator<std::pair<Key, T>>,
bool StoreHash = false>
Definition robin_hash.h:365
key_equal key_eq() const
Definition robin_hash.h:1073
static const size_type DEFAULT_INIT_BUCKETS_SIZE
Definition robin_hash.h:1508
iterator find(const K &key)
Definition robin_hash.h:972
Hash hasher
Definition robin_hash.h:382
const value_type * const_pointer
Definition robin_hash.h:388
iterator begin() noexcept
Definition robin_hash.h:664
bool empty() const noexcept
Definition robin_hash.h:695
typename KeySelect::key_type key_type
Definition robin_hash.h:378
float min_load_factor() const
Definition robin_hash.h:1041
KeyEqual key_equal
Definition robin_hash.h:383
std::pair< iterator, bool > insert(P &&value)
Definition robin_hash.h:719
hasher hash_function() const
Definition robin_hash.h:1071
value_type * pointer
Definition robin_hash.h:387
value_type & reference
Definition robin_hash.h:385
void rehash(size_type my_count)
Definition robin_hash.h:1057
std::pair< iterator, bool > try_emplace(K &&key, Args &&...args)
Definition robin_hash.h:783
void serialize(Serializer &serializer) const
Definition robin_hash.h:1083
bool contains(const K &key) const
Definition robin_hash.h:989
std::ptrdiff_t difference_type
Definition robin_hash.h:381
std::pair< iterator, bool > insert_or_assign(K &&key, M &&obj)
Definition robin_hash.h:751
std::pair< iterator, bool > emplace(Args &&...args)
Definition robin_hash.h:773
iterator insert_hint(const_iterator hint, P &&value)
Definition robin_hash.h:724
iterator try_emplace_hint(const_iterator hint, K &&key, Args &&...args)
Definition robin_hash.h:790
U::value_type & at(const K &key)
Definition robin_hash.h:920
size_type max_size() const noexcept
Definition robin_hash.h:699
const_iterator cbegin() const noexcept
Definition robin_hash.h:676
allocator_type get_allocator() const
Definition robin_hash.h:659
ValueType value_type
Definition robin_hash.h:379
robin_iterator< false > iterator
Definition robin_hash.h:389
float load_factor() const
Definition robin_hash.h:1032
const value_type & const_reference
Definition robin_hash.h:386
iterator erase(iterator pos)
Definition robin_hash.h:803
size_type bucket_count() const
Definition robin_hash.h:1022
void deserialize(Deserializer &deserializer, bool hash_compatible)
Definition robin_hash.h:1088
void swap(robin_hash &other)
Definition robin_hash.h:897
size_type count(const K &key) const
Definition robin_hash.h:960
const_iterator cend() const noexcept
Definition robin_hash.h:690
iterator end() noexcept
Definition robin_hash.h:686
float max_load_factor() const
Definition robin_hash.h:1043
size_type size() const noexcept
Definition robin_hash.h:697
std::pair< iterator, iterator > equal_range(const K &key)
Definition robin_hash.h:996
robin_iterator< true > const_iterator
Definition robin_hash.h:390
std::size_t size_type
Definition robin_hash.h:380
void reserve(size_type my_count)
Definition robin_hash.h:1063
iterator mutable_iterator(const_iterator pos)
Definition robin_hash.h:1078
Allocator allocator_type
Definition robin_hash.h:384
size_type max_bucket_count() const
Definition robin_hash.h:1024
iterator emplace_hint(const_iterator hint, Args &&...args)
Definition robin_hash.h:778
void clear() noexcept
Definition robin_hash.h:704
Definition robin_map.h:95
Key key_type
Definition robin_map.h:97
key_type & operator()(std::pair< Key, T > &key_value) noexcept
Definition robin_map.h:104
const key_type & operator()(const std::pair< Key, T > &key_value) const noexcept
Definition robin_map.h:99
Definition robin_map.h:108
T value_type
Definition robin_map.h:110
const value_type & operator()(const std::pair< Key, T > &key_value) const noexcept
Definition robin_map.h:112
value_type & operator()(std::pair< Key, T > &key_value) noexcept
Definition robin_map.h:117
Definition robin_map.h:90
robin_map(InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition robin_map.h:179
float load_factor() const
Definition robin_map.h:665
typename ht::value_type value_type
Definition robin_map.h:126
float min_load_factor() const
Definition robin_map.h:667
typename ht::reference reference
Definition robin_map.h:132
std::pair< iterator, bool > try_emplace(key_type &&k, Args &&...args)
Definition robin_map.h:324
T & at(const Key &key)
Definition robin_map.h:384
friend bool operator!=(const robin_map &lhs, const robin_map &rhs)
Definition robin_map.h:769
typename ht::const_pointer const_pointer
Definition robin_map.h:135
std::pair< iterator, bool > insert(P &&value)
Definition robin_map.h:243
iterator insert(const_iterator hint, const value_type &value)
Definition robin_map.h:250
std::pair< iterator, bool > insert(const value_type &value)
Definition robin_map.h:239
size_type count(const Key &key) const
Definition robin_map.h:450
void clear() noexcept
Definition robin_map.h:237
T mapped_type
Definition robin_map.h:125
robin_map(size_type bucket_count, const Allocator &alloc)
Definition robin_map.h:151
size_type count(const Key &key, std::size_t precalculated_hash) const
Definition robin_map.h:457
typename ht::hasher hasher
Definition robin_map.h:129
size_type max_size() const noexcept
Definition robin_map.h:232
std::pair< iterator, iterator > equal_range(const K &key, std::size_t precalculated_hash)
Definition robin_map.h:632
size_type count(const K &key) const
Definition robin_map.h:469
const_iterator find(const Key &key, std::size_t precalculated_hash) const
Definition robin_map.h:502
iterator find(const Key &key, std::size_t precalculated_hash)
Definition robin_map.h:493
typename ht::allocator_type allocator_type
Definition robin_map.h:131
T & operator[](const Key &key)
Definition robin_map.h:447
iterator erase(const_iterator pos)
Definition robin_map.h:341
bool empty() const noexcept
Definition robin_map.h:230
typename ht::pointer pointer
Definition robin_map.h:134
const_iterator find(const K &key) const
Definition robin_map.h:535
key_equal key_eq() const
Definition robin_map.h:689
size_type erase(const key_type &key)
Definition robin_map.h:343
iterator mutable_iterator(const_iterator pos)
Definition robin_map.h:698
robin_map(std::initializer_list< value_type > init, size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition robin_map.h:198
size_type bucket_count() const
Definition robin_map.h:659
std::pair< iterator, iterator > equal_range(const Key &key)
Definition robin_map.h:588
std::pair< iterator, bool > try_emplace(const key_type &k, Args &&...args)
Definition robin_map.h:319
T & at(const Key &key, std::size_t precalculated_hash)
Definition robin_map.h:391
bool contains(const K &key) const
Definition robin_map.h:571
bool contains(const Key &key) const
Definition robin_map.h:552
robin_map(InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc)
Definition robin_map.h:173
typename ht::difference_type difference_type
Definition robin_map.h:128
size_type erase(const key_type &key, std::size_t precalculated_hash)
Definition robin_map.h:350
iterator begin() noexcept
Definition robin_map.h:219
friend void swap(robin_map &lhs, robin_map &rhs)
Definition robin_map.h:774
iterator erase(const_iterator first, const_iterator last)
Definition robin_map.h:342
void rehash(size_type my_count)
Definition robin_map.h:682
bool contains(const K &key, std::size_t precalculated_hash) const
Definition robin_map.h:583
size_type max_bucket_count() const
Definition robin_map.h:660
const T & at(const K &key) const
Definition robin_map.h:433
allocator_type get_allocator() const
Definition robin_map.h:214
std::pair< iterator, iterator > equal_range(const K &key)
Definition robin_map.h:620
friend bool operator==(const robin_map &lhs, const robin_map &rhs)
Definition robin_map.h:753
const T & at(const Key &key) const
Definition robin_map.h:396
void insert(std::initializer_list< value_type > ilist)
Definition robin_map.h:269
typename ht::key_type key_type
Definition robin_map.h:124
iterator find(const K &key)
Definition robin_map.h:514
void reserve(size_type my_count)
Definition robin_map.h:683
hasher hash_function() const
Definition robin_map.h:688
void insert(InputIt first, InputIt last)
Definition robin_map.h:267
iterator insert_or_assign(const_iterator hint, const key_type &k, M &&obj)
Definition robin_map.h:284
const_iterator find(const Key &key) const
Definition robin_map.h:498
iterator insert(const_iterator hint, P &&value)
Definition robin_map.h:257
const_iterator begin() const noexcept
Definition robin_map.h:220
size_type erase(const K &key, std::size_t precalculated_hash)
Definition robin_map.h:374
void min_load_factor(float ml)
Definition robin_map.h:679
typename ht::const_reference const_reference
Definition robin_map.h:133
float max_load_factor() const
Definition robin_map.h:668
bool contains(const Key &key, std::size_t precalculated_hash) const
Definition robin_map.h:559
robin_map()
Definition robin_map.h:143
iterator try_emplace(const_iterator hint, const key_type &k, Args &&...args)
Definition robin_map.h:330
const_iterator cend() const noexcept
Definition robin_map.h:225
static robin_map deserialize(Deserializer &deserializer, bool hash_compatible=false)
Definition robin_map.h:745
robin_map & operator=(std::initializer_list< value_type > ilist)
Definition robin_map.h:204
typename ht::key_equal key_equal
Definition robin_map.h:130
typename ht::const_iterator const_iterator
Definition robin_map.h:137
iterator find(const Key &key)
Definition robin_map.h:486
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t precalculated_hash) const
Definition robin_map.h:650
std::pair< iterator, bool > emplace(Args &&...args)
Definition robin_map.h:301
T & at(const K &key)
Definition robin_map.h:412
void swap(robin_map &other)
Definition robin_map.h:379
size_type size() const noexcept
Definition robin_map.h:231
iterator end() noexcept
Definition robin_map.h:223
std::pair< iterator, bool > insert(value_type &&value)
Definition robin_map.h:248
void max_load_factor(float ml)
Definition robin_map.h:680
const T & at(const Key &key, std::size_t precalculated_hash) const
Definition robin_map.h:400
robin_map(size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
Definition robin_map.h:145
const T & at(const K &key, std::size_t precalculated_hash) const
Definition robin_map.h:442
const_iterator find(const K &key, std::size_t precalculated_hash) const
Definition robin_map.h:547
iterator emplace_hint(const_iterator hint, Args &&...args)
Definition robin_map.h:313
robin_map(std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc)
Definition robin_map.h:192
size_type erase(const K &key)
Definition robin_map.h:362
iterator insert_or_assign(const_iterator hint, key_type &&k, M &&obj)
Definition robin_map.h:289
size_type count(const K &key, std::size_t precalculated_hash) const
Definition robin_map.h:481
std::pair< const_iterator, const_iterator > equal_range(const Key &key) const
Definition robin_map.h:600
T & operator[](Key &&key)
Definition robin_map.h:448
std::pair< const_iterator, const_iterator > equal_range(const Key &key, std::size_t precalculated_hash) const
Definition robin_map.h:607
robin_map(size_type bucket_count, const Hash &hash, const Allocator &alloc)
Definition robin_map.h:156
const_iterator cbegin() const noexcept
Definition robin_map.h:221
typename ht::size_type size_type
Definition robin_map.h:127
iterator try_emplace(const_iterator hint, key_type &&k, Args &&...args)
Definition robin_map.h:335
void serialize(Serializer &serializer) const
Definition robin_map.h:713
const_iterator end() const noexcept
Definition robin_map.h:224
std::pair< iterator, bool > insert_or_assign(const key_type &k, M &&obj)
Definition robin_map.h:274
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition robin_map.h:641
T & at(const K &key, std::size_t precalculated_hash)
Definition robin_map.h:424
iterator erase(iterator pos)
Definition robin_map.h:340
std::pair< iterator, bool > insert_or_assign(key_type &&k, M &&obj)
Definition robin_map.h:279
robin_map(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 robin_map.h:164
iterator insert(const_iterator hint, value_type &&value)
Definition robin_map.h:262
std::pair< iterator, iterator > equal_range(const Key &key, std::size_t precalculated_hash)
Definition robin_map.h:595
ht m_ht
Definition robin_map.h:777
robin_map(const Allocator &alloc)
Definition robin_map.h:161
robin_map(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 robin_map.h:185
typename ht::iterator iterator
Definition robin_map.h:136
iterator find(const K &key, std::size_t precalculated_hash)
Definition robin_map.h:526
Definition bhopscotch_map.h:38
Definition robin_hash.h:54