22 template<
typename Type, ice::ContainerLogic Logic = ice::Constant_DefaultContainerLogic<Type>>
30 "Collection element type is not allowed with 'Trivial' logic!"
60 requires std::copy_constructible<Type>;
64 requires std::copy_constructible<Type>;
68 template<
typename Self>
70 template<
typename Self>
73 template<
typename Self,
typename InValueType = Type>
75 this Self& self,
KeyType key, InValueType&& in_value
79 using AssociativeResizableContainer::remove;
82 template<
typename Self>
88 constexpr void clear() noexcept;
91 template<typename Self>
93 template<typename Self>
122 constexpr auto value() const noexcept -> Type const& {
return *
_value; }
131 template<
typename Type, ice::ContainerLogic Logic>
141 template<
typename Type, ice::ContainerLogic Logic>
148 template<
typename Type, ice::ContainerLogic Logic>
151 ,
_capacity{ ice::exchange(other._capacity, 0) }
152 ,
_count{ ice::exchange(other._count, 0) }
153 ,
_hashes{ ice::exchange(other._hashes,
nullptr) }
154 ,
_entries{ ice::exchange(other._entries,
nullptr) }
155 ,
_data{ ice::exchange(other._data,
nullptr) }
158 template<
typename Type, ice::ContainerLogic Logic>
160 requires std::copy_constructible<Type>
168 if (other._count > 0)
174 static_assert(std::is_pod_v<EntryType>,
"HashMap::Entry should not be changed!");
194 other.values_data_view()
213 template<
typename Type, ice::ContainerLogic Logic>
222 _capacity = std::exchange(other._capacity, 0);
223 _count = std::exchange(other._count, 0);
224 _hashes = std::exchange(other._hashes,
nullptr);
225 _entries = std::exchange(other._entries,
nullptr);
226 _data = std::exchange(other._data,
nullptr);
231 template<
typename Type, ice::ContainerLogic Logic>
233 requires std::copy_constructible<Type>
244 static_assert(std::is_pod_v<EntryType>,
"HashMap::Entry should not be changed!");
247 other.entries_data_view()
264 other.values_data_view()
284 template<
typename Type, ice::ContainerLogic Logic>
285 template<
typename Self,
typename InValueType>
287 this Self& self,
KeyType key, InValueType&& in_value
307 std::forward<InValueType>(in_value)
312 self._data[index] = in_value;
315 return self._data[index];
318 template<
typename Type, ice::ContainerLogic Logic>
319 template<
typename Self>
325 template<
typename Type, ice::ContainerLogic Logic>
326 template<
typename Self>
334 ? ice::addressof(self._data[entry_index])
338 template<
typename Type, ice::ContainerLogic Logic>
339 template<
typename Self>
342 return { self._data, self._count };
345 template<
typename Type, ice::ContainerLogic Logic>
352 if (new_capacity > 0)
358 alloc_reqest.
include(new_hashes_ptr, new_internal_capacity);
359 alloc_reqest.
include(new_entries_ptr, new_capacity);
360 alloc_reqest.
include(new_value_ptr, new_capacity);
364 std::memset(new_hashes_ptr, 0xffffffff, new_internal_capacity *
sizeof(
u32));
371 static_assert(std::is_pod_v<EntryType>,
"HashMap::EntryType should not be changed!");
372 std::memcpy(new_entries_ptr, this->_entries,
sizeof(
EntryType) *
_count);
386 ice::u32 const new_capacity_u32 = new_capacity.u32();
390 new_entries_ptr[idx].
next = new_hashes_ptr[entry.key % new_capacity_u32];
393 new_hashes_ptr[entry.key % new_capacity_u32] = idx;
400 _capacity = new_capacity.u32();
403 _data = new_value_ptr;
406 template<
typename Type, ice::ContainerLogic Logic>
425 template<
typename Type, ice::ContainerLogic Logic>
426 template<
typename Self>
429 return { self._entries, self._data };
432 template<
typename Type, ice::ContainerLogic Logic>
433 template<
typename Self>
436 return { self._entries + self._count, self._data + self._count };
439 template<
typename Type, ice::ContainerLogic Logic>
450 template<
typename Type, ice::ContainerLogic Logic>
460 template<
typename Type, ice::ContainerLogic Logic>
465 .size = this->
size(),
470 template<
typename Type, ice::ContainerLogic Logic>
#define ICE_ASSERT_CORE(expression)
Definition assert_core.hxx:43
A concept that ensures only types that can be trivially copyable can be 'forced' to use trifial Logic...
Definition container_logic.hxx:25
Definition associative_container.hxx:8
ice::Span< ice::container::ConstCorrectContainerValueType< ContainerT > > SpanType
Definition container_concepts.hxx:167
ValueType< ContainerT > * ValuePtr
Definition container_concepts.hxx:155
ConstCorrectContainerIterator< ContainerT > Iterator
Definition container_concepts.hxx:158
ValueType< ContainerT > & ValueRef
Definition container_concepts.hxx:149
constexpr auto calc_meminfo(ice::ncount capacity) noexcept -> ice::meminfo
Definition hashmap_details.hxx:53
bool find_and_erase(ContainerT &map, ice::u64 key) noexcept
Definition hashmap_details.hxx:242
constexpr auto capacity_with_overhead(ice::ncount max_count) noexcept -> ice::ncount
Definition hashmap_details.hxx:47
auto find_or_make(ContainerT &map, ice::u64 key, bool &found) noexcept -> ice::u32
Definition hashmap_details.hxx:207
auto entries(ContainerT const &map) noexcept -> ice::Span< typename ContainerT::EntryType const >
Definition hashmap_details.hxx:64
auto find_or_fail(ContainerT const &map, ice::container::KeyType< ContainerT > key) noexcept -> ice::u32
Definition hashmap_details.hxx:201
static constexpr ice::u32 Constant_EndOfList
Definition hashmap_details.hxx:31
SPDX-License-Identifier: MIT.
Definition array.hxx:12
constexpr ice::usize size_of
Definition mem_info.hxx:12
auto mem_move_construct_n_at(ice::Memory memory, T *objects, ice::u64 count) noexcept -> T *
Definition mem_initializers.hxx:58
ContainerLogic
The logic implemented by a collectiont type when working with data. (Copying, Moving,...
Definition container_logic.hxx:13
@ Complex
The collection handles complex data types and properly implements copy and move semantics.
Definition container_logic.hxx:19
void mem_destruct_n_at(T *location, ice::u64 count) noexcept
Definition mem_initializers.hxx:113
auto alloc(ice::usize size) noexcept -> ice::AllocResult
std::uint64_t u64
Definition types.hxx:27
constexpr ice::ualign align_of
Definition mem_info.hxx:15
auto mem_copy_construct_n_at(ice::Memory memory, T const *objects, ice::u64 count) noexcept -> T *
Definition mem_initializers.hxx:80
std::uint32_t u32
Definition types.hxx:26
void mem_destruct_at(T *location) noexcept
Definition mem_initializers.hxx:107
ice::AllocatorBase< ice::build::is_debug||ice::build::is_develop > Allocator
Definition mem_types.hxx:25
auto mem_construct_at(void *memory_ptr, Args &&... args) noexcept -> T *
Definition mem_initializers.hxx:12
auto memcpy(void *dest, void const *source, ice::usize size) noexcept -> void *
constexpr auto include(T *&ptrref, ice::u64 count) noexcept
Definition mem.hxx:91
Definition mem_data.hxx:17
Definition hashmap.hxx:107
constexpr auto operator==(ConstIterator const &other) const noexcept
Definition hashmap.hxx:124
constexpr ConstIterator(std::nullptr_t) noexcept
Definition hashmap.hxx:111
EntryType const * _entry
Definition hashmap.hxx:108
constexpr auto operator!=(ConstIterator const &other) const noexcept
Definition hashmap.hxx:125
constexpr auto value() const noexcept -> Type const &
Definition hashmap.hxx:122
constexpr auto key() const noexcept -> ice::u64 const &
Definition hashmap.hxx:121
constexpr auto operator*() const noexcept -> Type const &
Definition hashmap.hxx:128
constexpr ConstIterator(EntryType const *entry, Type const *value) noexcept
Definition hashmap.hxx:116
ValueType const * _value
Definition hashmap.hxx:109
constexpr void operator++() noexcept
Definition hashmap.hxx:127
Definition hashmap.hxx:42
KeyType key
Definition hashmap.hxx:43
ice::u32 next
Definition hashmap.hxx:44
constexpr auto size() const noexcept -> SizeType
Definition hashmap.hxx:67
constexpr auto store(this Self &self, KeyType key, InValueType &&in_value) noexcept -> ice::container::ValueRef< Self >
Definition hashmap.hxx:286
constexpr auto begin(this Self &&self) noexcept -> ice::container::Iterator< Self >
Definition hashmap.hxx:427
constexpr void clear() noexcept
Definition hashmap.hxx:407
constexpr auto values(this Self &&self) noexcept -> ice::container::SpanType< Self >
Definition hashmap.hxx:340
Type ValueType
Definition hashmap.hxx:36
ConstIterator Iterator
Definition hashmap.hxx:38
ValueType * _data
Definition hashmap.hxx:53
constexpr auto find(this Self &&self, KeyType key) noexcept -> ice::container::ValuePtr< Self >
Definition hashmap.hxx:327
ice::Allocator * _allocator
Definition hashmap.hxx:47
ice::u32 * _hashes
Definition hashmap.hxx:51
constexpr void set_capacity(ice::ncount new_capacity) noexcept
Definition hashmap.hxx:346
constexpr auto entries_memory_view() noexcept -> ice::Memory
Definition hashmap.hxx:451
ice::ncount SizeType
Definition hashmap.hxx:39
ice::u32 _count
Definition hashmap.hxx:49
static constexpr ContainerLogic OperationLogic
Definition hashmap.hxx:27
ice::u64 KeyType
Definition hashmap.hxx:35
constexpr auto end(this Self &&self) noexcept -> ice::container::Iterator< Self >
Definition hashmap.hxx:434
auto operator=(HashMap &&other) noexcept -> HashMap &
Definition hashmap.hxx:214
~HashMap() noexcept
Definition hashmap.hxx:142
EntryType * _entries
Definition hashmap.hxx:52
constexpr auto memory_view() noexcept -> ice::Memory
Definition hashmap.hxx:440
constexpr auto entries_data_view() const noexcept -> ice::Data
Definition hashmap.hxx:471
constexpr auto values_data_view() const noexcept -> ice::Data
Definition hashmap.hxx:461
ice::u32 _capacity
Definition hashmap.hxx:48
HashMap(ice::Allocator &alloc) noexcept
Definition hashmap.hxx:132
constexpr auto capacity() const noexcept -> SizeType
Definition hashmap.hxx:86
constexpr bool remove(this Self &self, KeyType key) noexcept
Definition hashmap.hxx:320
Type const ConstContainerValueType
Definition hashmap.hxx:37
Definition mem_memory.hxx:13
Definition associative_container.hxx:55
Definition resizable_container.hxx:11
constexpr void reserve(this Self &self, ice::ncount min_capacity) noexcept
Definition resizable_container.hxx:25
Definition mem_size_types.hxx:59