CVB++ 15.1
Loading...
Searching...
No Matches
ValueRange< T > Class Template Referencefinal

Container for range definitions. More...

#include <cvb/value_range.hpp>

Public Member Functions

 ValueRange () noexcept=default
 Creates a default value range e.g. from 0 to 0.
 
 ValueRange (T min, T max)
 Initializes a ValueRange object.
 
T Min () const noexcept
 Gets the minimum value.
 
void SetMin (T min)
 Sets the minimum value.
 
T Max () const noexcept
 Gets the maximum value.
 
void SetMax (T max)
 Sets the maximum value.
 
bool Contains (T value) const noexcept
 Checks if a value is within the range.
 
bool IntersectsWith (ValueRange< T > other) const noexcept
 Checks if this value range intersects with another value range.
 
bool operator== (const ValueRange< T > &valueRange) const noexcept
 Compares to an other value range.
 
bool operator!= (const ValueRange< T > &valueRange) const noexcept
 Compares to an other value range.
 
template<class C>
 operator ValueRange< C > () const noexcept
 Enable casting.
 

Detailed Description

template<class T>
class Cvb::ValueRange< T >

Container for range definitions.

Constructor & Destructor Documentation

◆ ValueRange() [1/2]

template<class T>
ValueRange ( )
defaultnoexcept

Creates a default value range e.g. from 0 to 0.

Exceptions
Doesnot throw any exception.

◆ ValueRange() [2/2]

template<class T>
ValueRange ( T min,
T max )
inline

Initializes a ValueRange object.

Parameters
[in]minMinimum value.
[in]maxMaximum value.
Exceptions
Anyexception derived from std::exception including CvbException.

Member Function Documentation

◆ Contains()

template<class T>
bool Contains ( T value) const
inlinenoexcept

Checks if a value is within the range.

Parameters
[in]valueValue to be checked.
Returns
True if the value is within the range (border included), false otherwise.
Exceptions
Doesnot throw any exception.

◆ IntersectsWith()

template<class T>
bool IntersectsWith ( ValueRange< T > other) const
inlinenoexcept

Checks if this value range intersects with another value range.

Parameters
[in]otherRange for intersection test.
Returns
True if this range and the other range have at least one value in common, false otherwise.
Exceptions
Doesnot throw any exception.

◆ Max()

template<class T>
T Max ( ) const
inlinenoexcept

Gets the maximum value.

Returns
The minimum value.
Exceptions
Doesnot throw any exception.

◆ Min()

template<class T>
T Min ( ) const
inlinenoexcept

Gets the minimum value.

Returns
The minimum value.
Exceptions
Doesnot throw any exception.

◆ operator!=()

template<class T>
bool operator!= ( const ValueRange< T > & valueRange) const
inlinenoexcept

Compares to an other value range.

Parameters
[in]valueRangeOther value range.
Returns
True if not equal, otherwise false.
Exceptions
Doesnot throw any exception.

◆ operator==()

template<class T>
bool operator== ( const ValueRange< T > & valueRange) const
inlinenoexcept

Compares to an other value range.

Parameters
[in]valueRangeOther value range.
Returns
True if equal, otherwise false.
Exceptions
Doesnot throw any exception.

◆ SetMax()

template<class T>
void SetMax ( T max)
inline

Sets the maximum value.

Parameters
[in]maxNew maximum value, must be greater or equal than the current minimum value.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetMin()

template<class T>
void SetMin ( T min)
inline

Sets the minimum value.

Parameters
[in]minNew minimum value, must be less or equal than the current maximum value.
Exceptions
Anyexception derived from std::exception including CvbException.