13#if HX_USE_MACROS_WITH_MODULE
14#error Header does not provide macros alone.
24template<hx
size_t mask_>
25class hxhandle_map_mask_ {
27 hxinline_constexpr uint32_t get_mask_(
void)
const {
return static_cast<uint32_t
>(mask_); }
28 hxinline void set_mask_(uint32_t)
const { }
35 hxinline void set_mask_(uint32_t mask_) { m_mask_ = mask_; }
51template<
typename T_, u
int32_t table_size_bits_=hxallocator_dynamic_capacity>
54 static_assert(table_size_bits_ < 31u,
"Slot index must fit in the low 31-bits of the handle");
117 template<
typename callable_t_>
139 template<
typename... args_t_>
158 :
static_cast<hxsize_t>(1) << table_size_bits_;
171 void build_free_list_(
void);
174 hxhandle_map_mask_<s_value_capacity_> m_mask_;
175 hxallocator<slot_t_, s_capacity_> m_slots_;
176 hxallocator<T_, s_value_capacity_> m_values_;
179#include "detail/hxhandle_map.inl"
bool empty(void) const
Checks if the map is empty.
Definition hxhandle_map.hpp:107
const T * data(void) const
Returns a const pointer to the first of size contiguous values.
Definition hxhandle_map.hpp:93
T * data(void)
Returns a pointer to the first of size contiguous values.
Definition hxhandle_map.hpp:96
~hxhandle_map()
Destructs the map and destroys all values.
T * end(void)
Returns a T* to the end of the values.
Definition hxhandle_map.hpp:104
bool erase(hxhandle_t handle_) noexcept
Returns true if handle resolved and its value was destroyed.
hxsize_t capacity(void) const
Returns the number of values that can be stored.
Definition hxhandle_map.hpp:79
void clear(void) noexcept
Destroys all values and invalidates their handles.
const T * end(void) const
Returns a const T* to the end of the values.
Definition hxhandle_map.hpp:100
const T * get(hxhandle_t handle_) const noexcept
const version of get.
hxsize_t size(void) const
Returns the number of values in the map.
Definition hxhandle_map.hpp:151
bool full(void) const
Checks if the map is full.
Definition hxhandle_map.hpp:121
const T * begin(void) const
Returns a const T* to the beginning of the values (alias for data).
Definition hxhandle_map.hpp:72
hxhandle_t insert(args_t_ &&... args_) noexcept
Returns a non-zero handle referencing a value constructed at the end of data from args.
hxsize_t erase_if(callable_t_ &&callable_) noexcept
Returns the number of values destroyed.
void set_size_bits(uint32_t bits_)
Sets the number of index bits and allocates memory for the map (only for dynamic capacity).
const T * const_iterator
const_iterator - Const random access iterator.
Definition hxhandle_map.hpp:60
const T * cbegin(void) const
Returns a const T* to the beginning of the values (alias for begin).
Definition hxhandle_map.hpp:83
T * iterator
iterator - Random access iterator.
Definition hxhandle_map.hpp:57
T * get(hxhandle_t handle_) noexcept
Returns a pointer to the value referenced by handle if it resolves, otherwise hxnull.
hxsize_t max_size(void) const
Returns the maximum number of values that can be stored.
Definition hxhandle_map.hpp:143
hxhandle_map(void)
Constructs an empty map with a capacity of 2^table_size_bits - 1.
T * begin(void)
Returns a T* to the beginning of the values (alias for data).
Definition hxhandle_map.hpp:76
T value_t
Definition hxhandle_map.hpp:62
hxhandle_t handle_at(hxsize_t index_) const noexcept
Returns the handle for the value at begin() + index.
const T * cend(void) const
Returns a const T* to the end of the values.
Definition hxhandle_map.hpp:87
Similar to std::allocator.
HX_NS_BEGIN_ constexpr hxsize_t hxallocator_dynamic_capacity
hxallocator_dynamic_capacity - A capacity value that allows for dynamic allocation.
Definition hxallocator.hpp:20
#define hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:120
#define hxinline_constexpr
hxinline_constexpr - Enables C++17 compatable "inline constexpr" usage for variables so they can be e...
Definition hxsettings.h:272
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:89
#define hxattr_flatten
hxattr_flatten - Inline every call inside a function's body into it, recursively, regardless of the c...
Definition hxsettings.h:82
A few utility functions and most standard C++ meta programming functions.
Provides core macros, memory management and feature detection.
uint64_t hxhandle_t
hxhandle_t - An opaque 64-bit handle.
Definition libhatchet.h:215
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:209