OSVR-Core
|
Class providing a unified container-like interface to either a single value or a range of integers. More...
#include <ValueOrRange.h>
Public Types | |
typedef ValueType | value_type |
typedef detail::ValueOrRangeIterator< ValueType > | const_iterator |
typedef const_iterator | iterator |
typedef ValueType | size_type |
Public Member Functions | |
ValueOrRange () | |
Default constructor: an empty range. | |
template<typename T > | |
bool | contains (T val) const |
Determine if the range contains the given value (treating a value instance of this object as essentially a single-element range) | |
ValueType | getMin () const |
Get minimum value - closed lower bound. More... | |
ValueType | getMax () const |
Get maximum value - closed upper bound. More... | |
bool | isValue () const |
Has the object been assigned a single value (range of size 1) | |
bool | isNonEmptyRange () const |
Has the object been assigned a range of size > 1? | |
bool | empty () const |
Is the object an empty range? (default constructor, or setting to a range with max < min) | |
size_type | size () const |
value_type | getValue () const |
void | setValue (ValueType val) |
Assign a single value to this object. | |
void | setEmpty () |
Assign an empty range to this object. | |
void | setRangeMaxMin (ValueType maxVal, ValueType minVal=0) |
Assign a range of values to this object. More... | |
ValueOrRange | getIntersection (ValueOrRange other) const |
Gets the (possibly empty) intersection of the ranges/values. | |
void | extendRangeToMax (ValueType maxVal) |
If this is an initialized range, extend it as needed such that the given maxVal is included. More... | |
const_iterator | begin () const |
Get a "begin" iterator pointing to the first value in the range (or value) | |
const_iterator | end () const |
Get a "past-the-end" iterator pointing to one more than the max value) | |
Static Public Member Functions | |
static ValueOrRange | SingleValue (ValueType val) |
Factory method for creating a single-value range. | |
static ValueOrRange | RangeZeroTo (ValueType maxVal) |
Factory method for creating a range from zero. | |
static ValueOrRange | RangeMaxMin (ValueType maxVal, ValueType minVal) |
Factory method for creating a range from zero. | |
Class providing a unified container-like interface to either a single value or a range of integers.
|
inline |
If this is an initialized range, extend it as needed such that the given maxVal is included.
|
inline |
Get maximum value - closed upper bound.
Only valid if not empty()!
|
inline |
Get minimum value - closed lower bound.
Only valid if not empty()!
|
inline |
Assign a range of values to this object.
Note the order of parameters to make minimum (0) optional.
Giving a range of size == 1 is the same as calling setValue(). Giving a range where min is greater than max sets the range to be empty, discarding your provided max and min values for sentinel values.