AMRange  201909
String localization library
Public Member Functions | Public Attributes | List of all members
AMCore::AMRange< T > Class Template Reference

Range and set of range operations. More...

#include <AMRange.h>

Public Member Functions

 AMRange ()
 empty constructor Uses T() for init bounds. More...
 
 AMRange (T _from, T _to)
 empty constructor Uses T() for init bounds. More...
 
bool operator< (const AMRange &right) const
 less operator Used namely for std::set container More...
 
AMRange & operator-= (const AMRange &right)
 minus operator Cut part of range by intersect with right operand. If ranges are in disjunction, range is unchanged. If right range is inside left (and range will be splitted to two intervals), range become invalid. More...
 
AMRange & operator+= (const AMRange &right)
 plus operator Cut part of range by intersect with right operand. If right range is inside left, range is unchanged. If ranges are in disjunction (and range will splitted to two), range become invalid. More...
 
bool operator== (const AMRange &right) const
 comparison operator Tests both bounds for equality. More...
 
bool operator!= (const AMRange &right) const
 comparison operator If at least one bound not equalt to rught bound. More...
 
AMRange & intersect (const AMRange &right)
 intersect Intersection with right interval If ranges are in disjunction, range become empty More...
 
bool valid () const
 test for validity Simply checks that from bound >= to bound More...
 
bool nonEmpty () const
 test for validity and empty Simply checks that from bound > to bound More...
 
bool in (T num) const
 check that number is inside Remember that interval is open from right, so if num == to, result => false More...
 
bool in (const AMRange &rng) const
 check that number is inside Remember that interval is open from right, so if num == to, result => false More...
 
bool empty () const
 test for empty Simply checks that from bound == to bound More...
 

Public Attributes

T from
 left bound
 
T to
 right bound
 

Detailed Description

template<typename T>
class AMCore::AMRange< T >

Range and set of range operations.

This range means interval closed from left and open from right &lt from, to ). Template parameter may be an integer or float types. Any other class as template parameter may works, however is not tested.

There are basic operations for set of ranges. Set of ranges means "interval with gaps" e.q. Second interval start above first ends , thirds interval start above second end etc... Operation with set produces such set of ranges and there is a pack function to ensure this.

Constructor & Destructor Documentation

◆ AMRange() [1/2]

template<typename T >
AMCore::AMRange< T >::AMRange

empty constructor Uses T() for init bounds.

Exceptions
Thisfunction will not throw an exception.

◆ AMRange() [2/2]

template<typename T >
AMCore::AMRange< T >::AMRange ( T  _from,
T  _to 
)

empty constructor Uses T() for init bounds.

Parameters
_frombound
_tobound
Exceptions
Thisfunction will not throw an exception.

Member Function Documentation

◆ empty()

template<typename T >
bool AMCore::AMRange< T >::empty
inline

test for empty Simply checks that from bound == to bound

Exceptions
Thisfunction will not throw an exception.

◆ in() [1/2]

template<typename T >
bool AMCore::AMRange< T >::in ( const AMRange< T > &  rng) const
inline

check that number is inside Remember that interval is open from right, so if num == to, result => false

Parameters
rng
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::from, and AMCore::AMRange< T >::to.

◆ in() [2/2]

template<typename T >
bool AMCore::AMRange< T >::in ( T  num) const
inline

check that number is inside Remember that interval is open from right, so if num == to, result => false

Parameters
num
Exceptions
Thisfunction will not throw an exception.

◆ intersect()

template<typename T >
AMRange< T > & AMCore::AMRange< T >::intersect ( const AMRange< T > &  right)
inline

intersect Intersection with right interval If ranges are in disjunction, range become empty

Parameters
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::from, and AMCore::AMRange< T >::to.

Referenced by AMCore::intersect().

◆ nonEmpty()

template<typename T >
bool AMCore::AMRange< T >::nonEmpty
inline

test for validity and empty Simply checks that from bound > to bound

Exceptions
Thisfunction will not throw an exception.

Referenced by AMCore::operator-().

◆ operator!=()

template<typename T >
bool AMCore::AMRange< T >::operator!= ( const AMRange< T > &  right) const
inline

comparison operator If at least one bound not equalt to rught bound.

Parameters
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::from, and AMCore::AMRange< T >::to.

◆ operator+=()

template<typename T >
AMRange< T > & AMCore::AMRange< T >::operator+= ( const AMRange< T > &  right)
inline

plus operator Cut part of range by intersect with right operand. If right range is inside left, range is unchanged. If ranges are in disjunction (and range will splitted to two), range become invalid.

Parameters
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::from, AMCore::AMRange< T >::to, AMCore::AMRange< T >::valid(), and AMCore::valid().

◆ operator-=()

template<typename T >
AMRange< T > & AMCore::AMRange< T >::operator-= ( const AMRange< T > &  right)
inline

minus operator Cut part of range by intersect with right operand. If ranges are in disjunction, range is unchanged. If right range is inside left (and range will be splitted to two intervals), range become invalid.

Parameters
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::from, AMCore::AMRange< T >::to, AMCore::AMRange< T >::valid(), and AMCore::valid().

◆ operator<()

template<typename T >
bool AMCore::AMRange< T >::operator< ( const AMRange< T > &  right) const
inline

less operator Used namely for std::set container

Parameters
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::from, and AMCore::AMRange< T >::to.

◆ operator==()

template<typename T >
bool AMCore::AMRange< T >::operator== ( const AMRange< T > &  right) const
inline

comparison operator Tests both bounds for equality.

Parameters
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::from, and AMCore::AMRange< T >::to.

◆ valid()

template<typename T >
bool AMCore::AMRange< T >::valid
inline

test for validity Simply checks that from bound >= to bound

Exceptions
Thisfunction will not throw an exception.

Referenced by AMCore::AMRange< T >::operator+=(), AMCore::operator-(), AMCore::AMRange< T >::operator-=(), and AMCore::pack().


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