12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
21#include "detail/hxpow2_allocator.hpp"
38 static_assert(table_size_bits_ <= 30u,
"hxhandle_table is designed for 2^30 or less slots");
56 template<
typename deleter_u_>
57 void clear(deleter_u_&& deleter_)
noexcept;
69 template<
typename deleter_u_>
81 template<
typename callable_t_>
115 template<
typename deleter_u_>
142 void build_free_list_(
void);
144 hxdetail_::hxpow2_allocator_<slot_t_, table_size_bits_, false> m_table_;
146 slot_t_* m_free_head_;
149#include "detail/hxhandle_table.inl"
hxdefault_delete - A callable that deletes objects of type T using hxdelete.
Definition hxmemory_manager.h:254
hxdo_not_delete - A version of hxdefault_delete that does not delete the object.
Definition hxmemory_manager.h:267
hxsize_t max_size(void) const
Returns the maximum number of values that can be stored.
Definition hxhandle_table.hpp:119
hxsize_t capacity(void) const
Returns the number of slots in the table.
Definition hxhandle_table.hpp:51
deleter_t_ & deleter(void)
Returns a reference to the stored deleter.
hxhandle_t insert(hxptr< T, deleter_u_ > &&ptr_) noexcept
Takes ownership of the value owned by ptr and returns a non-zero handle referencing it.
hxhandle_t insert(T *ptr_) noexcept
Takes ownership of ptr and returns a non-zero handle referencing it.
const T * get(hxhandle_t handle_) const noexcept
const version of get.
bool full(void) const
Checks if the table is full.
Definition hxhandle_table.hpp:90
hxptr< T, deleter_t_ > extract(hxhandle_t handle_) noexcept
Returns an hxptr owning the value referenced by handle, or an empty hxptr if handle does not resolve.
bool empty(void) const
Checks if the table is empty.
Definition hxhandle_table.hpp:63
const deleter_t_ & deleter(void) const
Returns a const reference to the stored deleter.
void set_size_bits(uint32_t bits_)
Sets the number of index bits and allocates memory for the table (only for dynamic capacity).
hxhandle_table(deleter_t_ deleter_=deleter_t_())
Constructs an empty table with a capacity of 2^table_size_bits slots and an optional deleter instance...
T value_t
Definition hxhandle_table.hpp:40
void clear(deleter_u_ &&deleter_) noexcept
Removes all values and if deleter is true then calls deleter() on every value.
bool erase(hxhandle_t handle_) noexcept
Removes and calls the stored deleter on the value referenced by handle.
Definition hxhandle_table.hpp:75
hxsize_t erase_if(callable_t_ &&callable_) noexcept
Returns the number of values destroyed.
bool erase(hxhandle_t handle_, deleter_u_ &&deleter_) noexcept
Releases the value referenced by handle if deleter is true then calls deleter on it.
hxsize_t size(void) const
Returns the number of values in the table.
Definition hxhandle_table.hpp:130
void release_all(void) noexcept
Clears the table without deleting any values.
Definition hxhandle_table.hpp:122
void clear(void) noexcept
Removes all values and calls the stored deleter on every value.
Definition hxhandle_table.hpp:60
~hxhandle_table(void)
Destructs the table and deletes all owned values.
T * get(hxhandle_t handle_) noexcept
Returns the value referenced by handle if it resolves, otherwise hxnull.
hxptr<T, deleter_t> - A unique owning pointer.
Definition hxptr.hpp:30
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 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
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