CombinedStateToIdMapPair Class Template
Maps combined state pairs directly to ID lists. More...
Declaration
Public Member Functions Index
template <typename LState, typename RState, typename TId> | |
| CombinedStateToIdMapPair & | add (const LState stateLft, const RState stateRgt, const TId id) noexcept |
|
Adds an ID for a specific state combination. More... | |
template <typename LState, typename RState, typename TId> | |
| void | finalize () |
|
Sorts and deduplicates all ID lists. More... | |
template <typename LState, typename RState, typename TId> | |
| void | freeze () |
|
Finalizes and prevents further modifications. More... | |
template <typename LState, typename RState, typename TId> | |
| bool | isFrozen () const noexcept |
|
Checks if the map is frozen. More... | |
template <typename LState, typename RState, typename TId> | |
| auto | ids (const LState stateLft, const RState stateRgt) const noexcept -> std::span< const TId > |
|
Returns IDs for a state combination. More... | |
Private Member Attributes Index
template <typename LState, typename RState, typename TId> | |
| std::vector< std::vector< std::vector< TId > > > | states_ |
|
2D matrix of ID lists indexed by [LState][RState]. More... | |
template <typename LState, typename RState, typename TId> | |
| const std::vector< TId > | empty_ |
|
Empty vector returned for invalid lookups. More... | |
template <typename LState, typename RState, typename TId> | |
| bool | frozen_ = false |
|
Whether the map is frozen. More... | |
Private Static Functions Index
template <typename LState, typename RState, typename TId> | |
| static constexpr size_t | indexOf (const LState stateLft) |
|
Computes the index for a left state value. More... | |
template <typename LState, typename RState, typename TId> | |
| static constexpr size_t | indexOf (const RState stateRgt) |
|
Computes the index for a right state value. More... | |
Description
Maps combined state pairs directly to ID lists.
Unlike StateToIdMapPair which stores IDs per state type and merges them at lookup time, this class uses a 2D matrix indexed by both state bit positions. This allows associating IDs with specific state combinations rather than individual states.
The right state (RState) supports an "undefined" value (0) which maps to index 0, allowing fallback behavior when only the left state is defined.
- Template Parameters
-
LState The left/primary state type.
RState The right/secondary state type.
TId The ID type to associate with state combinations.
- See Also
Definition at line 51 of file CombinedStateToIdMapPair.ixx.
Public Member Functions
add()
| inline noexcept |
Adds an ID for a specific state combination.
- Parameters
-
stateLft The left state (must be non-zero).
stateRgt The right state (may be 0 for fallback).
id The ID to associate with this combination.
- Returns
Reference to this map for chaining.
Definition at line 117 of file CombinedStateToIdMapPair.ixx.
finalize()
| inline |
Sorts and deduplicates all ID lists.
Definition at line 143 of file CombinedStateToIdMapPair.ixx.
Referenced by helios::engine::state::CombinedStateToIdMapPair< LState, RState, TId >::freeze.
freeze()
| inline |
Finalizes and prevents further modifications.
Definition at line 156 of file CombinedStateToIdMapPair.ixx.
Reference helios::engine::state::CombinedStateToIdMapPair< LState, RState, TId >::finalize.
ids()
| inline nodiscard noexcept |
Returns IDs for a state combination.
If the specific combination has no IDs, falls back to the IDs registered for the left state with undefined right state.
- Parameters
-
stateLft The left state to query.
stateRgt The right state to query.
- Returns
Span of IDs for the state combination.
Definition at line 181 of file CombinedStateToIdMapPair.ixx.
isFrozen()
| inline nodiscard noexcept |
Checks if the map is frozen.
- Returns
True if frozen.
Definition at line 166 of file CombinedStateToIdMapPair.ixx.
Private Member Attributes
empty_
|
Empty vector returned for invalid lookups.
Definition at line 61 of file CombinedStateToIdMapPair.ixx.
frozen_
|
Whether the map is frozen.
Definition at line 66 of file CombinedStateToIdMapPair.ixx.
states_
|
2D matrix of ID lists indexed by [LState][RState].
Definition at line 56 of file CombinedStateToIdMapPair.ixx.
Private Static Functions
indexOf()
| inline nodiscard constexpr static |
Computes the index for a left state value.
- Parameters
-
stateLft The left state (must be non-zero, power of 2).
- Returns
The bit position index.
Definition at line 75 of file CombinedStateToIdMapPair.ixx.
indexOf()
| inline nodiscard constexpr static |
Computes the index for a right state value.
Supports undefined (0) state which maps to index 0. Non-zero states map to their bit position + 1.
- Parameters
-
stateRgt The right state (may be 0, otherwise power of 2).
- Returns
The index (0 for undefined, bit position + 1 otherwise).
Definition at line 94 of file CombinedStateToIdMapPair.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.