Murl::Math::MinMax< DataType, LimitsType > Class Template Reference

The minimum maximum values template class. More...

#include "murl_math_min_max.h"

Public Types

using ValueType = DataType
 The template parameter value type.
 

Public Member Functions

 MinMax ()
 The default constructor. More...
 
 MinMax (const DataType &min, const DataType &max)
 Constructor to initialize with a given minimum and maximum value. More...
 
 MinMax (const Array< DataType > &values)
 Constructor to initialize with given values. More...
 
void Reset ()
 Reset the minimum and maximum value. More...
 
void Add (const DataType &value)
 Add a value. More...
 
void Add (const Array< DataType > &values)
 Add values. More...
 
const DataType & GetMin () const
 Get the minimum. More...
 
const DataType & GetMax () const
 Get the maximum. More...
 
Bool IsInRange (const DataType &value) const
 Check if a value is in minimum / maximum range. More...
 
Bool IsInRangeEx (const DataType &value) const
 Check if a value is in minimum / maximum range excluding the bounds. More...
 
Bool IsInRangeExMin (const DataType &value) const
 Check if a value is in minimum / maximum range excluding minimum. More...
 
Bool IsInRangeExMax (const DataType &value) const
 Check if a value is in minimum / maximum range excluding maximum. More...
 
void Unite (const MinMax &other)
 Unite this MinMax with another MinMax object. More...
 
void SetMin (const DataType &min)
 Set the minimum. More...
 
void SetMax (const DataType &max)
 Set the maximum. More...
 
void Set (const DataType &min, const DataType &max)
 Set the minimum and the maximum. More...
 
String ToString () const
 Get the string representation of the object. More...
 

Protected Attributes

DataType mMin
 The minimum value.
 
DataType mMax
 The maximum value.
 

Friends

bool operator== (const MinMax &lhs, const MinMax &rhs)
 Equal to comparison operator. More...
 
bool operator!= (const MinMax &lhs, const MinMax &rhs)
 Not equal to comparison operator. More...
 

Detailed Description

template<class DataType, class LimitsType = Limits<DataType>>
class Murl::Math::MinMax< DataType, LimitsType >

The minimum maximum values template class.

This template can be specialized with UInt32, SInt32, UInt64, SInt64, Float and Double, e.g:

Math::MinMax<SInt32> range;

Specialization of other datatypes require the LimitsType template parameter, e.g. use of System::Time:

Math::MinMax<System::Time, System::Time> timeRange;
Template Parameters
DataTypeThe minimum and maximum value datatype, must support being compared with operator<.
LimitsTypeThe datatype's limits type, must implement a static Min() and Max() method.

Constructor & Destructor Documentation

◆ MinMax() [1/3]

template<class DataType , class LimitsType = Limits<DataType>>
Murl::Math::MinMax< DataType, LimitsType >::MinMax ( )
inline

The default constructor.

Initialize the minimum with LimitsType::Max() and the maximum with LimitsType::Min().

◆ MinMax() [2/3]

template<class DataType , class LimitsType = Limits<DataType>>
Murl::Math::MinMax< DataType, LimitsType >::MinMax ( const DataType &  min,
const DataType &  max 
)
inline

Constructor to initialize with a given minimum and maximum value.

Parameters
minThe minimum value.
maxThe maximum value.

◆ MinMax() [3/3]

template<class DataType , class LimitsType = Limits<DataType>>
Murl::Math::MinMax< DataType, LimitsType >::MinMax ( const Array< DataType > &  values)
inline

Constructor to initialize with given values.

Initialize the minimum with LimitsType::Max() and the maximum with LimitsType::Min() and Add() values from an array.

Parameters
valuesThe values to add.

References Murl::Math::MinMax< DataType, LimitsType >::Add().

Member Function Documentation

◆ Reset()

template<class DataType , class LimitsType = Limits<DataType>>
void Murl::Math::MinMax< DataType, LimitsType >::Reset ( )
inline

Reset the minimum and maximum value.

Set the minimum to LimitsType::Max() and the maximum to LimitsType::Min().

References Murl::Math::Max(), Murl::Math::Min(), Murl::Math::MinMax< DataType, LimitsType >::mMax, and Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ Add() [1/2]

template<class DataType , class LimitsType = Limits<DataType>>
void Murl::Math::MinMax< DataType, LimitsType >::Add ( const DataType &  value)
inline

Add a value.

Set the minimum to the value if the value is less than the current minimum. Set the maximum to the value if the value is greater than the current maximum.

Parameters
valueThe value to add.

References Murl::Math::MinMax< DataType, LimitsType >::mMax, and Murl::Math::MinMax< DataType, LimitsType >::mMin.

Referenced by Murl::Math::MinMax< DataType, LimitsType >::Add(), and Murl::Math::MinMax< DataType, LimitsType >::MinMax().

◆ Add() [2/2]

template<class DataType , class LimitsType = Limits<DataType>>
void Murl::Math::MinMax< DataType, LimitsType >::Add ( const Array< DataType > &  values)
inline

Add values.

Add() all values from an array.

Parameters
valuesThe values to add.

References Murl::Math::MinMax< DataType, LimitsType >::Add().

◆ GetMin()

template<class DataType , class LimitsType = Limits<DataType>>
const DataType& Murl::Math::MinMax< DataType, LimitsType >::GetMin ( ) const
inline

Get the minimum.

Returns
The minimum.

References Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ GetMax()

template<class DataType , class LimitsType = Limits<DataType>>
const DataType& Murl::Math::MinMax< DataType, LimitsType >::GetMax ( ) const
inline

Get the maximum.

Returns
The maximum.

References Murl::Math::MinMax< DataType, LimitsType >::mMax.

◆ IsInRange()

template<class DataType , class LimitsType = Limits<DataType>>
Bool Murl::Math::MinMax< DataType, LimitsType >::IsInRange ( const DataType &  value) const
inline

Check if a value is in minimum / maximum range.

Parameters
valueThe value to check.
Returns
true if the value is greater or equal the minimum and less or equal the maximum.

References Murl::Math::MinMax< DataType, LimitsType >::mMax, and Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ IsInRangeEx()

template<class DataType , class LimitsType = Limits<DataType>>
Bool Murl::Math::MinMax< DataType, LimitsType >::IsInRangeEx ( const DataType &  value) const
inline

Check if a value is in minimum / maximum range excluding the bounds.

Parameters
valueThe value to check.
Returns
true if the value is greater the minimum and less the maximum.

References Murl::Math::MinMax< DataType, LimitsType >::mMax, and Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ IsInRangeExMin()

template<class DataType , class LimitsType = Limits<DataType>>
Bool Murl::Math::MinMax< DataType, LimitsType >::IsInRangeExMin ( const DataType &  value) const
inline

Check if a value is in minimum / maximum range excluding minimum.

Parameters
valueThe value to check.
Returns
true if the value is greater the minimum and less or equal the maximum.

References Murl::Math::MinMax< DataType, LimitsType >::mMax, and Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ IsInRangeExMax()

template<class DataType , class LimitsType = Limits<DataType>>
Bool Murl::Math::MinMax< DataType, LimitsType >::IsInRangeExMax ( const DataType &  value) const
inline

Check if a value is in minimum / maximum range excluding maximum.

Parameters
valueThe value to check.
Returns
true if the value is greater or equal the minimum and less the maximum.

References Murl::Math::MinMax< DataType, LimitsType >::mMax, and Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ Unite()

template<class DataType , class LimitsType = Limits<DataType>>
void Murl::Math::MinMax< DataType, LimitsType >::Unite ( const MinMax< DataType, LimitsType > &  other)
inline

Unite this MinMax with another MinMax object.

Parameters
otherThe other MinMax object to unite.

References Murl::Math::MinMax< DataType, LimitsType >::mMax, and Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ SetMin()

template<class DataType , class LimitsType = Limits<DataType>>
void Murl::Math::MinMax< DataType, LimitsType >::SetMin ( const DataType &  min)
inline

Set the minimum.

Parameters
minThe minimum to set.

References Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ SetMax()

template<class DataType , class LimitsType = Limits<DataType>>
void Murl::Math::MinMax< DataType, LimitsType >::SetMax ( const DataType &  max)
inline

Set the maximum.

Parameters
maxThe maximum to set.

References Murl::Math::MinMax< DataType, LimitsType >::mMax.

◆ Set()

template<class DataType , class LimitsType = Limits<DataType>>
void Murl::Math::MinMax< DataType, LimitsType >::Set ( const DataType &  min,
const DataType &  max 
)
inline

Set the minimum and the maximum.

Parameters
minThe maximum to set.
maxThe maximum to set.

References Murl::Math::MinMax< DataType, LimitsType >::mMax, and Murl::Math::MinMax< DataType, LimitsType >::mMin.

◆ ToString()

template<class DataType , class LimitsType = Limits<DataType>>
String Murl::Math::MinMax< DataType, LimitsType >::ToString ( ) const
inline

Get the string representation of the object.

Returns
The string representation of the object.

References Murl::Math::MinMax< DataType, LimitsType >::mMax, Murl::Math::MinMax< DataType, LimitsType >::mMin, and Murl::Util::ValueToString().

Friends And Related Function Documentation

◆ operator==

template<class DataType , class LimitsType = Limits<DataType>>
bool operator== ( const MinMax< DataType, LimitsType > &  lhs,
const MinMax< DataType, LimitsType > &  rhs 
)
friend

Equal to comparison operator.

Parameters
lhsThe left hand side to compare.
rhsThe right hand side to compare.
Returns
true if minimum and maximum are the same.

◆ operator!=

template<class DataType , class LimitsType = Limits<DataType>>
bool operator!= ( const MinMax< DataType, LimitsType > &  lhs,
const MinMax< DataType, LimitsType > &  rhs 
)
friend

Not equal to comparison operator.

Parameters
lhsThe left hand side vector to compare.
rhsThe right hand side vector to compare.
Returns
true if minimum and maximum are not the same.

The documentation for this class was generated from the following file:
  • murl_math_min_max.h


Copyright © 2011-2024 Spraylight GmbH.