![]() |
VISR
0.11.8
Versatile Interactive Scene Renderer
|
#include <channel_list.hpp>
Public Types | |
using | IndexType = ChannelList::IndexType |
using | StepType = std::ptrdiff_t |
Public Member Functions | |
ChannelRange () | |
ChannelRange (IndexType val) | |
ChannelRange (IndexType start, IndexType end, StepType step=1) | |
void | set (IndexType start, IndexType end, StepType stride=1) |
bool | isValid () const |
IndexType | size () const |
IndexType | start () const |
IndexType | end () const |
StepType | step () const |
IndexType | at (IndexType idx) const |
IndexType | operator[] (IndexType idx) const |
IndexType | at (IndexType idx) |
IndexType | operator[] (IndexType idx) |
Static Public Member Functions | |
static bool | isValid (IndexType start, IndexType size, StepType stride) |
Class representing a sequence of equidistant channel indices caharcterised by a start, an end, and step (or stride) value. The end value is not included in the range following the 'one-past-end' semantics used in the STL or Python. Strides can be negative but must be non-zero.
using visr::ChannelRange::StepType = std::ptrdiff_t |
visr::ChannelRange::ChannelRange | ( | ) |
Default constructor, construct an empty range.
visr::ChannelRange::ChannelRange | ( | IndexType | val | ) |
Construct a single-element range.
val | The start valu (and sole value of the resulting range) |
Construct a range from start, end, and optional step values
start | The start value of the sequence. |
end | The end value of the sequence. this value is not included in the index sequence. |
step | The increment between successive channel indices, must be non-zero. |
std::invalid_argument | the range specification is invalid (i.e., if step is zero or the increments goes in the different direction of the end value.) |
ChannelRange::IndexType visr::ChannelRange::at | ( | IndexType | idx | ) | const |
Return the channel index at the idx-th
position.
std::out_of_range | if idx exceeds the size of the slice |
ChannelRange::IndexType visr::ChannelRange::at | ( | IndexType | idx | ) |
Return the channel index at the idx-th
position.
std::out_of_range | if idx exceeds the size of the slice |
|
inline |
Return the end value of the sequence.
Static method to check whether a range specification is valid.
bool visr::ChannelRange::isValid | ( | ) | const |
Query whether the range is valid, i.e., whether it contains a finite (potentially zero) number of elements. That is, ranges are invalid if the stride is zero or the end index cannot be reached from the start index with the given stride value.
ChannelRange::IndexType visr::ChannelRange::operator[] | ( | IndexType | idx | ) | const |
Return the channel index at the idx-th
position.
idx
exceeds the size of the slice. ChannelRange::IndexType visr::ChannelRange::operator[] | ( | IndexType | idx | ) |
Return the channel index at the idx-th
position.
idx
exceeds the size of the slice. Set a range using start, end, and (optional) step notation
start | The start value of the sequence. |
end | The end value of the sequence. this value is not included in the index sequence. |
stride | The increment between successive channel indices, must be non-zero. |
std::invalid_argument | the range specification is invalid (i.e., if step is zero or the increments goes in the different direction of the end value.) |
ChannelRange::IndexType visr::ChannelRange::size | ( | ) | const |
Return the number of channel indices in the range.
|
inline |
Return the start value of the range.
|
inline |
Return the step size (stride) between consecutive elements.