Jamba C++ API  4.0.0
Range< T > Struct Template Reference

Defines a range of values. More...

#include <Lerp.h>

Public Types

using value_type = T
 Gives access to the type of elements in the range. More...
 

Public Member Functions

template<typename U >
Range< U > cast () const
 Cast this range to another one. More...
 
clamp (T iValue) const
 Clamp the value to this range. More...
 
bool contains (T iValue) const
 This method assumes that fFrom and fTo are part of the range or another way to put it: More...
 
bool isSingleValue () const
 
template<typename U , typename TLerp = DPLerpXY<T, U>>
Range< U > mapRange (Range< U > const &iRange) const
 Map this range to the other range. More...
 
template<typename U , typename TLerp = DPLerpXY<T, U>>
Range< U > mapSubRange (Range< T > const &iSubRange, Range< U > const &iRange, bool iClampToRange=true) const
 Map a sub range of this range to the other range. More...
 
template<typename U , typename TLerp = DPLerpXY<T, U>>
mapValue (T iValue, Range< U > const &iRange, bool iClampToRange=true) const
 Map the value from this range into the provide range. More...
 
bool operator!= (const Range &rhs) const
 
bool operator== (const Range &rhs) const
 
 Range ()=default
 
 Range (T iValue) noexcept
 
 Range (T iFrom, T iTo)
 

Public Attributes

fFrom {}
 
fTo {}
 

Detailed Description

template<typename T>
struct pongasoft::Utils::Range< T >

Defines a range of values.

Member Typedef Documentation

◆ value_type

using value_type = T

Gives access to the type of elements in the range.

Constructor & Destructor Documentation

◆ Range() [1/3]

Range ( )
default

◆ Range() [2/3]

Range ( iValue)
inlineexplicitnoexcept

◆ Range() [3/3]

Range ( iFrom,
iTo 
)
inline

Member Function Documentation

◆ cast()

Range<U> cast ( ) const
inline

Cast this range to another one.

◆ clamp()

T clamp ( iValue) const
inline

Clamp the value to this range.

Returns
a value between fFrom and fTo

◆ contains()

bool contains ( iValue) const
inline

This method assumes that fFrom and fTo are part of the range or another way to put it:

range.contains(range.fFrom) // returns true
range.contains(range.fTo) // returns true
Returns
true if the range contains the value

◆ isSingleValue()

bool isSingleValue ( ) const
inline

◆ mapRange()

Range<U> mapRange ( Range< U > const &  iRange) const
inline

Map this range to the other range.

Parameters
iRangethe range to map this range into
Returns
the new range

◆ mapSubRange()

Range<U> mapSubRange ( Range< T > const &  iSubRange,
Range< U > const &  iRange,
bool  iClampToRange = true 
) const
inline

Map a sub range of this range to the other range.

Parameters
iSubRangethe sub-range of this range to use as source
iRangethe range to map iSubRange into
iClampToRangedetermines whether iSubRange should first be clamped to this range
Returns
the new range
Todo:
optimize by computing TLerp only once

◆ mapValue()

U mapValue ( iValue,
Range< U > const &  iRange,
bool  iClampToRange = true 
) const
inline

Map the value from this range into the provide range.

Parameters
iValuethe value from this range [fFrom, fTo]
iRangethe range to map the iValue into
iClampToRangedetermines whether iValue should first be clamped to this range
Returns
the new value

◆ operator!=()

bool operator!= ( const Range< T > &  rhs) const
inline

◆ operator==()

bool operator== ( const Range< T > &  rhs) const
inline

Member Data Documentation

◆ fFrom

T fFrom {}

◆ fTo

T fTo {}

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