|
libhatchet
|
#include <hxslot_map.hpp>
Public Types | |
| using | iterator = T* |
| using | const_iterator = const T* |
| using | value_t = T |
Public Member Functions | |
| hxslot_map (void) | |
| ~hxslot_map () | |
| template<typename self_t_, typename callable_t_> | |
| auto | and_then (this self_t_ &&self_, hxhandle_t handle_, callable_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< T & >())))> |
| const T * | begin (void) const |
| T * | begin (void) |
| hxsize_t | capacity (void) const |
| const T * | cbegin (void) const |
| const T * | cend (void) const |
| void | clear (void) noexcept |
| const T * | data (void) const |
| T * | data (void) |
| template<typename... args_t_> | |
| hxhandle_t | emplace (args_t_ &&... args_) noexcept |
| bool | empty (void) const |
| const T * | end (void) const |
| T * | end (void) |
| template<typename callable_t_> | |
| hxsize_t | erase_if (callable_t_ &&callable_) noexcept |
| bool | full (void) const |
| hxhandle_t | handle_at (hxsize_t index_) const noexcept |
| template<typename... args_t_> | |
| hxhandle_t | insert (args_t_ &&... args_) noexcept |
| hxsize_t | max_size (void) const |
| template<typename self_t_, typename callable_t_> | |
| auto | or_else (this self_t_ &&self_, hxhandle_t handle_, callable_t_ &&callable_) -> decltype(self_.end()) |
| bool | reset (hxhandle_t handle_) noexcept |
| void | set_size_bits (uint32_t bits_) |
| hxsize_t | size (void) const |
| T * | value (hxhandle_t handle_) noexcept |
| const T * | value (hxhandle_t handle_) const noexcept |
| template<typename self_t_, typename... args_t_> | |
| T | value_or (this self_t_ &&self_, hxhandle_t handle_, args_t_ &&... args_) |
hxslot_map - A table that maps 64-bit generational handles to values kept in a contiguous array of size 2^table_size_bits - 1 without reallocating memory.
data() always references size() contiguous values. Pointers into data are invalidated by reset while handles are not. Handle 0 is never valid. If non-zero, the template parameter table_size_bits configures the capacity to 2^table_size_bits - 1 values. Otherwise use set_size_bits to configure the size dynamically.
| using hxslot_map< T, table_size_bits_ >::const_iterator = const T* |
const_iterator - Const random access iterator.
| using hxslot_map< T, table_size_bits_ >::iterator = T* |
iterator - Random access iterator.
| using hxslot_map< T, table_size_bits_ >::value_t = T |
| hxslot_map< T, table_size_bits_ >::hxslot_map | ( | void | ) |
Constructs an empty map with a capacity of 2^table_size_bits - 1.
| hxslot_map< T, table_size_bits_ >::~hxslot_map | ( | ) |
Destructs the map and destroys all values.
| auto hxslot_map< T, table_size_bits_ >::and_then | ( | this self_t_ && | self_, |
| hxhandle_t | handle_, | ||
| callable_t_ && | callable_ )->hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< T & >())))> |
Returns the result of calling callable with the value referenced by handle, otherwise returns hxnil.
Use and_then to return hxptr, hxref or hxexpected.
|
inline |
|
inline |
Returns a const T* to the beginning of the values (alias for data).
Iterators are invalidated by modification of the table.
| hxsize_t hxslot_map< T, table_size_bits_ >::capacity | ( | void | ) | const |
Returns the number of values that can be stored.
|
inline |
Returns a const T* to the beginning of the values (alias for begin).
Iterators are invalidated by modification of the table.
| const T * hxslot_map< T, table_size_bits_ >::cend | ( | void | ) | const |
Returns a const T* to the end of the values.
Iterators are invalidated by modification of the table.
|
noexcept |
Destroys all values and invalidates their handles.
|
inline |
|
inline |
Returns a const pointer to the first of size contiguous values.
|
noexcept |
Returns a non-zero handle referencing a value constructed at the end of data from args.
The map must not be full.
|
inline |
Checks if the map is empty.
|
inline |
| const T * hxslot_map< T, table_size_bits_ >::end | ( | void | ) | const |
Returns a const T* to the end of the values.
Iterators are invalidated by modification of the table.
|
noexcept |
Returns the number of values destroyed.
Calls callable with a T& for every value and destroys those for which it returns true.
| bool hxslot_map< T, table_size_bits_ >::full | ( | void | ) | const |
Checks if the map is full.
|
noexcept |
|
noexcept |
Returns a non-zero handle referencing a value constructed at the end of data from args.
The map must not be full.
|
inline |
Returns the maximum number of values that can be stored.
| auto hxslot_map< T, table_size_bits_ >::or_else | ( | this self_t_ && | self_, |
| hxhandle_t | handle_, | ||
| callable_t_ && | callable_ )->decltype(self_.end()) |
Returns a pointer to the value referenced by handle, or the result of calling callable when the handle does not resolve.
|
noexcept |
Returns true if handle resolved and its value was destroyed.
The last value is move-assigned into the hole to keep the values contiguous.
| void hxslot_map< T, table_size_bits_ >::set_size_bits | ( | uint32_t | bits_ | ) |
Sets the number of index bits and allocates memory for the map (only for dynamic capacity).
|
inline |
Returns the number of values in the map.
|
noexcept |
|
noexcept |
Returns a pointer to the value referenced by handle if it resolves, otherwise end().
| T hxslot_map< T, table_size_bits_ >::value_or | ( | this self_t_ && | self_, |
| hxhandle_t | handle_, | ||
| args_t_ &&... | args_ ) |
Returns a copy of the value referenced by handle, or a value constructed from args when the handle does not resolve.