ViewRaggedStorage
ViewRaggedStorage
View-based ragged storage that references another storage. More…
#include <RaggedStorage.hpp>
Inherits from RaggedStorageBase< ViewRaggedStorage< TData >, TData >
Public Functions
| Name | |
|---|---|
| ViewRaggedStorage(std::shared_ptr< OwningRaggedStorage< TData > const > source) Construct a view referencing source storage. |
|
| void | setIndices(std::vector< size_t > indices) Set the indices this view includes. |
| void | setAllIndices() Create view of all entries (useful as starting point for chained operations). |
| template <typename EntityIdContainer > void |
filterByEntityIds(EntityIdContainer const & entity_ids) Filter by EntityId set. |
| void | filterByTimeRange(TimeFrameIndex start, TimeFrameIndex end) Filter by time range [start, end] inclusive. |
| std::shared_ptr< OwningRaggedStorage< TData > const > | source() const Get the source storage. |
| std::vector< size_t > const & | indices() const Get the indices vector. |
| size_t | sizeImpl() const |
| TimeFrameIndex | getTimeImpl(size_t idx) const |
| TData const & | getDataImpl(size_t idx) const |
| EntityId | getEntityIdImpl(size_t idx) const |
| std::optional< size_t > | findByEntityIdImpl(EntityId id) const |
| std::pair< size_t, size_t > | getTimeRangeImpl(TimeFrameIndex time) const |
| size_t | getTimeCountImpl() const |
| RaggedStorageType | getStorageTypeImpl() const |
| RaggedStorageCache< TData > | tryGetCacheImpl() const Return cache if view is contiguous, otherwise invalid cache. |
Additional inherited members
Public Functions inherited from RaggedStorageBase< ViewRaggedStorage< TData >, TData >
| 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 inherited from RaggedStorageBase< ViewRaggedStorage< TData >, TData >
| Name | |
|---|---|
| ~RaggedStorageBase() =default |
Detailed Description
template <typename TData >
class ViewRaggedStorage;View-based ragged storage that references another storage.
Template Parameters:
Holds a shared_ptr to a source OwningRaggedStorage and a vector of indices into that source. This enables:
Public Functions Documentation
function ViewRaggedStorage
inline explicit ViewRaggedStorage(
std::shared_ptr< OwningRaggedStorage< TData > const > source
)Construct a view referencing source storage.
Parameters:
- source Shared pointer to source storage (must remain valid)
function setIndices
inline void setIndices(
std::vector< size_t > indices
)Set the indices this view includes.
Parameters:
- indices Vector of source indices (will be moved)
The indices refer to positions in the source storage. Call this after construction to define what the view shows.
function setAllIndices
inline void setAllIndices()Create view of all entries (useful as starting point for chained operations).
function filterByEntityIds
template <typename EntityIdContainer >
inline void filterByEntityIds(
EntityIdContainer const & entity_ids
)Filter by EntityId set.
Parameters:
- entity_ids Set of EntityIds to include
Creates indices for all entries whose EntityId is in the set.
function filterByTimeRange
inline void filterByTimeRange(
TimeFrameIndex start,
TimeFrameIndex end
)Filter by time range [start, end] inclusive.
Parameters:
- start Start TimeFrameIndex (inclusive)
- end End TimeFrameIndex (inclusive)
function source
inline std::shared_ptr< OwningRaggedStorage< TData > const > source() constGet the source storage.
function indices
inline std::vector< size_t > const & indices() constGet the indices vector.
function sizeImpl
inline size_t sizeImpl() constfunction getTimeImpl
inline TimeFrameIndex getTimeImpl(
size_t idx
) constfunction getDataImpl
inline TData const & getDataImpl(
size_t idx
) constfunction getEntityIdImpl
inline EntityId getEntityIdImpl(
size_t idx
) constfunction findByEntityIdImpl
inline std::optional< size_t > findByEntityIdImpl(
EntityId id
) constfunction getTimeRangeImpl
inline std::pair< size_t, size_t > getTimeRangeImpl(
TimeFrameIndex time
) constfunction getTimeCountImpl
inline size_t getTimeCountImpl() constfunction getStorageTypeImpl
inline RaggedStorageType getStorageTypeImpl() constfunction tryGetCacheImpl
inline RaggedStorageCache< TData > tryGetCacheImpl() constReturn cache if view is contiguous, otherwise invalid cache.
ViewRaggedStorage can provide a valid cache when the indices form a contiguous range (e.g., all elements, or a consecutive subset). This enables zero-overhead iteration for common view patterns.
Contiguous cases:
- All indices: _indices == [0, 1, 2, …, n-1]
- Consecutive range: _indices == [k, k+1, …, m]
Non-contiguous cases (must use virtual dispatch):
- Filtered by entity IDs (sparse)
- Non-consecutive time ranges
Updated on 2026-11-13 at 20:25:39 +0000