24#ifndef TSL_ROBIN_HASH_H
25#define TSL_ROBIN_HASH_H
46 namespace detail_robin_hash {
67 template <std::
size_t GrowthFactor>
74 template <
class T>
const T &
clamp(
const T &v,
const T &lo,
const T &hi)
76 return std::min(hi, std::max(lo, v));
79 template <
typename T,
typename U>
80 static T
numeric_cast(U value,
const char *error_message =
"numeric_cast() failed.")
82 T ret =
static_cast<T
>(value);
83 if (
static_cast<U
>(ret) != value) {
87 const bool is_same_signedness = (std::is_unsigned<T>::value && std::is_unsigned<U>::value) ||
88 (std::is_signed<T>::value && std::is_signed<U>::value);
89 if (!is_same_signedness && (ret < T{}) != (value < U{})) {
96 template <
class T,
class Deserializer>
static T
deserialize_value(Deserializer &deserializer)
100#if defined(_MSC_VER) && _MSC_VER < 1910
101 return deserializer.Deserializer::operator()<T>();
103 return deserializer.Deserializer::template operator()<T>();
113 static_assert(std::numeric_limits<slz_size_type>::max() >=
114 std::numeric_limits<std::size_t>::max(),
115 "slz_size_type must be >= std::size_t");
169 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;
208 std::is_nothrow_move_constructible<value_type>::value)
213 if (!other.empty()) {
214 ::new (static_cast<void *>(std::addressof(m_value))) value_type(std::move(other.value()));
215 m_dist_from_ideal_bucket = other.m_dist_from_ideal_bucket;
220 std::is_nothrow_copy_constructible<value_type>::value)
222 if (
this != &other) {
225 bucket_hash::operator=(other);
226 if (!other.empty()) {
272 template <
typename... Args>
279 ::new (
static_cast<void *
>(std::addressof(
m_value)))
280 value_type(std::forward<Args>(value_type_args)...);
316 value().~value_type();
322 static_assert(DIST_FROM_IDEAL_BUCKET_LIMIT <= std::numeric_limits<distance_type>::max() - 1,
323 "DIST_FROM_IDEAL_BUCKET_LIMIT must be <= "
324 "std::numeric_limits<distance_type>::max() - 1.");
353 template <
class ValueType,
class KeySelect,
class ValueSelect,
class Hash,
class KeyEqual,
354 class Allocator,
bool StoreHash,
class GrowthPolicy>
355 class robin_hash :
private Hash,
private KeyEqual,
private GrowthPolicy
358 template <
typename U>
359 using has_mapped_type =
typename std::integral_constant<bool, !std::is_same<U, void>::value>;
361 static_assert(
noexcept(std::declval<GrowthPolicy>().bucket_for_hash(std::size_t(0))),
362 "GrowthPolicy::bucket_for_hash must be noexcept.");
363 static_assert(
noexcept(std::declval<GrowthPolicy>().clear()),
364 "GrowthPolicy::clear must be noexcept.");
395 (!std::is_arithmetic<key_type>::value ||
396 !std::is_same<Hash, std::hash<key_type>>::value));
419 return (
bucket_count - 1) <= std::numeric_limits<truncated_hash_type>::max();
431 typename std::allocator_traits<allocator_type>::template rebind_alloc<bucket_entry>;
452 typename std::conditional<IsConst, const bucket_entry *, bucket_entry *>::type;
466 template <bool TIsConst = IsConst, typename std::enable_if<TIsConst>::type * =
nullptr>
478 template <
class U = ValueSelect,
479 typename std::enable_if<has_mapped_type<U>::value && IsConst>::type * =
nullptr>
480 const typename U::value_type &
value()
const
485 template <
class U = ValueSelect,
486 typename std::enable_if<has_mapped_type<U>::value && !IsConst>::type * =
nullptr>
487 typename U::value_type &
value()
const
526 return !(lhs == rhs);
534#if defined(__cplusplus) && __cplusplus >= 201402L
538 : Hash(my_hash), KeyEqual(equal), GrowthPolicy(
bucket_count),
543 "The map exceeds its maximum bucket count.");
608 std::is_nothrow_move_constructible<Hash>::value &&
609 std::is_nothrow_move_constructible<KeyEqual>::value &&
610 std::is_nothrow_move_constructible<GrowthPolicy>::value &&
611 std::is_nothrow_move_constructible<buckets_container_type>::value)
612 : Hash(std::move(static_cast<Hash &>(other))),
613 KeyEqual(std::move(static_cast<KeyEqual &>(other))),
614 GrowthPolicy(std::move(static_cast<GrowthPolicy &>(other))),
623 other.clear_and_shrink();
628 if (&other !=
this) {
629 Hash::operator=(other);
630 KeyEqual::operator=(other);
631 GrowthPolicy::operator=(other);
717 template <
typename P> std::pair<iterator, bool>
insert(P &&value)
719 return insert_impl(KeySelect()(value), std::forward<P>(value));
724 if (hint !=
cend() &&
compare_keys(KeySelect()(*hint), KeySelect()(value))) {
728 return insert(std::forward<P>(value)).first;
731 template <
class InputIt>
void insert(InputIt first, InputIt last)
733 if (std::is_base_of<std::forward_iterator_tag,
734 typename std::iterator_traits<InputIt>::iterator_category>::value) {
735 const auto nb_elements_insert = std::distance(first, last);
739 if (nb_elements_insert > 0 && nb_free_buckets <
size_type(nb_elements_insert)) {
744 for (; first != last; ++first) {
751 auto it =
try_emplace(std::forward<K>(key), std::forward<M>(obj));
753 it.first.value() = std::forward<M>(obj);
763 it.value() = std::forward<M>(obj);
771 template <
class... Args> std::pair<iterator, bool>
emplace(Args &&...args)
781 template <
class K,
class... Args>
785 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 std::size_t icloser_bucket =
static_cast<std::size_t
>(first_mutable.m_bucket -
m_buckets);
848 std::size_t ito_move_closer_value =
849 static_cast<std::size_t
>(last_mutable.m_bucket -
m_buckets);
852 const std::size_t ireturn_bucket =
853 ito_move_closer_value -
854 std::min(ito_move_closer_value - icloser_bucket,
855 std::size_t(
m_buckets[ito_move_closer_value].dist_from_ideal_bucket()));
858 m_buckets[ito_move_closer_value].dist_from_ideal_bucket() > 0) {
860 ito_move_closer_value -
861 std::min(ito_move_closer_value - icloser_bucket,
862 std::size_t(
m_buckets[ito_move_closer_value].dist_from_ideal_bucket()));
867 (ito_move_closer_value - icloser_bucket));
869 new_distance,
m_buckets[ito_move_closer_value].truncated_hash(),
870 std::move(
m_buckets[ito_move_closer_value].value()));
874 ++ito_move_closer_value;
886 auto it =
find(key, my_hash);
902 swap(
static_cast<Hash &
>(*
this),
static_cast<Hash &
>(other));
903 swap(
static_cast<KeyEqual &
>(*
this),
static_cast<KeyEqual &
>(other));
904 swap(
static_cast<GrowthPolicy &
>(*
this),
static_cast<GrowthPolicy &
>(other));
919 template <
class K,
class U = ValueSelect,
920 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
921 typename U::value_type &
at(
const K &key)
926 template <
class K,
class U = ValueSelect,
927 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
928 typename U::value_type &
at(
const K &key, std::size_t my_hash)
930 return const_cast<typename U::value_type &
>(
931 static_cast<const robin_hash *
>(
this)->
at(key, my_hash));
934 template <
class K,
class U = ValueSelect,
935 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
936 const typename U::value_type &
at(
const K &key)
const
941 template <
class K,
class U = ValueSelect,
942 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
943 const typename U::value_type &
at(
const K &key, std::size_t my_hash)
const
945 auto it =
find(key, my_hash);
954 template <
class K,
class U = ValueSelect,
955 typename std::enable_if<has_mapped_type<U>::value>::type * =
nullptr>
958 return try_emplace(std::forward<K>(key)).first.value();
992 template <
class K>
bool contains(
const K &key, std::size_t my_hash)
const
994 return count(key, my_hash) != 0;
997 template <
class K> std::pair<iterator, iterator>
equal_range(
const K &key)
1003 std::pair<iterator, iterator>
equal_range(
const K &key, std::size_t my_hash)
1006 return std::make_pair(it, (it ==
end()) ? it : std::next(it));
1009 template <
class K> std::pair<const_iterator, const_iterator>
equal_range(
const K &key)
const
1015 std::pair<const_iterator, const_iterator>
equal_range(
const K &key, std::size_t my_hash)
const
1018 return std::make_pair(it, (it ==
cend()) ? it : std::next(it));
1028 return std::min(GrowthPolicy::max_bucket_count(),
m_buckets_data.max_size());
1086 template <
class Serializer>
void serialize(Serializer &serializer)
const
1091 template <
class Deserializer>
1098 template <
class K> std::size_t
hash_key(
const K &key)
const {
return Hash::operator()(key); }
1100 template <
class K1,
class K2>
bool compare_keys(
const K1 &key1,
const K2 &key2)
const
1102 return KeyEqual::operator()(key1, key2);
1107 const std::size_t bucket = GrowthPolicy::bucket_for_hash(my_hash);
1113 template <
class U = GrowthPolicy,
1114 typename std::enable_if<is_power_of_two_policy<U>::value>::type * =
nullptr>
1119 return (index + 1) & this->m_mask;
1122 template <
class U = GrowthPolicy,
1123 typename std::enable_if<!is_power_of_two_policy<U>::value>::type * =
nullptr>
1142 while (dist_from_ideal_bucket <=
m_buckets[ibucket].dist_from_ideal_bucket()) {
1150 dist_from_ideal_bucket++;
1168 std::size_t previous_ibucket =
static_cast<std::size_t
>(pos.
m_bucket -
m_buckets);
1169 std::size_t ibucket =
next_bucket(previous_ibucket);
1171 while (
m_buckets[ibucket].dist_from_ideal_bucket() > 0) {
1177 new_distance,
m_buckets[ibucket].truncated_hash(),
1181 previous_ibucket = ibucket;
1186 template <
class K,
class... Args>
1187 std::pair<iterator, bool>
insert_impl(
const K &key, Args &&...value_type_args)
1189 const std::size_t my_hash =
hash_key(key);
1194 while (dist_from_ideal_bucket <=
m_buckets[ibucket].dist_from_ideal_bucket()) {
1201 dist_from_ideal_bucket++;
1206 dist_from_ideal_bucket = 0;
1208 while (dist_from_ideal_bucket <=
m_buckets[ibucket].dist_from_ideal_bucket()) {
1210 dist_from_ideal_bucket++;
1217 std::forward<Args>(value_type_args)...);
1221 std::forward<Args>(value_type_args)...);
1232 template <
class... Args>
1236 value_type value(std::forward<Args>(value_type_args)...);
1259 dist_from_ideal_bucket++;
1262 if (dist_from_ideal_bucket >
m_buckets[ibucket].dist_from_ideal_bucket()) {
1275 dist_from_ideal_bucket++;
1284 robin_hash new_table(my_count,
static_cast<Hash &
>(*
this),
static_cast<KeyEqual &
>(*
this),
1289 if (bucket.empty()) {
1293 const std::size_t my_hash = use_stored_hash
1294 ? bucket.truncated_hash()
1295 : new_table.
hash_key(KeySelect()(bucket.value()));
1299 std::move(bucket.value()));
1303 new_table.
swap(*
this);
1308 GrowthPolicy::clear();
1322 if (dist_from_ideal_bucket >
m_buckets[ibucket].dist_from_ideal_bucket()) {
1333 dist_from_ideal_bucket++;
1369 serializer(version);
1374 const std::int16_t hash_stored_for_bucket =
static_cast<std::int16_t
>(
STORE_HASH);
1375 serializer(hash_stored_for_bucket);
1378 serializer(nb_elements);
1390 if (bucket.empty()) {
1392 serializer(empty_bucket);
1395 const std::int16_t dist_from_ideal_bucket = bucket.dist_from_ideal_bucket();
1396 serializer(dist_from_ideal_bucket);
1398 const std::uint32_t truncated_hash = bucket.truncated_hash();
1399 serializer(truncated_hash);
1401 serializer(bucket.value());
1406 template <
class Deserializer>
1416 "The protocol version header is invalid.");
1419 const bool hash_stored_for_bucket =
1421 if (hash_compatible &&
STORE_HASH != hash_stored_for_bucket) {
1423 "Can't deserialize a map with a different StoreHash "
1424 "than the one used during the serialization when "
1425 "hash compatibility is used");
1436 "Invalid min_load_factor. Check that the serializer "
1437 "and deserializer support floats correctly as they "
1438 "can be converted implicitly to ints.");
1444 "Invalid max_load_factor. Check that the serializer "
1445 "and deserializer support floats correctly as they "
1446 "can be converted implicitly to ints.");
1452 if (bucket_count_ds == 0) {
1457 if (!hash_compatible) {
1459 for (
slz_size_type ibucket = 0; ibucket < bucket_count_ds; ibucket++) {
1463 if (hash_stored_for_bucket) {
1482 "though hash_compatible is true.");
1495 if (hash_stored_for_bucket) {
1500 bucket.set_value_of_empty_bucket(dist_from_ideal_bucket, truncated_hash,
1523 "MINIMUM_MAX_LOAD_FACTOR should be < MAXIMUM_MAX_LOAD_FACTOR");
1525 "MINIMUM_MIN_LOAD_FACTOR should be < MAXIMUM_MIN_LOAD_FACTOR");
1527 "MAXIMUM_MIN_LOAD_FACTOR should be < MINIMUM_MAX_LOAD_FACTOR");
1542 return &empty_bucket;
bool bucket_hash_equal(std::size_t my_hash) const noexcept
Definition robin_hash.h:137
void set_hash(truncated_hash_type my_hash) noexcept
Definition robin_hash.h:145
truncated_hash_type m_hash
Definition robin_hash.h:148
truncated_hash_type truncated_hash() const noexcept
Definition robin_hash.h:142
Definition robin_hash.h:124
truncated_hash_type truncated_hash() const noexcept
Definition robin_hash.h:128
bool bucket_hash_equal(std::size_t) const noexcept
Definition robin_hash.h:126
void set_hash(truncated_hash_type) noexcept
Definition robin_hash.h:131
Definition robin_hash.h:171
bucket_entry(bool last_bucket) noexcept
Definition robin_hash.h:184
std::int16_t distance_type
Definition robin_hash.h:176
void clear() noexcept
Definition robin_hash.h:241
bucket_entry & operator=(bucket_entry &&)=delete
bool empty() const noexcept
Definition robin_hash.h:249
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:219
ValueType value_type
Definition robin_hash.h:175
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:273
~bucket_entry() noexcept
Definition robin_hash.h:239
storage m_value
Definition robin_hash.h:331
bucket_entry() noexcept
Definition robin_hash.h:178
static truncated_hash_type truncate_hash(std::size_t my_hash) noexcept
Definition robin_hash.h:307
distance_type m_dist_from_ideal_bucket
Definition robin_hash.h:329
bool last_bucket() const noexcept
Definition robin_hash.h:268
distance_type dist_from_ideal_bucket() const noexcept
Definition robin_hash.h:266
bool m_last_bucket
Definition robin_hash.h:330
bucket_entry_hash< StoreHash > bucket_hash
Definition robin_hash.h:172
typename std::aligned_storage< sizeof(value_type), alignof(value_type)>::type storage
Definition robin_hash.h:327
void destroy_value() noexcept
Definition robin_hash.h:313
value_type & value() noexcept
Definition robin_hash.h:254
void swap_with_value_in_bucket(distance_type &dist_from_ideal_bucket, truncated_hash_type &my_hash, value_type &value)
Definition robin_hash.h:287
const value_type & value() const noexcept
Definition robin_hash.h:260
bucket_entry(bucket_entry &&other) noexcept(std::is_nothrow_move_constructible< value_type >::value)
Definition robin_hash.h:207
static const distance_type DIST_FROM_IDEAL_BUCKET_LIMIT
Definition robin_hash.h:321
static const distance_type EMPTY_MARKER_DIST_FROM_IDEAL_BUCKET
Definition robin_hash.h:320
void set_as_last_bucket() noexcept
Definition robin_hash.h:270
Definition robin_hash.h:447
const robin_hash::key_type & key() const
Definition robin_hash.h:476
robin_iterator & operator=(const robin_iterator &other)=default
reference operator*() const
Definition robin_hash.h:492
typename std::conditional< IsConst, const bucket_entry *, bucket_entry * >::type bucket_entry_ptr
Definition robin_hash.h:451
value_type & reference
Definition robin_hash.h:460
const U::value_type & value() const
Definition robin_hash.h:480
robin_iterator operator++(int)
Definition robin_hash.h:511
U::value_type & value() const
Definition robin_hash.h:487
const typename robin_hash::value_type value_type
Definition robin_hash.h:458
value_type * pointer
Definition robin_hash.h:461
robin_iterator(const robin_iterator &other)=default
robin_iterator(bucket_entry_ptr bucket) noexcept
Definition robin_hash.h:454
bucket_entry_ptr m_bucket
Definition robin_hash.h:530
robin_iterator & operator=(robin_iterator &&other)=default
robin_iterator() noexcept
Definition robin_hash.h:463
robin_iterator(robin_iterator &&other)=default
friend bool operator!=(const robin_iterator &lhs, const robin_iterator &rhs)
Definition robin_hash.h:524
robin_iterator(const robin_iterator<!TIsConst > &other) noexcept
Definition robin_hash.h:467
std::forward_iterator_tag iterator_category
Definition robin_hash.h:457
std::ptrdiff_t difference_type
Definition robin_hash.h:459
robin_iterator & operator++()
Definition robin_hash.h:496
pointer operator->() const
Definition robin_hash.h:494
friend bool operator==(const robin_iterator &lhs, const robin_iterator &rhs)
Definition robin_hash.h:519
Definition robin_hash.h:356
std::pair< const_iterator, const_iterator > equal_range(const K &key, std::size_t my_hash) const
Definition robin_hash.h:1015
key_equal key_eq() const
Definition robin_hash.h:1076
static const size_type DEFAULT_INIT_BUCKETS_SIZE
Definition robin_hash.h:1512
size_type m_nb_elements
Definition robin_hash.h:1565
static bool USE_STORED_HASH_ON_REHASH(size_type bucket_count)
Definition robin_hash.h:411
iterator find(const K &key)
Definition robin_hash.h:973
Hash hasher
Definition robin_hash.h:373
size_type m_bucket_count
Definition robin_hash.h:1563
const value_type * const_pointer
Definition robin_hash.h:379
iterator begin() noexcept
Definition robin_hash.h:662
const_iterator find(const K &key) const
Definition robin_hash.h:980
void deserialize_impl(Deserializer &deserializer, bool hash_compatible)
Definition robin_hash.h:1407
bucket_entry * static_empty_bucket_ptr() noexcept
Definition robin_hash.h:1539
static constexpr float DEFAULT_MIN_LOAD_FACTOR
Definition robin_hash.h:1518
void min_load_factor(float ml)
Definition robin_hash.h:1047
std::size_t next_bucket(std::size_t index) const noexcept
Definition robin_hash.h:1115
bool m_try_shrink_on_next_insert
Definition robin_hash.h:1581
static constexpr bool STORE_HASH
Definition robin_hash.h:389
bool m_grow_on_next_insert
Definition robin_hash.h:1572
static constexpr float MAXIMUM_MAX_LOAD_FACTOR
Definition robin_hash.h:1516
static const slz_size_type SERIALIZATION_PROTOCOL_VERSION
Definition robin_hash.h:1533
bool empty() const noexcept
Definition robin_hash.h:693
typename KeySelect::key_type key_type
Definition robin_hash.h:369
float min_load_factor() const
Definition robin_hash.h:1043
KeyEqual key_equal
Definition robin_hash.h:374
std::pair< iterator, bool > insert(P &&value)
Definition robin_hash.h:717
std::pair< const_iterator, const_iterator > equal_range(const K &key) const
Definition robin_hash.h:1009
iterator insert_or_assign(const_iterator hint, K &&key, M &&obj)
Definition robin_hash.h:759
void clear_and_shrink() noexcept
Definition robin_hash.h:1306
hasher hash_function() const
Definition robin_hash.h:1074
std::size_t hash_key(const K &key) const
Definition robin_hash.h:1098
iterator erase(const_iterator first, const_iterator last)
Definition robin_hash.h:823
value_type * pointer
Definition robin_hash.h:378
value_type & reference
Definition robin_hash.h:376
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:1318
iterator find_impl(const K &key, std::size_t my_hash)
Definition robin_hash.h:1132
void rehash(size_type my_count)
Definition robin_hash.h:1060
std::pair< iterator, bool > try_emplace(K &&key, Args &&...args)
Definition robin_hash.h:782
std::pair< iterator, iterator > equal_range(const K &key, std::size_t my_hash)
Definition robin_hash.h:1003
void serialize(Serializer &serializer) const
Definition robin_hash.h:1086
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:572
bool contains(const K &key) const
Definition robin_hash.h:990
const_iterator find(const K &key, std::size_t my_hash) const
Definition robin_hash.h:985
robin_hash & operator=(const robin_hash &other)
Definition robin_hash.h:626
std::ptrdiff_t difference_type
Definition robin_hash.h:372
std::pair< iterator, bool > insert_or_assign(K &&key, M &&obj)
Definition robin_hash.h:749
std::pair< iterator, bool > emplace(Args &&...args)
Definition robin_hash.h:771
iterator insert_hint(const_iterator hint, P &&value)
Definition robin_hash.h:722
const U::value_type & at(const K &key) const
Definition robin_hash.h:936
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:1240
static constexpr float MAXIMUM_MIN_LOAD_FACTOR
Definition robin_hash.h:1520
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:921
U::value_type & operator[](K &&key)
Definition robin_hash.h:956
size_type max_size() const noexcept
Definition robin_hash.h:697
const_iterator end() const noexcept
Definition robin_hash.h:686
const_iterator cbegin() const noexcept
Definition robin_hash.h:674
void rehash_impl(size_type my_count)
Definition robin_hash.h:1282
allocator_type get_allocator() const
Definition robin_hash.h:657
iterator find(const K &key, std::size_t my_hash)
Definition robin_hash.h:975
ValueType value_type
Definition robin_hash.h:370
robin_iterator< false > iterator
Definition robin_hash.h:380
float load_factor() const
Definition robin_hash.h:1034
const value_type & const_reference
Definition robin_hash.h:377
iterator erase(iterator pos)
Definition robin_hash.h:803
robin_hash & operator=(robin_hash &&other)
Definition robin_hash.h:649
void erase_from_bucket(iterator pos)
Definition robin_hash.h:1156
iterator erase(const_iterator pos)
Definition robin_hash.h:821
size_type bucket_count() const
Definition robin_hash.h:1024
float m_min_load_factor
Definition robin_hash.h:1569
void deserialize(Deserializer &deserializer, bool hash_compatible)
Definition robin_hash.h:1092
const U::value_type & at(const K &key, std::size_t my_hash) const
Definition robin_hash.h:943
void swap(robin_hash &other)
Definition robin_hash.h:898
size_type count(const K &key) const
Definition robin_hash.h:961
std::vector< bucket_entry, buckets_allocator > buckets_container_type
Definition robin_hash.h:432
const_iterator cend() const noexcept
Definition robin_hash.h:688
iterator end() noexcept
Definition robin_hash.h:684
float max_load_factor() const
Definition robin_hash.h:1045
bucket_entry * m_buckets
Definition robin_hash.h:1557
const_iterator find_impl(const K &key, std::size_t my_hash) const
Definition robin_hash.h:1137
void max_load_factor(float ml)
Definition robin_hash.h:1053
static constexpr float DEFAULT_MAX_LOAD_FACTOR
Definition robin_hash.h:1514
U::value_type & at(const K &key, std::size_t my_hash)
Definition robin_hash.h:928
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:1254
static constexpr float MINIMUM_MAX_LOAD_FACTOR
Definition robin_hash.h:1515
robin_hash(const robin_hash &other)
Definition robin_hash.h:596
std::size_t bucket_for_hash(std::size_t my_hash) const
Definition robin_hash.h:1105
void insert(InputIt first, InputIt last)
Definition robin_hash.h:731
size_type size() const noexcept
Definition robin_hash.h:695
float m_max_load_factor
Definition robin_hash.h:1570
size_type erase(const K &key)
Definition robin_hash.h:882
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:1233
std::pair< iterator, bool > insert_impl(const K &key, Args &&...value_type_args)
Definition robin_hash.h:1187
size_type m_load_threshold
Definition robin_hash.h:1567
typename bucket_entry::distance_type distance_type
Definition robin_hash.h:428
size_type erase(const K &key, std::size_t my_hash)
Definition robin_hash.h:884
void serialize_impl(Serializer &serializer) const
Definition robin_hash.h:1366
typename std::integral_constant< bool, !std::is_same< U, void >::value > has_mapped_type
Definition robin_hash.h:359
bool contains(const K &key, std::size_t my_hash) const
Definition robin_hash.h:992
std::pair< iterator, iterator > equal_range(const K &key)
Definition robin_hash.h:997
bool compare_keys(const K1 &key1, const K2 &key2) const
Definition robin_hash.h:1100
robin_iterator< true > const_iterator
Definition robin_hash.h:381
std::size_t size_type
Definition robin_hash.h:371
typename std::allocator_traits< allocator_type >::template rebind_alloc< bucket_entry > buckets_allocator
Definition robin_hash.h:430
void reserve(size_type my_count)
Definition robin_hash.h:1066
static constexpr float MINIMUM_MIN_LOAD_FACTOR
Definition robin_hash.h:1519
const_iterator begin() const noexcept
Definition robin_hash.h:672
bool rehash_on_extreme_load()
Definition robin_hash.h:1345
iterator mutable_iterator(const_iterator pos)
Definition robin_hash.h:1081
Allocator allocator_type
Definition robin_hash.h:375
static constexpr bool USE_STORED_HASH_ON_LOOKUP
Definition robin_hash.h:403
size_type max_bucket_count() const
Definition robin_hash.h:1026
iterator emplace_hint(const_iterator hint, Args &&...args)
Definition robin_hash.h:776
void clear() noexcept
Definition robin_hash.h:702
size_type count(const K &key, std::size_t my_hash) const
Definition robin_hash.h:963
buckets_container_type m_buckets_data
Definition robin_hash.h:1546
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:607
Definition robin_growth_policy.h:85
static T numeric_cast(U value, const char *error_message="numeric_cast() failed.")
Definition robin_hash.h:80
std::uint64_t slz_size_type
Definition robin_hash.h:112
static T deserialize_value(Deserializer &deserializer)
Definition robin_hash.h:96
std::uint32_t truncated_hash_type
Definition robin_hash.h:117
const T & clamp(const T &v, const T &lo, const T &hi)
Definition robin_hash.h:74
Definition robin_growth_policy.h:74
#define TSL_RH_LIKELY(exp)
Definition robin_growth_policy.h:69
#define TSL_RH_THROW_OR_TERMINATE(ex, msg)
Definition robin_growth_policy.h:58
#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