OwningDigitalEventStorage
OwningDigitalEventStorage
Owning digital event storage using Structure of Arrays layout. More…
#include <OwningDigitalEventStorage.hpp>
Inherits from DigitalEventStorageBase< OwningDigitalEventStorage >
Public Functions
| Name | |
|---|---|
| OwningDigitalEventStorage() =default | |
| OwningDigitalEventStorage(std::vector< TimeFrameIndex > events) Construct from existing event vector (will sort). |
|
| OwningDigitalEventStorage(std::vector< TimeFrameIndex > events, std::vector< EntityId > entity_ids) Construct from existing event and entity ID vectors. |
|
| bool | addEvent(TimeFrameIndex time, EntityId entity_id) Add an event at the specified time. |
| bool | removeEvent(TimeFrameIndex time) Remove an event at the specified time. |
| bool | removeByEntityId(EntityId id) Remove an event by EntityId. |
| void | clear() Clear all events. |
| void | reserve(size_t capacity) Reserve capacity for expected number of events. |
| void | setEntityIds(std::vector< EntityId > ids) Set all entity IDs (must match event count). |
| size_t | sizeImpl() const |
| TimeFrameIndex | getEventImpl(size_t idx) const |
| EntityId | getEntityIdImpl(size_t idx) const |
| std::optional< size_t > | findByTimeImpl(TimeFrameIndex time) const |
| std::optional< size_t > | findByEntityIdImpl(EntityId id) const |
| std::pair< size_t, size_t > | getTimeRangeImpl(TimeFrameIndex start, TimeFrameIndex end) const |
| DigitalEventTimeDomain | getTimeDomainImpl() const |
| DigitalEventStorageType | getStorageTypeImpl() const |
| DigitalEventStorageCache | tryGetCacheImpl() const Get cache with pointers to contiguous data. |
| std::vector< TimeFrameIndex > const & | events() const |
| std::vector< EntityId > const & | entityIds() const |
| std::span< TimeFrameIndex const > | eventsSpan() const |
| std::span< EntityId const > | entityIdsSpan() const |
Additional inherited members
Public Functions inherited from DigitalEventStorageBase< OwningDigitalEventStorage >
| Name | |
|---|---|
| size_t | size() const Get total number of events. |
| bool | empty() const Check if storage is empty. |
| TimeFrameIndex | getEvent(size_t idx) const Get the event time at a flat index. |
| EntityId | getEntityId(size_t idx) const Get the EntityId at a flat index. |
| std::optional< size_t > | findByTime(TimeFrameIndex time) const Find the index of an event by its exact time. |
| std::optional< size_t > | findByEntityId(EntityId id) const Find the index of an event by its EntityId. |
| bool | hasEventAtTime(TimeFrameIndex time) const Check if an event exists at a specific time. |
| std::pair< size_t, size_t > | getTimeRange(TimeFrameIndex start, TimeFrameIndex end) const Get range of indices for events in [start, end] inclusive. |
| DigitalEventTimeDomain | getTimeDomain() const Get the time coordinate domain for this storage. |
| bool | isRelative() const Check if events are stored as relative ClockTicks. |
| ClockTicks | getRelativeEvent(size_t idx) const Get the relative event time at a flat index. |
| std::optional< size_t > | findByRelativeTime(ClockTicks time) const Find the index of an event by its exact relative time. |
| std::pair< size_t, size_t > | getRelativeTimeRange(ClockTicks start, ClockTicks end) const Get range of indices for events in [start, end] inclusive (relative time). |
| DigitalEventStorageType | getStorageType() const Get the storage type identifier. |
| bool | isView() const Check if this is a view (doesn’t own data). |
| bool | isLazy() const Check if this is lazy storage. |
| bool | isRelativeOwning() const Check if this is relative owning storage. |
| DigitalEventStorageCache | tryGetCache() const Try to get cached pointers for fast-path access. |
Protected Functions inherited from DigitalEventStorageBase< OwningDigitalEventStorage >
| Name | |
|---|---|
| ~DigitalEventStorageBase() =default |
Detailed Description
class OwningDigitalEventStorage;Owning digital event storage using Structure of Arrays layout.
Stores event data in parallel vectors for cache-friendly access:
- _events[i] - TimeFrameIndex for event i (sorted)
- _entity_ids[i] - EntityId for event i
Maintains acceleration structures:
- Events are always sorted by time
- O(log n) lookup by time using binary search
- O(1) lookup by EntityId using hash map
Public Functions Documentation
function OwningDigitalEventStorage
OwningDigitalEventStorage() =defaultfunction OwningDigitalEventStorage
explicit OwningDigitalEventStorage(
std::vector< TimeFrameIndex > events
)Construct from existing event vector (will sort).
function OwningDigitalEventStorage
OwningDigitalEventStorage(
std::vector< TimeFrameIndex > events,
std::vector< EntityId > entity_ids
)Construct from existing event and entity ID vectors.
Note: Both vectors must be the same size.
function addEvent
bool addEvent(
TimeFrameIndex time,
EntityId entity_id
)Add an event at the specified time.
Parameters:
- time The event time.
- entity_id The EntityId for this event.
Return: true if added, false if duplicate time.
If an event already exists at this exact time, it is not added (returns false).
function removeEvent
bool removeEvent(
TimeFrameIndex time
)Remove an event at the specified time.
Return: true if removed, false if not found.
function removeByEntityId
bool removeByEntityId(
EntityId id
)Remove an event by EntityId.
Return: true if removed, false if not found.
function clear
void clear()Clear all events.
function reserve
void reserve(
size_t capacity
)Reserve capacity for expected number of events.
function setEntityIds
void setEntityIds(
std::vector< EntityId > ids
)Set all entity IDs (must match event count).
function sizeImpl
inline size_t sizeImpl() constfunction getEventImpl
inline TimeFrameIndex getEventImpl(
size_t idx
) constfunction getEntityIdImpl
inline EntityId getEntityIdImpl(
size_t idx
) constfunction findByTimeImpl
std::optional< size_t > findByTimeImpl(
TimeFrameIndex time
) constfunction findByEntityIdImpl
std::optional< size_t > findByEntityIdImpl(
EntityId id
) constfunction getTimeRangeImpl
std::pair< size_t, size_t > getTimeRangeImpl(
TimeFrameIndex start,
TimeFrameIndex end
) constfunction getTimeDomainImpl
inline DigitalEventTimeDomain getTimeDomainImpl() constfunction getStorageTypeImpl
inline DigitalEventStorageType getStorageTypeImpl() constfunction tryGetCacheImpl
inline DigitalEventStorageCache tryGetCacheImpl() constGet cache with pointers to contiguous data.
OwningDigitalEventStorage stores data contiguously in SoA layout, so it always returns a valid cache for fast-path iteration.
function events
inline std::vector< TimeFrameIndex > const & events() constfunction entityIds
inline std::vector< EntityId > const & entityIds() constfunction eventsSpan
inline std::span< TimeFrameIndex const > eventsSpan() constfunction entityIdsSpan
inline std::span< EntityId const > entityIdsSpan() constUpdated on 2026-11-13 at 20:25:40 +0000