Skip to main content

OwningDigitalIntervalStorage

OwningDigitalIntervalStorage

Owning digital interval storage using Structure of Arrays layout. More…

#include <OwningDigitalIntervalStorage.hpp>

Inherits from DigitalIntervalStorageBase< OwningDigitalIntervalStorage >

Public Functions

Name
OwningDigitalIntervalStorage() =default
OwningDigitalIntervalStorage(std::vector< TimeFrameInterval > intervals)
Construct from existing interval vector (will sort).
OwningDigitalIntervalStorage(std::vector< TimeFrameInterval > intervals, std::vector< EntityId > entity_ids)
Construct from existing interval and entity ID vectors.
bool addInterval(TimeFrameInterval const & interval, EntityId entity_id)
Add an interval.
bool removeInterval(TimeFrameInterval const & interval)
Remove an interval by exact match.
bool removeByEntityId(EntityId id)
Remove an interval by EntityId.
void clear()
Clear all intervals.
void reserve(size_t capacity)
Reserve capacity for expected number of intervals.
void setEntityIds(std::vector< EntityId > ids)
Set all entity IDs (must match interval count).
void setEntityId(size_t idx, EntityId id)
Set entity ID at a specific index.
void setInterval(size_t idx, TimeFrameInterval interval)
Set interval at a specific index (does not re-sort).
void removeAt(size_t idx)
Remove interval at a specific index.
void sort()
Sort intervals and entity IDs together.
void setAssumeDisjointIntervals(bool assume_disjoint)
Set whether intervals are assumed disjoint for range-query fast paths.
bool assumeDisjointIntervals() const
Whether intervals are assumed disjoint for range-query fast paths.
size_t sizeImpl() const
TimeFrameInterval const & getIntervalImpl(size_t idx) const
EntityId getEntityIdImpl(size_t idx) const
std::optional< size_t > findByIntervalImpl(TimeFrameInterval const & interval) const
std::optional< size_t > findByEntityIdImpl(EntityId id) const
bool hasIntervalAtTimeImpl(TimeFrameIndex time) const
std::pair< size_t, size_t > getOverlappingRangeImpl(TimeFrameIndex start, TimeFrameIndex end) const
Get index range of intervals overlapping [start, end].
std::pair< size_t, size_t > getContainedRangeImpl(TimeFrameIndex start, TimeFrameIndex end) const
DigitalIntervalStorageType getStorageTypeImpl() const
DigitalIntervalStorageCache tryGetCacheImpl() const
Get cache with pointers to contiguous data.
std::vector< TimeFrameInterval > const & intervals() const
std::vector< EntityId > const & entityIds() const
std::span< TimeFrameInterval const > intervalsSpan() const
std::span< EntityId const > entityIdsSpan() const

Additional inherited members

Public Functions inherited from DigitalIntervalStorageBase< OwningDigitalIntervalStorage >

Name
size_t size() const
Get total number of intervals.
bool empty() const
Check if storage is empty.
TimeFrameInterval const & getInterval(size_t idx) const
Get the interval at a flat index.
EntityId getEntityId(size_t idx) const
Get the EntityId at a flat index.
std::optional< size_t > findByInterval(TimeFrameInterval const & interval) const
Find the index of an interval by its exact start/end times.
std::optional< size_t > findByEntityId(EntityId id) const
Find the index of an interval by its EntityId.
bool hasIntervalAtTime(TimeFrameIndex time) const
Check if any interval contains the specified time.
std::pair< size_t, size_t > getOverlappingRange(TimeFrameIndex start, TimeFrameIndex end) const
Get range of indices for intervals overlapping [start, end].
std::pair< size_t, size_t > getContainedRange(TimeFrameIndex start, TimeFrameIndex end) const
Get range of indices for intervals fully contained in [start, end].
DigitalIntervalStorageType 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.
DigitalIntervalStorageCache tryGetCache() const
Try to get cached pointers for fast-path access.

Protected Functions inherited from DigitalIntervalStorageBase< OwningDigitalIntervalStorage >

Name
~DigitalIntervalStorageBase() =default

Detailed Description

class OwningDigitalIntervalStorage;

Owning digital interval storage using Structure of Arrays layout.

Stores interval data in parallel vectors for cache-friendly access:

  • _intervals[i] - Interval for entry i (sorted by start time)
  • _entity_ids[i] - EntityId for entry i

Maintains acceleration structures:

  • Intervals are always sorted by start time
  • O(log n) lookup by start time using binary search
  • O(1) lookup by EntityId using hash map

Public Functions Documentation

function OwningDigitalIntervalStorage

OwningDigitalIntervalStorage() =default

function OwningDigitalIntervalStorage

explicit OwningDigitalIntervalStorage(
    std::vector< TimeFrameInterval > intervals
)

Construct from existing interval vector (will sort).

function OwningDigitalIntervalStorage

OwningDigitalIntervalStorage(
    std::vector< TimeFrameInterval > intervals,
    std::vector< EntityId > entity_ids
)

Construct from existing interval and entity ID vectors.

Note: Both vectors must be the same size

function addInterval

bool addInterval(
    TimeFrameInterval const & interval,
    EntityId entity_id
)

Add an interval.

Parameters:

  • interval The interval to add
  • entity_id The EntityId for this interval

Return: true if added, false if duplicate

If an interval with the same start/end already exists, it is not added (returns false).

function removeInterval

bool removeInterval(
    TimeFrameInterval const & interval
)

Remove an interval by exact match.

Return: true if removed, false if not found

function removeByEntityId

bool removeByEntityId(
    EntityId id
)

Remove an interval by EntityId.

Return: true if removed, false if not found

function clear

void clear()

Clear all intervals.

function reserve

void reserve(
    size_t capacity
)

Reserve capacity for expected number of intervals.

function setEntityIds

void setEntityIds(
    std::vector< EntityId > ids
)

Set all entity IDs (must match interval count).

function setEntityId

void setEntityId(
    size_t idx,
    EntityId id
)

Set entity ID at a specific index.

function setInterval

void setInterval(
    size_t idx,
    TimeFrameInterval interval
)

Set interval at a specific index (does not re-sort).

function removeAt

void removeAt(
    size_t idx
)

Remove interval at a specific index.

function sort

void sort()

Sort intervals and entity IDs together.

function setAssumeDisjointIntervals

inline void setAssumeDisjointIntervals(
    bool assume_disjoint
)

Set whether intervals are assumed disjoint for range-query fast paths.

See:

When true (default), getOverlappingRangeImpl() uses O(log n) binary search, which requires intervals to be sorted by start and pairwise non-overlapping. When false, falls back to an O(n) linear scan that is correct for overlapping intervals. Set via DigitalIntervalSeries::_syncStorageDisjointHint() from [IntervalLayout](/api_generated/Files/Digital__Interval__Series_8hpp.md#enum-intervallayout).

function assumeDisjointIntervals

inline bool assumeDisjointIntervals() const

Whether intervals are assumed disjoint for range-query fast paths.

See: setAssumeDisjointIntervals()

function sizeImpl

inline size_t sizeImpl() const

function getIntervalImpl

inline TimeFrameInterval const & getIntervalImpl(
    size_t idx
) const

function getEntityIdImpl

inline EntityId getEntityIdImpl(
    size_t idx
) const

function findByIntervalImpl

std::optional< size_t > findByIntervalImpl(
    TimeFrameInterval const & interval
) const

function findByEntityIdImpl

std::optional< size_t > findByEntityIdImpl(
    EntityId id
) const

function hasIntervalAtTimeImpl

bool hasIntervalAtTimeImpl(
    TimeFrameIndex time
) const

function getOverlappingRangeImpl

std::pair< size_t, size_t > getOverlappingRangeImpl(
    TimeFrameIndex start,
    TimeFrameIndex end
) const

Get index range of intervals overlapping [start, end].

See:

Disjoint fast path ([assumeDisjointIntervals()](/api_generated/Classes/classOwningDigitalIntervalStorage.md#function-assumedisjointintervals) == true): O(log n) binary search on sorted starts and ends. Requires pairwise non-overlapping intervals.

Overlapping fallback ([assumeDisjointIntervals()](/api_generated/Classes/classOwningDigitalIntervalStorage.md#function-assumedisjointintervals) == false): O(n) linear scan; correct when intervals may overlap.

function getContainedRangeImpl

std::pair< size_t, size_t > getContainedRangeImpl(
    TimeFrameIndex start,
    TimeFrameIndex end
) const

function getStorageTypeImpl

inline DigitalIntervalStorageType getStorageTypeImpl() const

function tryGetCacheImpl

inline DigitalIntervalStorageCache tryGetCacheImpl() const

Get cache with pointers to contiguous data.

OwningDigitalIntervalStorage stores data contiguously in SoA layout, so it always returns a valid cache for fast-path iteration.

function intervals

inline std::vector< TimeFrameInterval > const & intervals() const

function entityIds

inline std::vector< EntityId > const & entityIds() const

function intervalsSpan

inline std::span< TimeFrameInterval const > intervalsSpan() const

function entityIdsSpan

inline std::span< EntityId const > entityIdsSpan() const

Updated on 2026-11-13 at 20:25:40 +0000