MathPlot
Public Member Functions | Public Attributes | List of all members
mpRange< T > Struct Template Reference

Represents a numeric range with minimum and maximum values. More...

#include <mathplot.h>

Collaboration diagram for mpRange< T >:
Collaboration graph
[legend]

Public Member Functions

 mpRange ()
 Default constructor.
 
 mpRange (T value1, T value2)
 Create range with the 2 values.
 
void Set (T _value)
 Initialize min and max.
 
void Set (T _min, T _max)
 Set min, max function.
 
void SetMin (T _min)
 Set min function, correct max.
 
void SetMax (T _max)
 Set max function, correct min.
 
void Assign (T value1, T value2)
 Assign values to min and max.
 
bool IsSet ()
 Check if this mpRange has been assigned any values.
 
void Update (T value)
 Update range according new value: Expand the range to include the value. More...
 
void Update (T _min, T _max)
 Update range with new min and max values if this expand the range If _min < min then min = _min and if _max > max then max = _max.
 
void Update (mpRange range)
 Update range with new range values if this expand the range.
 
void Check (void)
 Check to always have a range. If min = max then introduce the 0 to make a range.
 
Length (void) const
 Length of the range.
 
GetCenter (void) const
 Center of the range.
 
GetMaxAbs (void) const
 Returns max absolute value of the range.
 
void ToLog (void)
 Convert to log range.
 
bool PointIsInside (T point) const
 Return true if the point is inside the range (min and max included)
 
bool operator== (const mpRange &other) const
 
bool operator!= (const mpRange &other) const
 

Public Attributes

min = 0
 The min value of the range.
 
max = 0
 The max value of the range.
 

Detailed Description

template<typename T>
struct mpRange< T >

Represents a numeric range with minimum and maximum values.

This struct holds a range defined by min and max values. It supports equality comparison using the default operator==.

Member Function Documentation

◆ Update()

template<typename T>
void mpRange< T >::Update ( value)
inline

Update range according new value: Expand the range to include the value.

If value < min then min = value and if value > max then max = value