Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | Friends | List of all members
CDPL::Math::Range< S > Class Template Reference

Half-open index range \( [start, stop) \) used for slicing vector and matrix expressions. More...

#include <Range.hpp>

+ Inheritance diagram for CDPL::Math::Range< S >:

Public Types

typedef S SizeType
 The integral size/index type. More...
 

Public Member Functions

 Range ()
 Constructs an empty range \( [0, 0) \). More...
 
 Range (SizeType start, SizeType stop)
 Constructs the range \( [start, stop) \). More...
 
SizeType operator() (SizeType i) const
 Maps the local position i to the global index start + i. More...
 
SizeType getStart () const
 Returns the lower (inclusive) bound. More...
 
SizeType getStop () const
 Returns the upper (exclusive) bound. More...
 
SizeType getSize () const
 Returns the size of the range, \( stop - start \). More...
 
bool isEmpty () const
 Tells whether the range is empty. More...
 
bool operator== (const Range &r) const
 Equality comparison. More...
 
bool operator!= (const Range &r) const
 Inequality comparison. More...
 
void swap (Range &r)
 Swaps the contents of *this and r. More...
 

Friends

void swap (Range &r1, Range &r2)
 Free-function swap overload. More...
 

Detailed Description

template<typename S>
class CDPL::Math::Range< S >

Half-open index range \( [start, stop) \) used for slicing vector and matrix expressions.

Template Parameters
SThe integral size/index type.

Member Typedef Documentation

◆ SizeType

template<typename S >
typedef S CDPL::Math::Range< S >::SizeType

The integral size/index type.

Constructor & Destructor Documentation

◆ Range() [1/2]

template<typename S >
CDPL::Math::Range< S >::Range ( )
inline

Constructs an empty range \( [0, 0) \).

◆ Range() [2/2]

template<typename S >
CDPL::Math::Range< S >::Range ( SizeType  start,
SizeType  stop 
)
inline

Constructs the range \( [start, stop) \).

Parameters
startThe lower (inclusive) bound.
stopThe upper (exclusive) bound.
Exceptions
Base::RangeErrorif start > stop.

Member Function Documentation

◆ operator()()

template<typename S >
SizeType CDPL::Math::Range< S >::operator() ( SizeType  i) const
inline

Maps the local position i to the global index start + i.

Parameters
iThe zero-based local position.
Returns
The global index.
Exceptions
Base::IndexErrorif i is not in the range \( [0, size) \).

◆ getStart()

template<typename S >
SizeType CDPL::Math::Range< S >::getStart ( ) const
inline

Returns the lower (inclusive) bound.

Returns
The lower bound.

◆ getStop()

template<typename S >
SizeType CDPL::Math::Range< S >::getStop ( ) const
inline

Returns the upper (exclusive) bound.

Returns
The upper bound.

◆ getSize()

template<typename S >
SizeType CDPL::Math::Range< S >::getSize ( ) const
inline

Returns the size of the range, \( stop - start \).

Returns
The range size.

◆ isEmpty()

template<typename S >
bool CDPL::Math::Range< S >::isEmpty ( ) const
inline

Tells whether the range is empty.

Returns
true if the range is empty, and false otherwise.

◆ operator==()

template<typename S >
bool CDPL::Math::Range< S >::operator== ( const Range< S > &  r) const
inline

Equality comparison.

Parameters
rThe other range.
Returns
true if both ranges have the same start and stop, and false otherwise.

◆ operator!=()

template<typename S >
bool CDPL::Math::Range< S >::operator!= ( const Range< S > &  r) const
inline

Inequality comparison.

Parameters
rThe other range.
Returns
true if the ranges differ in start or stop, and false otherwise.

◆ swap()

template<typename S >
void CDPL::Math::Range< S >::swap ( Range< S > &  r)
inline

Swaps the contents of *this and r.

Parameters
rThe other range.

Friends And Related Function Documentation

◆ swap

template<typename S >
void swap ( Range< S > &  r1,
Range< S > &  r2 
)
friend

Free-function swap overload.

Parameters
r1The first range.
r2The second range.

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