Jamba  3.1.0
pongasoft::Utils::Range< T > Struct Template Reference

#include <Lerp.h>

Public Types

using value_type = T
 

Public Member Functions

template<typename U >
Range< U > cast () const
 
clamp (T iValue) const
 
bool contains (T iValue) const
 
bool isSingleValue () const
 
template<typename U , typename TLerp = DPLerpXY<T, U>>
Range< U > mapRange (Range< U > const &iRange, bool iClampToRange=true) const
 
template<typename U , typename TLerp = DPLerpXY<T, U>>
Range< U > mapSubRange (Range< T > const &iSubRange, Range< U > const &iRange, bool iClampToRange=true) const
 
template<typename U , typename TLerp = DPLerpXY<T, U>>
mapValue (T iValue, Range< U > const &iRange, bool iClampToRange=true) const
 
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

template<typename T>
using pongasoft::Utils::Range< T >::value_type = T

Gives access to the type of elements in the range

Constructor & Destructor Documentation

◆ Range() [1/3]

template<typename T>
pongasoft::Utils::Range< T >::Range ( )
default

◆ Range() [2/3]

template<typename T>
pongasoft::Utils::Range< T >::Range ( iValue)
inlineexplicitnoexcept

◆ Range() [3/3]

template<typename T>
pongasoft::Utils::Range< T >::Range ( iFrom,
iTo 
)
inline

Member Function Documentation

◆ cast()

template<typename T>
template<typename U >
Range<U> pongasoft::Utils::Range< T >::cast ( ) const
inline

Cast this range to another one

◆ clamp()

template<typename T>
T pongasoft::Utils::Range< T >::clamp ( iValue) const
inline

Clamp the value to this range

Returns
a value between fFrom and fTo

◆ contains()

template<typename T>
bool pongasoft::Utils::Range< T >::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()

template<typename T>
bool pongasoft::Utils::Range< T >::isSingleValue ( ) const
inline

◆ mapRange()

template<typename T>
template<typename U , typename TLerp = DPLerpXY<T, U>>
Range<U> pongasoft::Utils::Range< T >::mapRange ( Range< U > const &  iRange,
bool  iClampToRange = true 
) const
inline

Map this range to the other range

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

◆ mapSubRange()

template<typename T>
template<typename U , typename TLerp = DPLerpXY<T, U>>
Range<U> pongasoft::Utils::Range< T >::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
iRangethe range to map the iValue into
Returns
the new range
Todo:
optimize by computing TLerp only once

◆ mapValue()

template<typename T>
template<typename U , typename TLerp = DPLerpXY<T, U>>
U pongasoft::Utils::Range< T >::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
Returns
the new value

◆ operator!=()

template<typename T>
bool pongasoft::Utils::Range< T >::operator!= ( const Range< T > &  rhs) const
inline

◆ operator==()

template<typename T>
bool pongasoft::Utils::Range< T >::operator== ( const Range< T > &  rhs) const
inline

Member Data Documentation

◆ fFrom

template<typename T>
T pongasoft::Utils::Range< T >::fFrom {}

◆ fTo

template<typename T>
T pongasoft::Utils::Range< T >::fTo {}

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