StateToIdMap Class Template
Maps state enum values to lists of IDs. More...
Declaration
Public Constructors Index
template <typename TState, typename TId> | |
| StateToIdMap () | |
|
Default constructor. More... | |
Public Member Functions Index
template <typename TState, typename TId> | |
| StateToIdMap & | add (TState state, TId id) noexcept |
|
Adds an ID for a given state. More... | |
template <typename TState, typename TId> | |
| void | finalize () |
|
Sorts and deduplicates all ID lists. More... | |
template <typename TState, typename TId> | |
| bool | isFrozen () const noexcept |
|
Checks if the map is frozen. More... | |
template <typename TState, typename TId> | |
| void | freeze () |
|
Finalizes and prevents further modifications. More... | |
template <typename TState, typename TId> | |
| auto | ids (const TState state) const noexcept -> const std::vector< TId > & |
|
Returns IDs for a single state. More... | |
Private Member Functions Index
template <typename TState, typename TId> | |
| void | update (size_t st, const TId id) |
|
Updates internal storage for a state-ID association. More... | |
Private Member Attributes Index
template <typename TState, typename TId> | |
| std::vector< std::vector< TId > > | states_ |
|
ID lists indexed by state bit position. More... | |
template <typename TState, typename TId> | |
| const std::vector< TId > | empty_ |
|
Empty vector returned for invalid lookups. More... | |
template <typename TState, typename TId> | |
| bool | frozen_ = false |
|
Whether the map is frozen. More... | |
Description
Maps state enum values to lists of IDs.
Provides a lookup table that associates each bit position of a state enum with a list of IDs. States must be power-of-two values (single bits). Supports finalization and freezing for runtime optimization.
- Template Parameters
-
TState The state enum type (e.g., GameState, MatchState).
TId The ID type to associate with states.
Definition at line 41 of file StateToIdMap.ixx.
Public Constructors
StateToIdMap()
| inline |
Default constructor.
Definition at line 89 of file StateToIdMap.ixx.
Referenced by helios::engine::state::StateToIdMap< TState, TId >::add.
Public Member Functions
add()
| inline noexcept |
Adds an ID for a given state.
- Parameters
-
state The state to associate the ID with.
id The ID to add.
- Returns
Reference to this map for chaining.
Definition at line 101 of file StateToIdMap.ixx.
Reference helios::engine::state::StateToIdMap< TState, TId >::StateToIdMap.
finalize()
| inline |
Sorts and deduplicates all ID lists.
Definition at line 118 of file StateToIdMap.ixx.
Referenced by helios::engine::state::StateToIdMap< TState, TId >::freeze.
freeze()
| inline |
Finalizes and prevents further modifications.
Definition at line 138 of file StateToIdMap.ixx.
Reference helios::engine::state::StateToIdMap< TState, TId >::finalize.
ids()
| inline nodiscard noexcept |
Returns IDs for a single state.
- Parameters
-
state The state to query (must be a power of 2).
- Returns
Reference to the ID list for the state.
Definition at line 151 of file StateToIdMap.ixx.
isFrozen()
| inline nodiscard noexcept |
Checks if the map is frozen.
- Returns
True if frozen.
Definition at line 131 of file StateToIdMap.ixx.
Private Member Functions
update()
| inline |
Updates internal storage for a state-ID association.
- Parameters
-
st The state value as size_t.
id The ID to associate.
Definition at line 59 of file StateToIdMap.ixx.
Private Member Attributes
empty_
|
Empty vector returned for invalid lookups.
Definition at line 51 of file StateToIdMap.ixx.
frozen_
|
states_
|
ID lists indexed by state bit position.
Definition at line 46 of file StateToIdMap.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.