Skip to main content

SparseTimeIndexStorage

SparseTimeIndexStorage

Sparse time index storage for irregularly-sampled data. More…

#include <TimeIndexStorage.hpp>

Inherits from TimeIndexStorage

Public Functions

Name
SparseTimeIndexStorage(std::vector< TimeFrameIndex > time_indices)
Construct sparse storage.
virtual TimeFrameIndex getTimeFrameIndexAt(size_t array_position) const override
Get the TimeFrameIndex at a specific array position.
virtual size_t size() const override
Get the total number of time points stored.
virtual std::optional< size_t > findArrayPositionForTimeIndex(TimeFrameIndex time_index) const override
Find the array position for a specific TimeFrameIndex.
virtual std::optional< size_t > findArrayPositionGreaterOrEqual(TimeFrameIndex target_time) const override
Find array position for the smallest TimeFrameIndex >= target.
virtual std::optional< size_t > findArrayPositionLessOrEqual(TimeFrameIndex target_time) const override
Find array position for the largest TimeFrameIndex <= target.
virtual std::vector< TimeFrameIndex > getAllTimeIndices() const override
Get all time indices as a vector.
virtual std::shared_ptr< TimeIndexStorage > clone() const override
Clone this storage (for copy operations).
virtual std::unique_ptr< TimeIndexIterator > createIterator(size_t start_position, size_t end_position, bool is_end =false) const override
Create an iterator for a range of array positions.
std::vector< TimeFrameIndex > const & getTimeIndices() const

Additional inherited members

Public Functions inherited from TimeIndexStorage

Name
virtual ~TimeIndexStorage() =default

Detailed Description

class SparseTimeIndexStorage;

Sparse time index storage for irregularly-sampled data.

Explicit storage of time indices for each sample point. This is necessary when time points are not consecutive or uniformly spaced.

Indices are kept sorted to enable efficient binary search operations.

Public Functions Documentation

function SparseTimeIndexStorage

explicit SparseTimeIndexStorage(
    std::vector< TimeFrameIndex > time_indices
)

Construct sparse storage.

Parameters:

  • time_indices Vector of TimeFrameIndex values (will be sorted if not already)

function getTimeFrameIndexAt

virtual TimeFrameIndex getTimeFrameIndexAt(
    size_t array_position
) const override

Get the TimeFrameIndex at a specific array position.

Parameters:

  • array_position The logical position in the data array (0-based)

Exceptions:

  • std::out_of_range if array_position is out of bounds

Return: The TimeFrameIndex corresponding to that position

Reimplements: TimeIndexStorage::getTimeFrameIndexAt

function size

virtual size_t size() const override

Get the total number of time points stored.

Return: The count of time indices

Reimplements: TimeIndexStorage::size

function findArrayPositionForTimeIndex

virtual std::optional< size_t > findArrayPositionForTimeIndex(
    TimeFrameIndex time_index
) const override

Find the array position for a specific TimeFrameIndex.

Parameters:

Return: Optional array position if found, nullopt otherwise

Reimplements: TimeIndexStorage::findArrayPositionForTimeIndex

function findArrayPositionGreaterOrEqual

virtual std::optional< size_t > findArrayPositionGreaterOrEqual(
    TimeFrameIndex target_time
) const override

Find array position for the smallest TimeFrameIndex >= target.

Parameters:

Return: Optional array position, or nullopt if no such index exists

Reimplements: TimeIndexStorage::findArrayPositionGreaterOrEqual

function findArrayPositionLessOrEqual

virtual std::optional< size_t > findArrayPositionLessOrEqual(
    TimeFrameIndex target_time
) const override

Find array position for the largest TimeFrameIndex <= target.

Parameters:

Return: Optional array position, or nullopt if no such index exists

Reimplements: TimeIndexStorage::findArrayPositionLessOrEqual

function getAllTimeIndices

virtual std::vector< TimeFrameIndex > getAllTimeIndices() const override

Get all time indices as a vector.

Return: Vector containing all TimeFrameIndex values

Note: For dense storage, this generates the vector on-demand

Reimplements: TimeIndexStorage::getAllTimeIndices

function clone

virtual std::shared_ptr< TimeIndexStorage > clone() const override

Clone this storage (for copy operations).

Return: A new shared_ptr to a copy of this storage

Reimplements: TimeIndexStorage::clone

function createIterator

virtual std::unique_ptr< TimeIndexIterator > createIterator(
    size_t start_position,
    size_t end_position,
    bool is_end =false
) const override

Create an iterator for a range of array positions.

Parameters:

  • start_position The starting array position (inclusive)
  • end_position The ending array position (exclusive)
  • is_end Whether to create an end iterator

Return: A unique_ptr to a TimeIndexIterator

Reimplements: TimeIndexStorage::createIterator

function getTimeIndices

inline std::vector< TimeFrameIndex > const & getTimeIndices() const

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