Skip to main content

LazyDigitalIntervalStorage

LazyDigitalIntervalStorage

Lazy digital interval storage that computes intervals on-demand from a view. More…

#include <LazyDigitalIntervalStorage.hpp>

Inherits from DigitalIntervalStorageBase< LazyDigitalIntervalStorage< ViewType > >

Public Functions

Name
LazyDigitalIntervalStorage(ViewType view, size_t num_elements, std::shared_ptr< TimeFrame > time_frame =[nullptr])
Construct lazy storage from a random-access view.
virtual ~LazyDigitalIntervalStorage() =default
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
Lazy storage is never contiguous in memory.
ViewType const & getView() const
Get reference to underlying view.

Additional inherited members

Public Functions inherited from DigitalIntervalStorageBase< LazyDigitalIntervalStorage< ViewType > >

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< LazyDigitalIntervalStorage< ViewType > >

Name
~DigitalIntervalStorageBase() =default

Detailed Description

template <typename ViewType >
class LazyDigitalIntervalStorage;

Lazy digital interval storage that computes intervals on-demand from a view.

Stores a computation pipeline as a random-access view that transforms data on-demand. Enables efficient composition of transforms without materializing intermediate results.

The view must yield objects with .interval and .entity_id members (ClockTicksIntervalWithId, IntervalWithId, or convertible pair/tuple).

Range-query limitation

getOverlappingRangeImpl() always uses an O(n) linear scan. Unlike OwningDigitalIntervalStorage and ViewDigitalIntervalStorage, lazy storage does not expose assumeDisjointIntervals() and therefore does not use the O(log n) binary-search fast path, even when the underlying view yields disjoint intervals. This is intentional for transform intermediates ([IntervalLayout::Overlapping](/api_generated/Files/Digital__Interval__Series_8hpp.md#enumvalue-overlapping)) where overlaps are possible; a disjoint fast path may be added later if needed.

ViewTypeType of the random-access range view

Public Functions Documentation

function LazyDigitalIntervalStorage

inline explicit LazyDigitalIntervalStorage(
    ViewType view,
    size_t num_elements,
    std::shared_ptr< TimeFrame > time_frame =nullptr
)

Construct lazy storage from a random-access view.

Parameters:

  • view Random-access range view yielding interval-like objects
  • num_elements Number of elements in the view
  • time_frame Time frame for converting ClockTicks elements to storage indices

function ~LazyDigitalIntervalStorage

virtual ~LazyDigitalIntervalStorage() =default

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

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

function findByEntityIdImpl

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

function hasIntervalAtTimeImpl

inline bool hasIntervalAtTimeImpl(
    TimeFrameIndex time
) const

function getOverlappingRangeImpl

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

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

See:

Note: Lazy storage has no assumeDisjointIntervals() hook; disjoint transform views still pay linear cost for this query.

Always O(n) linear scan over computed elements. Correct for overlapping intervals. Does not use the disjoint binary-search optimization available on OwningDigitalIntervalStorage::getOverlappingRangeImpl() and ViewDigitalIntervalStorage::getOverlappingRangeImpl().

function getContainedRangeImpl

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

function getStorageTypeImpl

inline DigitalIntervalStorageType getStorageTypeImpl() const

function tryGetCacheImpl

inline DigitalIntervalStorageCache tryGetCacheImpl() const

Lazy storage is never contiguous in memory.

Returns an invalid cache, forcing callers to use virtual dispatch.

function getView

inline ViewType const & getView() const

Get reference to underlying view.


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