RaggedStorageBase
RaggedStorageBase
CRTP base class for ragged storage implementations. More…
#include <RaggedStorage.hpp>
Public Functions
| Name | |
|---|---|
| size_t | size() const Get total number of entries across all times. |
| bool | empty() const Check if storage is empty. |
| TimeFrameIndex | getTime(size_t idx) const Get the TimeFrameIndex at a flat index. |
| TData const & | getData(size_t idx) const Get const reference to data at a flat index. |
| EntityId | getEntityId(size_t idx) const Get the EntityId at a flat index. |
| std::optional< size_t > | findByEntityId(EntityId id) const Find flat index by EntityId. |
| std::pair< size_t, size_t > | getTimeRange(TimeFrameIndex time) const Get range of flat indices for a specific time. |
| size_t | getTimeCount() const Get number of distinct times with data. |
| RaggedStorageType | getStorageType() const Get the storage type identifier. |
| bool | isView() const Check if this is a view (doesn’t own data). |
| RaggedStorageCache< TData > | tryGetCache() const Try to get cached pointers for fast-path access. |
Protected Functions
| Name | |
|---|---|
| ~RaggedStorageBase() =default |
Detailed Description
template <typename Derived ,
typename TData >
class RaggedStorageBase;CRTP base class for ragged storage implementations.
Template Parameters:
- Derived The concrete storage implementation type
- TData The data type stored (e.g., Mask2D, Line2D, Point2D
)
Uses Curiously Recurring Template Pattern to eliminate virtual function overhead while maintaining a polymorphic interface. Derived classes implement the actual storage strategy (owning SoA or view/filter).
The SoA (Structure of Arrays) layout stores parallel vectors:
- TimeFrameIndex times[]
- TData data[]
- EntityId entity_ids[]
This provides:
- O(1) EntityId lookup via hash map
- Cache-friendly sequential iteration
- Efficient view creation without data copying
Public Functions Documentation
function size
inline size_t size() constGet total number of entries across all times.
function empty
inline bool empty() constCheck if storage is empty.
function getTime
inline TimeFrameIndex getTime(
size_t idx
) constGet the TimeFrameIndex at a flat index.
Parameters:
- idx Flat index in [0, size())
function getData
inline TData const & getData(
size_t idx
) constGet const reference to data at a flat index.
Parameters:
- idx Flat index in [0, size())
function getEntityId
inline EntityId getEntityId(
size_t idx
) constGet the EntityId at a flat index.
Parameters:
- idx Flat index in [0, size())
function findByEntityId
inline std::optional< size_t > findByEntityId(
EntityId id
) constFind flat index by EntityId.
Parameters:
- id The EntityId to find
Return: Flat index if found, std::nullopt otherwise
Note: O(1) for OwningRaggedStorage, O(1) for ViewRaggedStorage
function getTimeRange
inline std::pair< size_t, size_t > getTimeRange(
TimeFrameIndex time
) constGet range of flat indices for a specific time.
Parameters:
- time The TimeFrameIndex to query
Return: Pair of (start_idx, end_idx) where end is exclusive, or (0,0) if not found
function getTimeCount
inline size_t getTimeCount() constGet number of distinct times with data.
function getStorageType
inline RaggedStorageType getStorageType() constGet the storage type identifier.
function isView
inline bool isView() constCheck if this is a view (doesn’t own data).
function tryGetCache
inline RaggedStorageCache< TData > tryGetCache() constTry to get cached pointers for fast-path access.
Return: RaggedStorageCache
Returns a cache structure with direct pointers to contiguous data. If the storage is non-contiguous (e.g., ViewRaggedStorage), returns an invalid cache and callers must use the virtual dispatch path.
Protected Functions Documentation
function ~RaggedStorageBase
~RaggedStorageBase() =defaultUpdated on 2026-11-13 at 20:25:40 +0000