24#ifndef TSL_ROBIN_HASH_H
25#define TSL_ROBIN_HASH_H
67 template <std::
size_t GrowthFactor>
73 template <
class T>
const T &
clamp(
const T &v,
const T &lo,
const T &hi)
75 return std::min(hi, std::max(lo, v));
78 template <
typename T,
typename U>
79 static T
numeric_cast(U value,
const char *error_message =
"numeric_cast() failed.")
81 T ret =
static_cast<T
>(value);
82 if (
static_cast<U
>(ret) != value) {
86 const bool is_same_signedness = (std::is_unsigned<T>::value && std::is_unsigned<U>::value) ||
87 (std::is_signed<T>::value && std::is_signed<U>::value);
88 if (!is_same_signedness && (ret < T{}) != (value < U{})) {
95 template <
class T,
class Deserializer>
static T
deserialize_value(Deserializer &deserializer)
99#if defined(_MSC_VER) && _MSC_VER < 1910
100 return deserializer.Deserializer::operator()<T>();
102 return deserializer.Deserializer::template operator()<T>();
112 static_assert(std::numeric_limits<slz_size_type>::max() >=
113 std::numeric_limits<std::size_t>::max(),
114 "slz_size_type must be >= std::size_t");
168 template <
typename ValueType,
bool StoreHash>
192 std::is_nothrow_copy_constructible<value_type>::value)
196 if (!other.empty()) {
197 ::new (static_cast<void *>(std::addressof(m_value))) value_type(other.value());
198 m_dist_from_ideal_bucket = other.m_dist_from_ideal_bucket;
209 std::is_nothrow_move_constructible<value_type>::value)
214 if (!other.empty()) {
215 ::new (static_cast<void *>(std::addressof(m_value))) value_type(std::move(other.value()));
216 m_dist_from_ideal_bucket = other.m_dist_from_ideal_bucket;
222 std::is_nothrow_copy_constructible<value_type>::value)
224 if (
this != &other) {
227 bucket_hash::operator=(other);
228 if (!other.empty()) {
259#if defined(__cplusplus) && __cplusplus >= 201703L
269#if defined(__cplusplus) && __cplusplus >= 201703L
270 return *std::launder(
reinterpret_cast<const value_type *
>(std::addressof(
m_value)));
282 template <
typename... Args>
289 ::new (
static_cast<void *
>(std::addressof(
m_value)))
290 value_type(std::forward<Args>(value_type_args)...);
327 value().~value_type();
333 static_assert(DIST_FROM_IDEAL_BUCKET_LIMIT <= std::numeric_limits<distance_type>::max() - 1,
334 "DIST_FROM_IDEAL_BUCKET_LIMIT must be <= "
335 "std::numeric_limits<distance_type>::max() - 1.");
362 template <
class ValueType,
class KeySelect,
class ValueSelect,
class Hash,
class KeyEqual,
363 class Allocator,
bool StoreHash,
class GrowthPolicy>
364 class robin_hash :
private Hash,
private KeyEqual,
private GrowthPolicy
367 template <
typename U>
368 using has_mapped_type =
typename std::integral_constant<bool, !std::is_same<U, void>::value>;
370 static_assert(
noexcept(std::declval<GrowthPolicy>().bucket_for_hash(std::size_t(0))),
371 "GrowthPolicy::bucket_for_hash must be noexcept.");
372 static_assert(
noexcept(std::declval<GrowthPolicy>().clear()),
373 "GrowthPolicy::clear must be noexcept.");
405 (!std::is_arithmetic<key_type>::value || !std::is_same<Hash, std::hash<key_type>>::value));
428 (
bucket_count - 1) <= std::numeric_limits<truncated_hash_type>::max();
440 typename std::allocator_traits<allocator_type>::template rebind_alloc<bucket_entry>;
461 typename std::conditional<IsConst, const bucket_entry *, bucket_entry *>::type;
475 template <
bool TIsConst = IsConst, typename std::enable_if<TIsConst>::type * =
nullptr>
487 template <
class U = ValueSelect,
488 typename std::enable_if<has_mapped_type<U>::value && IsConst>::type * =
nullptr>
489 const typename U::value_type &
value()
const
494 template <
class U = ValueSelect,
495 typename std::enable_if<has_mapped_type<U>::value && !IsConst>::type * =
nullptr>
496 typename U::value_type &
value()
const
535 return !(lhs == rhs);
543#if defined(__cplusplus) && __cplusplus >= 201402L
547 : Hash(my_hash), KeyEqual(equal), GrowthPolicy(
bucket_count),
610 std::is_nothrow_move_constructible<Hash>::value &&
611 std::is_nothrow_move_constructible<KeyEqual>::value &&
612 std::is_nothrow_move_constructible<GrowthPolicy>::value &&
613 std::is_nothrow_move_constructible<buckets_container_type>::value)
614 : Hash(std::move(static_cast<Hash &>(other))),
615 KeyEqual(std::move(static_cast<KeyEqual &>(other))),
616 GrowthPolicy(std::move(static_cast<GrowthPolicy &>(other))),
625 other.clear_and_shrink();
630 if (&other !=
this) {
631 Hash::operator=(other);
632 KeyEqual::operator=(other);
633 GrowthPolicy::operator=(other);
654 other.clear_and_shrink();
719 template <
typename P> std::pair<iterator, bool>
insert(P &&value)
721 return insert_impl(KeySelect()(value), std::forward<P>(value));
726 if (hint !=
cend() &&
compare_keys(KeySelect()(*hint), KeySelect()(value))) {
730 return insert(std::forward<P>(value)).first;
733 template <
class InputIt>
void insert(InputIt first, InputIt last)
735 if (std::is_base_of<std::forward_iterator_tag,
736 typename std::iterator_traits<InputIt>::iterator_category>::value) {
737 const auto nb_elements_insert = std::distance(first, last);
741 if (nb_elements_insert > 0 && nb_free_buckets <
size_type(nb_elements_insert)) {
746 for (; first != last; ++first) {
753 auto it =
try_emplace(std::forward<K>(key), std::forward<M>(obj));
755 it.first.value() = std::forward<M>(obj);
765 it.value() = std::forward<M>(obj);
773 template <
class... Args> std::pair<iterator, bool>
emplace(Args &&...args)
783 template <
class K,
class... Args> std::pair<iterator, bool>
try_emplace(K &&key, Args &&...args)
785 return insert_impl(key, std::piecewise_construct, std::forward_as_tuple(std::forward<K>(key)),
786 std::forward_as_tuple(std::forward<Args>(args)...));
789 template <
class K,
class... Args>
796 return try_emplace(std::forward<K>(key), std::forward<Args>(args)...).first;
831 for (
auto it = first_mutable.m_bucket; it != last_mutable.m_bucket; ++it) {
838 if (last_mutable ==
end()) {
847 auto icloser_bucket =
static_cast<std::size_t
>(first_mutable.m_bucket -
m_buckets);
848 auto ito_move_closer_value =
static_cast<std::size_t
>(last_mutable.m_bucket -
m_buckets);
851 const std::size_t ireturn_bucket =
852 ito_move_closer_value -
853 std::min(ito_move_closer_value - icloser_bucket,
854 std::size_t(
m_buckets[ito_move_closer_value].dist_from_ideal_bucket()));
857 m_buckets[ito_move_closer_value].dist_from_ideal_bucket() > 0) {
859 ito_move_closer_value -
860 std::min(ito_move_closer_value - icloser_bucket,
861 std::size_t(
m_buckets[ito_move_closer_value].dist_from_ideal_bucket()));
866 (ito_move_closer_value - icloser_bucket));
868 new_distance,
m_buckets[ito_move_closer_value].truncated_hash(),
869 std::move(
m_buckets[ito_move_closer_value].value()));
873 ++ito_move_closer_value;
885 auto it =
find(key, my_hash);
901 swap(
static_cast<Hash &
>(*
this),
static_cast<Hash &
>(other));
902 swap(
static_cast<KeyEqual &
>(*
this),
static_cast<KeyEqual &
>(other));
903 swap(
static_cast<GrowthPolicy &
>(*
this),
static_cast<GrowthPolicy &
>(other));
918 template <
class K,
class U = ValueSelect,
919 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
920 typename U::value_type &
at(
const K &key)
925 template <
class K,
class U = ValueSelect,
926 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
927 typename U::value_type &
at(
const K &key, std::size_t my_hash)
929 return const_cast<typename U::value_type &
>(
930 static_cast<const robin_hash *
>(
this)->
at(key, my_hash));
933 template <
class K,
class U = ValueSelect,
934 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
935 const typename U::value_type &
at(
const K &key)
const
940 template <
class K,
class U = ValueSelect,
941 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
942 const typename U::value_type &
at(
const K &key, std::size_t my_hash)
const
944 auto it =
find(key, my_hash);
953 template <
class K,
class U = ValueSelect,
954 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
957 return try_emplace(std::forward<K>(key)).first.value();
991 template <
class K>
bool contains(
const K &key, std::size_t my_hash)
const
993 return count(key, my_hash) != 0;
996 template <
class K> std::pair<iterator, iterator>
equal_range(
const K &key)
1001 template <
class K> std::pair<iterator, iterator>
equal_range(
const K &key, std::size_t my_hash)
1004 return std::make_pair(it, (it ==
end()) ? it : std::next(it));
1007 template <
class K> std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const
1013 std::pair<const_iterator, const_iterator>
equal_range(
const K &key, std::size_t my_hash)
const
1016 return std::make_pair(it, (it ==
cend()) ? it : std::next(it));
1026 return std::min(GrowthPolicy::max_bucket_count(),
m_buckets_data.max_size());
1083 template <
class Serializer>
void serialize(Serializer &serializer)
const
1088 template <
class Deserializer>
void deserialize(Deserializer &deserializer,
bool hash_compatible)
1094 template <
class K> std::size_t
hash_key(
const K &key)
const {
return Hash::operator()(key); }
1096 template <
class K1,
class K2>
bool compare_keys(
const K1 &key1,
const K2 &key2)
const
1098 return KeyEqual::operator()(key1, key2);
1103 const std::size_t bucket = GrowthPolicy::bucket_for_hash(my_hash);
1109 template <
class U = GrowthPolicy,
1110 typename std::enable_if<is_power_of_two_policy<U>::value>::type * =
nullptr>
1115 return (index + 1) & this->m_mask;
1118 template <
class U = GrowthPolicy,
1119 typename std::enable_if<!is_power_of_two_policy<U>::value>::type * =
nullptr>
1138 while (dist_from_ideal_bucket <=
m_buckets[ibucket].dist_from_ideal_bucket()) {
1146 dist_from_ideal_bucket++;
1167 while (
m_buckets[ibucket].dist_from_ideal_bucket() > 0) {
1172 new_distance,
m_buckets[ibucket].truncated_hash(),
1176 previous_ibucket = ibucket;
1181 template <
class K,
class... Args>
1182 std::pair<iterator, bool>
insert_impl(
const K &key, Args &&...value_type_args)
1184 const std::size_t my_hash =
hash_key(key);
1189 while (dist_from_ideal_bucket <=
m_buckets[ibucket].dist_from_ideal_bucket()) {
1196 dist_from_ideal_bucket++;
1201 dist_from_ideal_bucket = 0;
1203 while (dist_from_ideal_bucket <=
m_buckets[ibucket].dist_from_ideal_bucket()) {
1205 dist_from_ideal_bucket++;
1212 std::forward<Args>(value_type_args)...);
1216 std::forward<Args>(value_type_args)...);
1227 template <
class... Args>
1231 value_type value(std::forward<Args>(value_type_args)...);
1255 dist_from_ideal_bucket++;
1258 if (dist_from_ideal_bucket >
m_buckets[ibucket].dist_from_ideal_bucket()) {
1271 dist_from_ideal_bucket++;
1280 robin_hash new_table(my_count,
static_cast<Hash &
>(*
this),
static_cast<KeyEqual &
>(*
this),
1285 if (bucket.empty()) {
1289 const std::size_t my_hash = use_stored_hash
1290 ? bucket.truncated_hash()
1291 : new_table.
hash_key(KeySelect()(bucket.value()));
1295 std::move(bucket.value()));
1299 new_table.
swap(*
this);
1304 GrowthPolicy::clear();
1318 if (dist_from_ideal_bucket >
m_buckets[ibucket].dist_from_ideal_bucket()) {
1329 dist_from_ideal_bucket++;
1367 serializer(version);
1372 const auto hash_stored_for_bucket =
static_cast<std::int16_t
>(
STORE_HASH);
1373 serializer(hash_stored_for_bucket);
1376 serializer(nb_elements);
1388 if (bucket.empty()) {
1390 serializer(empty_bucket);
1393 const std::int16_t dist_from_ideal_bucket = bucket.dist_from_ideal_bucket();
1394 serializer(dist_from_ideal_bucket);
1396 const std::uint32_t truncated_hash = bucket.truncated_hash();
1397 serializer(truncated_hash);
1399 serializer(bucket.value());
1404 template <
class Deserializer>
1414 "The protocol version header is invalid.");
1417 const bool hash_stored_for_bucket =
1419 if (hash_compatible &&
STORE_HASH != hash_stored_for_bucket) {
1421 "Can't deserialize a map with a different StoreHash "
1422 "than the one used during the serialization when "
1423 "hash compatibility is used");
1433 "Invalid min_load_factor. Check that the serializer "
1434 "and deserializer support floats correctly as they "
1435 "can be converted implicitly to ints.");
1440 "Invalid max_load_factor. Check that the serializer "
1441 "and deserializer support floats correctly as they "
1442 "can be converted implicitly to ints.");
1448 if (bucket_count_ds == 0) {
1453 if (!hash_compatible) {
1455 for (
slz_size_type ibucket = 0; ibucket < bucket_count_ds; ibucket++) {
1459 if (hash_stored_for_bucket) {
1478 "though hash_compatible is true.");
1491 if (hash_stored_for_bucket) {
1496 bucket.set_value_of_empty_bucket(dist_from_ideal_bucket, truncated_hash,
1519 "MINIMUM_MAX_LOAD_FACTOR should be < MAXIMUM_MAX_LOAD_FACTOR");
1521 "MINIMUM_MIN_LOAD_FACTOR should be < MAXIMUM_MIN_LOAD_FACTOR");
1523 "MAXIMUM_MIN_LOAD_FACTOR should be < MINIMUM_MAX_LOAD_FACTOR");
1539 return &empty_bucket;
bool bucket_hash_equal(std::size_t my_hash) const noexcept
Definition robin_hash.h:136
void set_hash(truncated_hash_type my_hash) noexcept
Definition robin_hash.h:144
truncated_hash_type m_hash
Definition robin_hash.h:147
truncated_hash_type truncated_hash() const noexcept
Definition robin_hash.h:141
Definition robin_hash.h:123
truncated_hash_type truncated_hash() const noexcept
Definition robin_hash.h:127
bool bucket_hash_equal(std::size_t) const noexcept
Definition robin_hash.h:125
void set_hash(truncated_hash_type) noexcept
Definition robin_hash.h:130
Definition robin_hash.h:170
bucket_entry(bool last_bucket) noexcept
Definition robin_hash.h:184
std::int16_t distance_type
Definition robin_hash.h:175
void clear() noexcept
Definition robin_hash.h:243
bucket_entry & operator=(bucket_entry &&)=delete
bool empty() const noexcept
Definition robin_hash.h:251
bucket_entry(const bucket_entry &other) noexcept(std::is_nothrow_copy_constructible< value_type >::value)
Definition robin_hash.h:191
bucket_entry & operator=(const bucket_entry &other) noexcept(std::is_nothrow_copy_constructible< value_type >::value)
Definition robin_hash.h:221
unsigned char m_value[sizeof(value_type)]
Definition robin_hash.h:340
ValueType value_type
Definition robin_hash.h:174
void set_value_of_empty_bucket(distance_type dist_from_ideal_bucket, truncated_hash_type my_hash, Args &&...value_type_args)
Definition robin_hash.h:283
~bucket_entry() noexcept
Definition robin_hash.h:241
bucket_entry() noexcept
Definition robin_hash.h:177
static truncated_hash_type truncate_hash(std::size_t my_hash) noexcept
Definition robin_hash.h:318
distance_type m_dist_from_ideal_bucket
Definition robin_hash.h:338
bool last_bucket() const noexcept
Definition robin_hash.h:278
distance_type dist_from_ideal_bucket() const noexcept
Definition robin_hash.h:276
bool m_last_bucket
Definition robin_hash.h:339
bucket_entry_hash< StoreHash > bucket_hash
Definition robin_hash.h:171
void destroy_value() noexcept
Definition robin_hash.h:324
value_type & value() noexcept
Definition robin_hash.h:256
void swap_with_value_in_bucket(distance_type &dist_from_ideal_bucket, truncated_hash_type &my_hash, value_type &value)
Definition robin_hash.h:297
const value_type & value() const noexcept
Definition robin_hash.h:266
bucket_entry(bucket_entry &&other) noexcept(std::is_nothrow_move_constructible< value_type >::value)
Definition robin_hash.h:208
static const distance_type DIST_FROM_IDEAL_BUCKET_LIMIT
Definition robin_hash.h:332
static const distance_type EMPTY_MARKER_DIST_FROM_IDEAL_BUCKET
Definition robin_hash.h:331
void set_as_last_bucket() noexcept
Definition robin_hash.h:280
Definition robin_hash.h:456
const robin_hash::key_type & key() const
Definition robin_hash.h:485
robin_iterator() noexcept=default
robin_iterator & operator=(const robin_iterator &other)=default
reference operator*() const
Definition robin_hash.h:501
value_type & reference
Definition robin_hash.h:469
const U::value_type & value() const
Definition robin_hash.h:489
robin_iterator operator++(int)
Definition robin_hash.h:520
U::value_type & value() const
Definition robin_hash.h:496
typename std::conditional< IsConst, const bucket_entry *, bucket_entry * >::type bucket_entry_ptr
Definition robin_hash.h:460
const typename robin_hash::value_type value_type
Definition robin_hash.h:467
value_type * pointer
Definition robin_hash.h:470
robin_iterator(const robin_iterator &other)=default
robin_iterator(bucket_entry_ptr bucket) noexcept
Definition robin_hash.h:463
bucket_entry_ptr m_bucket
Definition robin_hash.h:539
robin_iterator & operator=(robin_iterator &&other)=default
robin_iterator(robin_iterator &&other)=default
friend bool operator!=(const robin_iterator &lhs, const robin_iterator &rhs)
Definition robin_hash.h:533
std::forward_iterator_tag iterator_category
Definition robin_hash.h:466
std::ptrdiff_t difference_type
Definition robin_hash.h:468
robin_iterator & operator++()
Definition robin_hash.h:505
pointer operator->() const
Definition robin_hash.h:503
friend bool operator==(const robin_iterator &lhs, const robin_iterator &rhs)
Definition robin_hash.h:528
Definition robin_hash.h:365
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t my_hash) const
Definition robin_hash.h:1013
key_equal key_eq() const
Definition robin_hash.h:1073
static const size_type DEFAULT_INIT_BUCKETS_SIZE
Definition robin_hash.h:1508
size_type m_nb_elements
Definition robin_hash.h:1562
static bool USE_STORED_HASH_ON_REHASH(size_type bucket_count)
Definition robin_hash.h:420
iterator find(const K &key)
Definition robin_hash.h:972
Hash hasher
Definition robin_hash.h:382
size_type m_bucket_count
Definition robin_hash.h:1560
const value_type * const_pointer
Definition robin_hash.h:388
iterator begin() noexcept
Definition robin_hash.h:664
const_iterator find(const K &key) const
Definition robin_hash.h:979
void deserialize_impl(Deserializer &deserializer, bool hash_compatible)
Definition robin_hash.h:1405
bucket_entry * static_empty_bucket_ptr() noexcept
Definition robin_hash.h:1535
static constexpr float DEFAULT_MIN_LOAD_FACTOR
Definition robin_hash.h:1514
void min_load_factor(float ml)
Definition robin_hash.h:1045
std::size_t next_bucket(std::size_t index) const noexcept
Definition robin_hash.h:1111
bool m_try_shrink_on_next_insert
Definition robin_hash.h:1578
static constexpr bool STORE_HASH
Definition robin_hash.h:398
bool m_grow_on_next_insert
Definition robin_hash.h:1569
static constexpr float MAXIMUM_MAX_LOAD_FACTOR
Definition robin_hash.h:1512
static const slz_size_type SERIALIZATION_PROTOCOL_VERSION
Definition robin_hash.h:1529
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
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition robin_hash.h:1007
iterator insert_or_assign(const_iterator hint, K &&key, M &&obj)
Definition robin_hash.h:761
void clear_and_shrink() noexcept
Definition robin_hash.h:1302
hasher hash_function() const
Definition robin_hash.h:1071
std::size_t hash_key(const K &key) const
Definition robin_hash.h:1094
iterator erase(const_iterator first, const_iterator last)
Definition robin_hash.h:823
value_type * pointer
Definition robin_hash.h:387
value_type & reference
Definition robin_hash.h:385
void insert_value_on_rehash(std::size_t ibucket, distance_type dist_from_ideal_bucket, truncated_hash_type my_hash, value_type &&value)
Definition robin_hash.h:1314
iterator find_impl(const K &key, std::size_t my_hash)
Definition robin_hash.h:1128
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
std::pair< iterator, iterator > equal_range(const K &key, std::size_t my_hash)
Definition robin_hash.h:1001
void serialize(Serializer &serializer) const
Definition robin_hash.h:1083
robin_hash(size_type bucket_count, const Hash &my_hash, const KeyEqual &equal, const Allocator &alloc, float min_load_factor=DEFAULT_MIN_LOAD_FACTOR, float max_load_factor=DEFAULT_MAX_LOAD_FACTOR)
Definition robin_hash.h:575
bool contains(const K &key) const
Definition robin_hash.h:989
const_iterator find(const K &key, std::size_t my_hash) const
Definition robin_hash.h:984
robin_hash & operator=(const robin_hash &other)
Definition robin_hash.h:628
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
const U::value_type & at(const K &key) const
Definition robin_hash.h:935
void insert_value(std::size_t ibucket, distance_type dist_from_ideal_bucket, truncated_hash_type my_hash, value_type &&value)
Definition robin_hash.h:1235
static constexpr float MAXIMUM_MIN_LOAD_FACTOR
Definition robin_hash.h:1516
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
U::value_type & operator[](K &&key)
Definition robin_hash.h:955
size_type max_size() const noexcept
Definition robin_hash.h:699
const_iterator end() const noexcept
Definition robin_hash.h:688
const_iterator cbegin() const noexcept
Definition robin_hash.h:676
void rehash_impl(size_type my_count)
Definition robin_hash.h:1278
allocator_type get_allocator() const
Definition robin_hash.h:659
iterator find(const K &key, std::size_t my_hash)
Definition robin_hash.h:974
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
robin_hash & operator=(robin_hash &&other)
Definition robin_hash.h:651
void erase_from_bucket(iterator pos)
Definition robin_hash.h:1152
iterator erase(const_iterator pos)
Definition robin_hash.h:821
size_type bucket_count() const
Definition robin_hash.h:1022
float m_min_load_factor
Definition robin_hash.h:1566
void deserialize(Deserializer &deserializer, bool hash_compatible)
Definition robin_hash.h:1088
const U::value_type & at(const K &key, std::size_t my_hash) const
Definition robin_hash.h:942
typename std::allocator_traits< allocator_type >::template rebind_alloc< bucket_entry > buckets_allocator
Definition robin_hash.h:439
void swap(robin_hash &other)
Definition robin_hash.h:897
size_type count(const K &key) const
Definition robin_hash.h:960
std::vector< bucket_entry, buckets_allocator > buckets_container_type
Definition robin_hash.h:441
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
bucket_entry * m_buckets
Definition robin_hash.h:1554
const_iterator find_impl(const K &key, std::size_t my_hash) const
Definition robin_hash.h:1133
void max_load_factor(float ml)
Definition robin_hash.h:1050
static constexpr float DEFAULT_MAX_LOAD_FACTOR
Definition robin_hash.h:1510
U::value_type & at(const K &key, std::size_t my_hash)
Definition robin_hash.h:927
void insert_value_impl(std::size_t ibucket, distance_type dist_from_ideal_bucket, truncated_hash_type my_hash, value_type &value)
Definition robin_hash.h:1249
static constexpr float MINIMUM_MAX_LOAD_FACTOR
Definition robin_hash.h:1511
robin_hash(const robin_hash &other)
Definition robin_hash.h:598
std::size_t bucket_for_hash(std::size_t my_hash) const
Definition robin_hash.h:1101
void insert(InputIt first, InputIt last)
Definition robin_hash.h:733
size_type size() const noexcept
Definition robin_hash.h:697
float m_max_load_factor
Definition robin_hash.h:1567
size_type erase(const K &key)
Definition robin_hash.h:881
void insert_value(std::size_t ibucket, distance_type dist_from_ideal_bucket, truncated_hash_type my_hash, Args &&...value_type_args)
Definition robin_hash.h:1228
std::pair< iterator, bool > insert_impl(const K &key, Args &&...value_type_args)
Definition robin_hash.h:1182
size_type m_load_threshold
Definition robin_hash.h:1564
typename bucket_entry::distance_type distance_type
Definition robin_hash.h:437
bool rehash_on_extreme_load(distance_type curr_dist_from_ideal_bucket)
Definition robin_hash.h:1341
size_type erase(const K &key, std::size_t my_hash)
Definition robin_hash.h:883
void serialize_impl(Serializer &serializer) const
Definition robin_hash.h:1364
typename std::integral_constant< bool, !std::is_same< U, void >::value > has_mapped_type
Definition robin_hash.h:368
bool contains(const K &key, std::size_t my_hash) const
Definition robin_hash.h:991
std::pair< iterator, iterator > equal_range(const K &key)
Definition robin_hash.h:996
bool compare_keys(const K1 &key1, const K2 &key2) const
Definition robin_hash.h:1096
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
static constexpr float MINIMUM_MIN_LOAD_FACTOR
Definition robin_hash.h:1515
const_iterator begin() const noexcept
Definition robin_hash.h:674
iterator mutable_iterator(const_iterator pos)
Definition robin_hash.h:1078
Allocator allocator_type
Definition robin_hash.h:384
static constexpr bool USE_STORED_HASH_ON_LOOKUP
Definition robin_hash.h:412
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
size_type count(const K &key, std::size_t my_hash) const
Definition robin_hash.h:962
buckets_container_type m_buckets_data
Definition robin_hash.h:1543
robin_hash(robin_hash &&other) noexcept(std::is_nothrow_move_constructible< Hash >::value &&std::is_nothrow_move_constructible< KeyEqual >::value &&std::is_nothrow_move_constructible< GrowthPolicy >::value &&std::is_nothrow_move_constructible< buckets_container_type >::value)
Definition robin_hash.h:609
Definition robin_growth_policy.h:84
Definition robin_hash.h:46
static T numeric_cast(U value, const char *error_message="numeric_cast() failed.")
Definition robin_hash.h:79
std::uint64_t slz_size_type
Definition robin_hash.h:111
static T deserialize_value(Deserializer &deserializer)
Definition robin_hash.h:95
std::uint32_t truncated_hash_type
Definition robin_hash.h:116
const T & clamp(const T &v, const T &lo, const T &hi)
Definition robin_hash.h:73
Definition bhopscotch_map.h:38
#define TSL_RH_LIKELY(exp)
Definition robin_growth_policy.h:69
#define TSL_RH_THROW_OR_TERMINATE(ex, msg)
Definition robin_growth_policy.h:62
#define tsl_rh_assert(expr)
Definition robin_growth_policy.h:41
#define TSL_RH_UNUSED(x)
Definition robin_growth_policy.h:72
Definition robin_hash.h:54
Definition robin_hash.h:64
Definition robin_hash.h:49
void type
Definition robin_hash.h:50