Skip to content

Commit c5ea6b9

Browse files
author
Julian LALU
committed
Improve hashmap
1 parent f86be20 commit c5ea6b9

3 files changed

Lines changed: 2036 additions & 100 deletions

File tree

interface/core/containers/hashmap.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,6 @@ namespace hud
163163
requires(hud::is_nothrow_copy_assignable_v<pair_type>)
164164
= default;
165165

166-
// template<typename u_key_t = key_t, typename u_value_t = value_t>
167-
// constexpr hashmap_storage &operator=(const hashmap_storage<u_key_t, u_value_t> &other) noexcept
168-
// {
169-
// element_ = other.element_;
170-
// return *this;
171-
// }
172-
173166
protected:
174167
/**
175168
* Move constructor.
@@ -204,10 +197,12 @@ namespace hud
204197
static_assert(hud::is_nothrow_move_constructible_v<value_t, u_value_t>, "value_t(u_value_t&&) move constructor is throwable. hashmap_storage is not designed to allow throwable move constructible components");
205198
}
206199

207-
private:
208200
/** hashmap_storage with other key or value can access private members of hashmap_storage. */
209201
template<typename u_key_t, typename u_value_t>
210202
friend class hashmap_storage;
203+
/** Only the slot can move construct storage. */
204+
template<typename u_storage>
205+
friend struct slot;
211206

212207
protected:
213208
/** The pair containing the key and value. */

interface/core/containers/hashset.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace hud
9292
* @param other The slot with a compatible storage to move from.
9393
*/
9494
template<typename u_storage_t = storage_type>
95-
requires(hud::is_move_constructible_v<storage_type, u_storage_t>)
95+
// requires(hud::is_move_constructible_v<storage_type, u_storage_t>)
9696
constexpr explicit(!hud::is_convertible_v<storage_type, u_storage_t>) slot(slot<u_storage_t> &&other) noexcept
9797
: storage_type(hud::move(other))
9898
{
@@ -1333,7 +1333,7 @@ namespace hud
13331333
// Save h2 in control h1 index
13341334
control::set_h2(control_ptr_, slot_index, H2(hash), max_slot_count_);
13351335
// Copy slot
1336-
hud::memory::construct_object_at(slot_ptr_ + slot_index, *slot_ptr);
1336+
hud::memory::construct_object_at(slot_ptr_ + slot_index, hud::move(*slot_ptr));
13371337
};
13381338
iterate_over_full_slots(other.control_ptr_, other.slot_ptr_, count_, other.max_slot_count_, insert_slot_by_copy);
13391339
}

0 commit comments

Comments
 (0)