Class SampleTimes

Class Documentation

class SampleTimes

The times a range of samples was taken at, as a closed form.

Sampling returns values only, because the times they were taken at are fully described by a start, a step and a count — storing them would double the memory for no information. This holds those three numbers and computes a time on demand, so indexing it costs a multiply and an add and nothing is allocated.

Obtain one from Channel::sample_times(), Channel::sample_times_by_rate(), or the free functions of the same names for an arbitrary range. Those apply the same step rule the matching evaluate_range() call does, so element i is exactly the time element i of the returned values was evaluated at.

Public Functions

inline SampleTimes(double start, double step, size_t count)

Constructs a sequence of count times from start, step apart.

Prefer the sample_times() functions, which derive step from a range and a RangeEnd rather than leaving it to the caller to restate that rule.

inline double operator[](size_t index) const

The time of sample index. Not bounds-checked; see at().

inline double at(size_t index) const

The time of sample index.

Throws:

std::out_of_range – if out of range.

inline size_t size() const

Number of samples described.

inline bool empty() const

Whether there are no samples.

inline double front() const

Time of the first sample.

inline double back() const

Time of the last sample. Undefined when empty().

inline double step() const

Spacing between consecutive samples.

inline bool operator==(const SampleTimes &other) const
inline bool operator!=(const SampleTimes &other) const