PPL API Reference
Overview Core Algorithm Abstractions Utilities Parallel Methods
Modules Class Hierarchy Classes Functions
Todo List Bug List Dead Code
List of all members
Range< T > Struct Template Referencefinal

A range of numeric values. More...

Public Member Functions

Construction
 Range () noexcept
 Construct a range over all values of T.
 
 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.
 
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.
 
bool operator== (const Range< T > &_other) const
 Checks for equality with another Range.
 
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
 

Public Attributes

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

Detailed Description

template<typename T>
struct Range< T >

A range of numeric values.

Constructor & Destructor Documentation

◆ Range() [1/2]

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

Construct a bounded range.

Parameters
_minThe lower bound.
_maxThe upper bound.

◆ Range() [2/2]

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

Construct a bounded range.

Parameters
_boundsA pair of min, max values.

Member Function Documentation

◆ Center()

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

Compute the center of this range.

Warning
This will not be exact for integral types.

◆ Contains()

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

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

◆ Clearance()

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

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
noexcept

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.

◆ Resize()

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

Resize the range.

Parameters
_minThe new lower bound.
_maxThe new upper bound.

◆ Translate()

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

Translate the range.

Parameters
_tThe translation magnitude.

◆ SetCenter()

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

Translate the range to a new center.

Parameters
_tThe new center value.

◆ ExpandToInclude()

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

Expand the range to include a value.

Parameters
_tThe new value to include.

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