libhatchet
Loading...
Searching...
No Matches
hxhandle_map< T, table_size_bits_ > Class Template Reference

#include <hxhandle_map.hpp>

Public Types

using iterator = T*
using const_iterator = const T*
using value_t = T

Public Member Functions

 hxhandle_map (void)
 ~hxhandle_map ()
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)
const T * end (void) const
T * end (void)
bool empty (void) const
bool erase (hxhandle_t handle_) noexcept
template<typename callable_t_>
hxsize_t erase_if (callable_t_ &&callable_) noexcept
bool full (void) const
T * get (hxhandle_t handle_) noexcept
const T * get (hxhandle_t handle_) const noexcept
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
void set_size_bits (uint32_t bits_)
hxsize_t size (void) const

Detailed Description

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
class hxhandle_map< T, table_size_bits_ >

hxhandle_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 erase and insert 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.

  • T : The value type stored in the map.
  • table_size_bits : If non-zero, sets the capacity to 2^table_size_bits - 1 values. Otherwise the size is dynamic.

Member Typedef Documentation

◆ const_iterator

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
using hxhandle_map< T, table_size_bits_ >::const_iterator = const T*

const_iterator - Const random access iterator.

◆ iterator

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
using hxhandle_map< T, table_size_bits_ >::iterator = T*

iterator - Random access iterator.

◆ value_t

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
using hxhandle_map< T, table_size_bits_ >::value_t = T

Constructor & Destructor Documentation

◆ hxhandle_map()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxhandle_map< T, table_size_bits_ >::hxhandle_map ( void )

Constructs an empty map with a capacity of 2^table_size_bits - 1.

◆ ~hxhandle_map()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxhandle_map< T, table_size_bits_ >::~hxhandle_map ( )

Destructs the map and destroys all values.

Member Function Documentation

◆ begin() [1/2]

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
T * hxhandle_map< T, table_size_bits_ >::begin ( void )
inline

Returns a T* to the beginning of the values (alias for data).

Iterators are invalidated by modification of the table.

◆ begin() [2/2]

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const T * hxhandle_map< T, table_size_bits_ >::begin ( void ) const
inline

Returns a const T* to the beginning of the values (alias for data).

Iterators are invalidated by modification of the table.

◆ capacity()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhandle_map< T, table_size_bits_ >::capacity ( void ) const
inline

Returns the number of values that can be stored.

◆ cbegin()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const T * hxhandle_map< T, table_size_bits_ >::cbegin ( void ) const
inline

Returns a const T* to the beginning of the values (alias for begin).

Iterators are invalidated by modification of the table.

◆ cend()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const T * hxhandle_map< T, table_size_bits_ >::cend ( void ) const
inline

Returns a const T* to the end of the values.

Iterators are invalidated by modification of the table.

◆ clear()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
void hxhandle_map< T, table_size_bits_ >::clear ( void )
noexcept

Destroys all values and invalidates their handles.

◆ data() [1/2]

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
T * hxhandle_map< T, table_size_bits_ >::data ( void )
inline

Returns a pointer to the first of size contiguous values.

◆ data() [2/2]

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const T * hxhandle_map< T, table_size_bits_ >::data ( void ) const
inline

Returns a const pointer to the first of size contiguous values.

◆ empty()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
bool hxhandle_map< T, table_size_bits_ >::empty ( void ) const
inline

Checks if the map is empty.

◆ end() [1/2]

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
T * hxhandle_map< T, table_size_bits_ >::end ( void )
inline

Returns a T* to the end of the values.

Iterators are invalidated by modification of the table.

◆ end() [2/2]

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const T * hxhandle_map< T, table_size_bits_ >::end ( void ) const
inline

Returns a const T* to the end of the values.

Iterators are invalidated by modification of the table.

◆ erase()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
bool hxhandle_map< T, table_size_bits_ >::erase ( hxhandle_t handle_)
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.

  • handle : The handle identifying the value to remove.

◆ erase_if()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename callable_t_>
hxsize_t hxhandle_map< T, table_size_bits_ >::erase_if ( callable_t_ && callable_)
noexcept

Returns the number of values destroyed.

Calls callable with a T& for every value and destroys those for which it returns true.

  • callable : Returns true for values to erase.

◆ full()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
bool hxhandle_map< T, table_size_bits_ >::full ( void ) const
inline

Checks if the map is full.

◆ get() [1/2]

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
const T * hxhandle_map< T, table_size_bits_ >::get ( hxhandle_t handle_) const
noexcept

const version of get.

  • handle : The handle identifying the value to look up.

◆ get() [2/2]

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
T * hxhandle_map< T, table_size_bits_ >::get ( hxhandle_t handle_)
noexcept

Returns a pointer to the value referenced by handle if it resolves, otherwise hxnull.

  • handle : The handle identifying the value to look up.

◆ handle_at()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxhandle_t hxhandle_map< T, table_size_bits_ >::handle_at ( hxsize_t index_) const
noexcept

Returns the handle for the value at begin() + index.

  • index : The offset of the value in [0, size()) to get a handle for.

◆ insert()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
template<typename... args_t_>
hxhandle_t hxhandle_map< T, table_size_bits_ >::insert ( args_t_ &&... args_)
noexcept

Returns a non-zero handle referencing a value constructed at the end of data from args.

The map must not be full.

  • args : Arguments forwarded to T's constructor.

◆ max_size()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhandle_map< T, table_size_bits_ >::max_size ( void ) const
inline

Returns the maximum number of values that can be stored.

◆ set_size_bits()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
void hxhandle_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).

  • bits : The number of index bits to set for the map, in the range [1, 30].

◆ size()

template<typename T, uint32_t table_size_bits_ = hxallocator_dynamic_capacity>
hxsize_t hxhandle_map< T, table_size_bits_ >::size ( void ) const
inline

Returns the number of values in the map.


The documentation for this class was generated from the following file: