OwningRaggedStorage
OwningRaggedStorage
Owning ragged storage using Structure of Arrays layout. More…
#include <RaggedStorage.hpp>
Inherits from RaggedStorageBase< OwningRaggedStorage< TData >, TData >
Public Functions
| Name | |
|---|---|
| OwningRaggedStorage() =default | |
| void | append(TimeFrameIndex time, TData && data, EntityId entity_id) Append a new entry. |
| void | append(TimeFrameIndex time, TData const & data, EntityId entity_id) Append a new entry (copy version). |
| void | reserve(size_t capacity) Reserve capacity for expected number of entries. |
| void | clear() Clear all data. |
| bool | removeByEntityId(EntityId entity_id) Remove entry by EntityId. |
| size_t | removeByEntityIds(std::unordered_set< EntityId > const & entity_ids) Remove multiple entries by EntityId in a single O(n + k) pass. |
| size_t | removeAtTime(TimeFrameIndex time) Remove all entries at a specific time. |
| 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 Get cache with pointers to contiguous data. |
| std::vector< TimeFrameIndex > const & | times() const |
| std::vector< TData > const & | data() const |
| std::vector< EntityId > const & | entityIds() const |
| std::span< TimeFrameIndex const > | timesSpan() const |
| std::span< TData const > | dataSpan() const |
| std::span< EntityId const > | entityIdsSpan() const |
| TData & | getMutableData(size_t idx) Get mutable reference to data (use with caution). |
| std::map< TimeFrameIndex, std::pair< size_t, size_t > > const & | timeRanges() const Get the time ranges map for iteration. |
Additional inherited members
Public Functions inherited from RaggedStorageBase< OwningRaggedStorage< 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< OwningRaggedStorage< TData >, TData >
| Name | |
|---|---|
| ~RaggedStorageBase() =default |
Detailed Description
template <typename TData >
class OwningRaggedStorage;Owning ragged storage using Structure of Arrays layout.
Template Parameters:
Stores data in parallel vectors for cache-friendly access:
- _times[i] - TimeFrameIndex for entry i
- _data[i] - TData for entry i
- _entity_ids[i] - EntityId for entry i
Maintains acceleration structures:
- _entity_to_index: O(1) EntityId lookup
- _time_ranges: O(log n) time range lookup
Public Functions Documentation
function OwningRaggedStorage
OwningRaggedStorage() =defaultfunction append
inline void append(
TimeFrameIndex time,
TData && data,
EntityId entity_id
)Append a new entry.
Parameters:
- time The TimeFrameIndex for this entry
- data The data to store (will be moved)
- entity_id The EntityId for this entry
Tail append at a new time is O(1). Revisiting an existing time inserts at the end of that time’s contiguous block (O(n) shift when interleaved).
function append
inline void append(
TimeFrameIndex time,
TData const & data,
EntityId entity_id
)Append a new entry (copy version).
function reserve
inline void reserve(
size_t capacity
)Reserve capacity for expected number of entries.
function clear
inline void clear()Clear all data.
function removeByEntityId
inline bool removeByEntityId(
EntityId entity_id
)Remove entry by EntityId.
Parameters:
- entity_id The EntityId to remove
Return: true if found and removed, false otherwise
Note: This is O(n) due to vector erasure. For bulk removal, consider collecting indices and using removeByIndices().
function removeByEntityIds
inline size_t removeByEntityIds(
std::unordered_set< EntityId > const & entity_ids
)Remove multiple entries by EntityId in a single O(n + k) pass.
Parameters:
- entity_ids Set of EntityIds to remove
Return: Number of entries actually removed
Note: O(n + k) compared to O(n * k) for repeated removeByEntityId calls.
function removeAtTime
inline size_t removeAtTime(
TimeFrameIndex time
)Remove all entries at a specific time.
Parameters:
- time The TimeFrameIndex to remove all entries for
Return: Number of entries removed
Note: More efficient than calling removeByEntityId multiple times
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() constGet cache with pointers to contiguous data.
OwningRaggedStorage stores data contiguously in SoA layout, so it always returns a valid cache for fast-path iteration.
function times
inline std::vector< TimeFrameIndex > const & times() constfunction data
inline std::vector< TData > const & data() constfunction entityIds
inline std::vector< EntityId > const & entityIds() constfunction timesSpan
inline std::span< TimeFrameIndex const > timesSpan() constfunction dataSpan
inline std::span< TData const > dataSpan() constfunction entityIdsSpan
inline std::span< EntityId const > entityIdsSpan() constfunction getMutableData
inline TData & getMutableData(
size_t idx
)Get mutable reference to data (use with caution).
Modifications through this reference do not update acceleration structures. Only use for in-place modifications that don’t change EntityId or time.
function timeRanges
inline std::map< TimeFrameIndex, std::pair< size_t, size_t > > const & timeRanges() constGet the time ranges map for iteration.
Updated on 2026-11-13 at 20:25:40 +0000