OpenMS  2.8.0
Public Member Functions | Protected Attributes | List of all members
RangeBase Struct Reference

Base class for a simple range with minimum and maximum. More...

#include <OpenMS/KERNEL/RangeManager.h>

Inheritance diagram for RangeBase:
[legend]
Collaboration diagram for RangeBase:
[legend]

Public Member Functions

 RangeBase ()=default
 Ctor: initialize with empty range. More...
 
 RangeBase (const double min, const double max)
 
void clear ()
 make the range empty, i.e. isEmpty() will be true More...
 
bool isEmpty () const
 is the range empty (i.e. default constructed or cleared using clear())? More...
 
bool contains (const double value) const
 is value within [min, max]? More...
 
bool contains (const RangeBase &inner_range) const
 is the range inner_range within [min, max]? More...
 
void extend (const RangeBase &other)
 ensure the range includes the range of other More...
 
void extend (const double value)
 extend the range such that it includes the given value More...
 
void scaleBy (const double factor)
 Scale the range of the dimension by a factor. A factor > 1 increases the range; factor < 1 decreases it. More...
 
void assign (const RangeBase &rhs)
 
bool operator== (const RangeBase &rhs) const
 
Accessors for min and max

We use accessors, to keep range consistent (i.e. ensure that min <= max)

void setMin (const double min)
 sets the minimum (and the maximum, if uninitialized) More...
 
void setMax (const double max)
 sets the maximum (and the minimum, if uninitialized) More...
 
double getMin () const
 only useful if isEmpty() returns false More...
 
double getMax () const
 only useful if isEmpty() returns false More...
 

Protected Attributes

double min_ = std::numeric_limits<double>::max()
 
double max_ = -std::numeric_limits<double>::max()
 

Detailed Description

Base class for a simple range with minimum and maximum.

Constructor & Destructor Documentation

◆ RangeBase() [1/2]

RangeBase ( )
default

Ctor: initialize with empty range.

◆ RangeBase() [2/2]

RangeBase ( const double  min,
const double  max 
)
inline

set min and max

Exceptions
Exception::InvalidRangeif min > max

Member Function Documentation

◆ assign()

void assign ( const RangeBase rhs)
inline

◆ clear()

void clear ( )
inline

make the range empty, i.e. isEmpty() will be true

◆ contains() [1/2]

bool contains ( const double  value) const
inline

◆ contains() [2/2]

bool contains ( const RangeBase inner_range) const
inline

is the range inner_range within [min, max]?

References RangeBase::max_, and RangeBase::min_.

◆ extend() [1/2]

void extend ( const double  value)
inline

extend the range such that it includes the given value

◆ extend() [2/2]

void extend ( const RangeBase other)
inline

ensure the range includes the range of other

References RangeBase::max_, and RangeBase::min_.

◆ getMax()

double getMax ( ) const
inline

only useful if isEmpty() returns false

◆ getMin()

double getMin ( ) const
inline

only useful if isEmpty() returns false

◆ isEmpty()

bool isEmpty ( ) const
inline

is the range empty (i.e. default constructed or cleared using clear())?

◆ operator==()

bool operator== ( const RangeBase rhs) const
inline

References RangeBase::max_, and RangeBase::min_.

◆ scaleBy()

void scaleBy ( const double  factor)
inline

Scale the range of the dimension by a factor. A factor > 1 increases the range; factor < 1 decreases it.

Let d = max - min; then min = min - d*(factor-1)/2, i.e. scale(1.5) extends the range by 25% on each side.

Scaling an empty range will not have any effect.

Parameters
factorThe multiplier to increase the range by

◆ setMax()

void setMax ( const double  max)
inline

sets the maximum (and the minimum, if uninitialized)

◆ setMin()

void setMin ( const double  min)
inline

sets the minimum (and the maximum, if uninitialized)

Member Data Documentation

◆ max_

double max_ = -std::numeric_limits<double>::max()
protected

◆ min_

double min_ = std::numeric_limits<double>::max()
protected