24 template<
typename Value,
typename Eq>
33 template<
typename Key,
typename Value,
typename Eq>
43 template<
typename Value,
bool is_map>
48 template<
typename Value>
58template<
typename Value,
typename Eq,
concepts::Hasher Hasher,
typename Buckets,
typename Tag,
typename Interface,
59 bool is_multi,
bool is_map,
typename Self =
Void>
62 template<
typename,
typename, concepts::Hasher,
typename,
typename,
typename,
bool,
bool,
typename>
78 return static_cast<Self&
>(*this);
101 m_eq = util::move(other.m_eq);
102 m_hasher = util::move(other.m_hasher);
119 auto const bucket_index = it - buckets.begin();
120 return Iterator(buckets, bucket_index);
134 if constexpr (!is_multi) {
144 auto bucket_index = it.base().bucket_index();
146 auto& node =
static_cast<ConcreteNode&
>(it.base().node());
147 auto const next = bucket.erase_after(it.base().before_current());
151 if (
next == bucket.end()) {
152 for (++bucket_index; bucket_index <
bucket_count(); ++bucket_index) {
169 auto const hash = this->
hash(needle);
171 auto const& bucket =
m_buckets[bucket_index];
172 auto before_it = bucket.before_begin();
175 if (this->
equal(current, needle)) {
182 if (it == bucket.end()) {
188 if constexpr (is_multi) {
207 auto const hash = this->
hash(needle);
209 auto const& bucket =
m_buckets[bucket_index];
210 auto before_it = bucket.before_begin();
226 m_buckets.reserve_from_nothing(new_capacity);
244 auto new_buckets = Buckets {};
246 new_buckets.reserve_from_nothing(new_capacity);
248 DI_TRY(new_buckets.reserve_from_nothing(new_capacity));
250 new_buckets.assume_size(new_capacity);
254 auto old_buckets = util::move(
m_buckets);
256 for (
auto& bucket : old_buckets) {
257 while (!bucket.empty()) {
258 auto& node =
static_cast<Node&
>(*bucket.begin().node());
285 auto it = other.begin();
286 auto const end = other.end();
288 auto& node = it.node();
301 auto before_it = bucket.before_begin();
310 if constexpr (is_multi) {
312 if (it != bucket.end()) {
313 bucket.insert_after(it, node);
314 if (call_insertion_hook) {
319 bucket.push_front(node);
320 if (call_insertion_hook) {
326 if (it == bucket.end()) {
328 bucket.push_front(node);
329 if (call_insertion_hook) {
339 constexpr auto hash(U
const& value)
const ->
u64 {
344 constexpr auto hash(Value
const& value)
const ->
u64 {
346 if constexpr (is_map) {
353 template<
typename T,
typename U>
354 constexpr auto equal(T
const& a, U
const& b)
const ->
bool {
359 constexpr auto equal(T
const& a, Value
const& b)
const ->
bool {
360 if constexpr (is_map) {
368 constexpr auto equal(Value
const& a, T
const& b)
const ->
bool {
369 if constexpr (is_map) {
376 constexpr auto equal(Value
const& a, Value
const& b)
const ->
bool {
377 if constexpr (is_map) {
386 [[no_unique_address]] Eq
m_eq {};
#define DI_ASSERT(...)
Definition assert_bool.h:7
Definition const_iterator_impl.h:19
Definition hash_node_iterator.h:15
constexpr auto bucket_count() const -> usize
Definition node_hash_table.h:110
constexpr auto insert_node_without_rehashing(Node &node, bool call_insertion_hook=true)
Definition node_hash_table.h:294
constexpr ~NodeHashTable()
Definition node_hash_table.h:106
static constexpr bool allow_rehashing_in_insert
Definition node_hash_table.h:82
constexpr auto end() -> Iterator
Definition node_hash_table.h:122
meta::Type< detail::NodeHashTableKey< Value, is_map > > Key
Definition node_hash_table.h:72
constexpr auto equal(Value const &a, Value const &b) const -> bool
Definition node_hash_table.h:376
constexpr auto begin() const -> ConstIterator
Definition node_hash_table.h:113
usize m_size
Definition node_hash_table.h:385
constexpr auto begin() -> Iterator
Definition node_hash_table.h:112
HashNode< Tag > Node
Definition node_hash_table.h:66
NodeHashTable(NodeHashTable const &)=delete
constexpr auto equal(T const &a, U const &b) const -> bool
Definition node_hash_table.h:354
constexpr auto hash(U const &value) const -> u64
Definition node_hash_table.h:339
constexpr void merge_impl_without_rehashing(NodeHashTable &&other)
Definition node_hash_table.h:284
constexpr auto down_cast_self() -> decltype(auto)
Definition node_hash_table.h:74
constexpr auto unconst_iterator(ConstIterator it) -> Iterator
Definition node_hash_table.h:125
constexpr auto find_impl(U &&needle) const -> ConstIterator
Definition node_hash_table.h:202
auto operator=(NodeHashTable const &) -> NodeHashTable &=delete
constexpr auto size() const -> usize
Definition node_hash_table.h:108
constexpr auto insert_node(Node &node)
Definition node_hash_table.h:127
constexpr auto equal(Value const &a, T const &b) const -> bool
Definition node_hash_table.h:368
constexpr auto node_value(Node const &node) const -> Value const &
Definition node_hash_table.h:280
constexpr auto end() const -> ConstIterator
Definition node_hash_table.h:123
constexpr NodeHashTable(NodeHashTable &&other)
Definition node_hash_table.h:91
constexpr auto erase_impl(ConstIterator it) -> Iterator
Definition node_hash_table.h:143
constexpr auto reserve(usize new_capacity) -> decltype(util::declval< Buckets & >().reserve_from_nothing(new_capacity))
Definition node_hash_table.h:221
constexpr auto equal(T const &a, Value const &b) const -> bool
Definition node_hash_table.h:359
constexpr auto equal_range_impl(U &&needle) const
Definition node_hash_table.h:164
constexpr auto hash(Value const &value) const -> u64
Definition node_hash_table.h:344
constexpr auto empty() const -> bool
Definition node_hash_table.h:109
Buckets m_buckets
Definition node_hash_table.h:384
constexpr auto insert_node(ConstIterator, Node &node)
Definition node_hash_table.h:133
Hasher m_hasher
Definition node_hash_table.h:387
constexpr auto node_value(Node &node) const -> Value &
Definition node_hash_table.h:277
HashNodeIterator< Value, Tag > Iterator
Definition node_hash_table.h:67
decltype(Tag::node_type(in_place_type< Value >)) ConcreteNode
Definition node_hash_table.h:70
constexpr auto operator=(NodeHashTable &&other) -> NodeHashTable &
Definition node_hash_table.h:97
container::ConstIteratorImpl< Iterator > ConstIterator
Definition node_hash_table.h:68
friend class NodeHashTable
Definition node_hash_table.h:63
constexpr NodeHashTable(Eq eq, Hasher hasher={})
Definition node_hash_table.h:89
constexpr void merge_impl(NodeHashTable &&other)
Definition node_hash_table.h:270
Eq m_eq
Definition node_hash_table.h:386
Definition tuple_forward_declaration.h:5
Definition hash_same.h:43
#define DI_TRY(...)
Definition monad_try.h:13
constexpr auto lookup(concepts::detail::ConstantVector auto &vector, size_t index) -> decltype(auto)
Definition vector_lookup.h:10
constexpr auto size(concepts::detail::ConstantVector auto const &vector) -> size_t
Definition vector_size.h:7
constexpr auto empty(concepts::detail::ConstantVector auto const &vector) -> bool
Definition vector_empty.h:7
constexpr auto next
Definition next.h:35
constexpr auto empty
Definition empty.h:45
constexpr auto move
Definition move.h:38
constexpr auto find_if
Definition find_if.h:31
constexpr auto equal
Definition equal.h:46
constexpr auto uninitialized_default_construct
Definition uninitialized_default_construct.h:34
constexpr auto hash
Definition hash.h:21
constexpr auto not_fn(F &&function)
Definition not_fn.h:55
size_t usize
Definition integers.h:33
__UINT64_TYPE__ u64
Definition integers.h:12
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
constexpr auto get(T &&value) -> decltype(auto)
Definition get.h:8
auto declval() -> meta::AddRValueReference< T >
Definition declval.h:8
constexpr auto exchange(T &object, U &&new_value) -> T
Definition exchange.h:8
Tuple(Types...) -> Tuple< Types... >
constexpr auto exchange(T &object, U &&new_value) -> T
Definition exchange.h:8
constexpr auto as_fallible
Definition as_fallible.h:26
constexpr auto try_infallible
Definition try_infallible.h:31
constexpr auto in_place_type
Definition in_place_type.h:12
Definition node_hash_table.h:44
meta::Front< meta::AsList< Value > > Type
Definition node_hash_table.h:50
Value Type
Definition node_hash_table.h:45
Definition node_hash_table.h:36
static constexpr bool value
Definition node_hash_table.h:37
Definition node_hash_table.h:34
Definition node_hash_table.h:27
static constexpr bool value
Definition node_hash_table.h:28
Definition node_hash_table.h:25