Parasol Planning Library (PPL)
Range< T > Struct Template Referencefinal

A range of numeric values. More...

#include <Range.h>

Public Member Functions

Construction
 Range () noexcept
 Construct a range over all values of T. More...
 
 Range (const T _min, const T _max) noexcept
 
 Range (const std::pair< T, T > &_bounds) noexcept
 
Queries
Length () const noexcept
 Compute the length of this range. More...
 
Center () const noexcept
 
template<typename U >
bool Contains (const U &_val, const double _tolerance=1e-8) const noexcept
 
template<typename U >
Clearance (const U &_val) const noexcept
 
template<typename U >
ClearancePoint (const U &_val) const noexcept
 
Sample () const noexcept
 Sample the range for a random contained value with uniform probability. More...
 
bool operator== (const Range< T > &_other) const
 Checks for equality with another Range. More...
 
bool operator< (const Range< T > &_other) const
 This only for placing in sets. More...
 
Modifiers
void Resize (const T _min, const T _max) noexcept
 
void Translate (const T _t) noexcept
 
void SetCenter (const T _t) noexcept
 
void ExpandToInclude (const T _t) noexcept
 

Data Fields

Internal State
min
 The lower bound on this range. More...
 
max
 The upper bound on this range. More...
 

Detailed Description

template<typename T>
struct Range< T >

A range of numeric values.

Constructor & Destructor Documentation

◆ Range() [1/3]

template<typename T >
Range< T >::Range
inlinenoexcept

Construct a range over all values of T.

◆ Range() [2/3]

template<typename T >
Range< T >::Range ( const T  _min,
const T  _max 
)
inlinenoexcept

Construct a bounded range.

Parameters
_minThe lower bound.
_maxThe upper bound.

◆ Range() [3/3]

template<typename T >
Range< T >::Range ( const std::pair< T, T > &  _bounds)
inlinenoexcept

Construct a bounded range.

Parameters
_boundsA pair of min, max values.

Member Function Documentation

◆ Center()

template<typename T >
T Range< T >::Center
inlinenoexcept

Compute the center of this range.

Warning
This will not be exact for integral types.

◆ Clearance()

template<typename T >
template<typename U >
T Range< T >::Clearance ( const U &  _val) const
inlinenoexcept

Test the clearance of a value. Clearance is defined as the minimum distance to a boundary value, and will be negative if the test value falls outside the range.

Parameters
_valThe value to test.
Returns
The distance of _val from the nearest endpoint.

◆ ClearancePoint()

template<typename T >
template<typename U >
T Range< T >::ClearancePoint ( const U &  _val) const
inlinenoexcept

Find the range endpoint that is closest to a target value.

Parameters
_valThe target value.
Returns
The endpoint of this that is closest to _val.

◆ Contains()

template<typename T >
template<typename U >
bool Range< T >::Contains ( const U &  _val,
const double  _tolerance = 1e-8 
) const
inlinenoexcept

Test if a value is inside this range.

Parameters
_valThe value to test.
_toleranceTolerance to accommodate floating-point error, as a fraction of the min/max.
Returns
True if the test value lies inside the range (or on the boundary for inclusive test).

◆ ExpandToInclude()

template<typename T >
void Range< T >::ExpandToInclude ( const T  _t)
inlinenoexcept

Expand the range to include a value.

Parameters
_tThe new value to include.

◆ Length()

template<typename T >
T Range< T >::Length
inlinenoexcept

Compute the length of this range.

◆ operator<()

template<typename T >
bool Range< T >::operator< ( const Range< T > &  _other) const
inline

This only for placing in sets.

◆ operator==()

template<typename T >
bool Range< T >::operator== ( const Range< T > &  _other) const
inline

Checks for equality with another Range.

◆ Resize()

template<typename T >
void Range< T >::Resize ( const T  _min,
const T  _max 
)
inlinenoexcept

Resize the range.

Parameters
_minThe new lower bound.
_maxThe new upper bound.

◆ Sample()

template<typename T >
T Range< T >::Sample
inlinenoexcept

Sample the range for a random contained value with uniform probability.

◆ SetCenter()

template<typename T >
void Range< T >::SetCenter ( const T  _t)
inlinenoexcept

Translate the range to a new center.

Parameters
_tThe new center value.

◆ Translate()

template<typename T >
void Range< T >::Translate ( const T  _t)
inlinenoexcept

Translate the range.

Parameters
_tThe translation magnitude.

Field Documentation

◆ max

template<typename T >
T Range< T >::max

The upper bound on this range.

◆ min

template<typename T >
T Range< T >::min

The lower bound on this range.


The documentation for this struct was generated from the following file: