VISR  0.11.1
Versatile Interactive Scene Renderer
visr::ChannelRange Class Reference

#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)
 

Detailed Description

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.

Member Typedef Documentation

◆ IndexType

◆ StepType

using visr::ChannelRange::StepType = std::ptrdiff_t

Constructor & Destructor Documentation

◆ ChannelRange() [1/3]

visr::ChannelRange::ChannelRange ( )

Default constructor, construct an empty range.

◆ ChannelRange() [2/3]

visr::ChannelRange::ChannelRange ( IndexType  val)

Construct a single-element range.

Note
this constructor is not explicit to enable construction of ChannelList objects from initializer lists.
Parameters
valThe start valu (and sole value of the resulting range)

◆ ChannelRange() [3/3]

visr::ChannelRange::ChannelRange ( IndexType  start,
IndexType  end,
StepType  step = 1 
)

Construct a range from start, end, and optional step values

Parameters
startThe start value of the sequence.
endThe end value of the sequence. this value is not included in the index sequence.
stepThe increment between successive channel indices, must be non-zero.
Exceptions
std::invalid_argumentthe range specification is invalid (i.e., if step is zero or the increments goes in the different direction of the end value.)
Note
this constructor is not explicit to enable construction of ChannelList objects from initializer lists of ranges.

Member Function Documentation

◆ at() [1/2]

ChannelRange::IndexType visr::ChannelRange::at ( IndexType  idx) const

Return the channel index at the idx-th position.

Exceptions
std::out_of_rangeif idx exceeds the size of the slice

◆ at() [2/2]

ChannelRange::IndexType visr::ChannelRange::at ( IndexType  idx)

Return the channel index at the idx-th position.

Exceptions
std::out_of_rangeif idx exceeds the size of the slice

◆ end()

IndexType visr::ChannelRange::end ( ) const
inline

Return the end value of the sequence.

Note
This is different from the last element of the sequence, because the class follows the 'one-past-the-end' semantics used in the STL and Python.

◆ isValid() [1/2]

bool visr::ChannelRange::isValid ( IndexType  start,
IndexType  size,
StepType  stride 
)
static

Static method to check whether a range specification is valid.

◆ isValid() [2/2]

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.

◆ operator[]() [1/2]

ChannelRange::IndexType visr::ChannelRange::operator[] ( IndexType  idx) const

Return the channel index at the idx-th position.

Note
No checking is performed whrther idx exceeds the size of the slice.

◆ operator[]() [2/2]

ChannelRange::IndexType visr::ChannelRange::operator[] ( IndexType  idx)

Return the channel index at the idx-th position.

Note
No checking is performed whrther idx exceeds the size of the slice.

◆ set()

void visr::ChannelRange::set ( IndexType  start,
IndexType  end,
StepType  stride = 1 
)

Set a range using start, end, and (optional) step notation

Parameters
startThe start value of the sequence.
endThe end value of the sequence. this value is not included in the index sequence.
strideThe increment between successive channel indices, must be non-zero.
Exceptions
std::invalid_argumentthe range specification is invalid (i.e., if step is zero or the increments goes in the different direction of the end value.)
See also
isValid

◆ size()

ChannelRange::IndexType visr::ChannelRange::size ( ) const

Return the number of channel indices in the range.

◆ start()

IndexType visr::ChannelRange::start ( ) const
inline

Return the start value of the range.

◆ step()

StepType visr::ChannelRange::step ( ) const
inline

Return the step size (stride) between consecutive elements.


The documentation for this class was generated from the following files: