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

Vector-expression proxy that views a contiguous half-open subrange of an underlying vector. More...

#include <VectorProxy.hpp>

+ Inheritance diagram for CDPL::Math::VectorRange< V >:

Public Types

typedef V VectorType
 The wrapped vector type. More...
 
typedef V::SizeType SizeType
 The size type used by the wrapped vector. More...
 
typedef V::DifferenceType DifferenceType
 The signed difference type used by the wrapped vector. More...
 
typedef V::ValueType ValueType
 The element value type of the wrapped vector. More...
 
typedef V::ConstReference ConstReference
 Constant reference type to an element. More...
 
typedef std::conditional< std::is_const< V >::value, typename V::ConstReference, typename V::Reference >::type Reference
 Mutable reference type (degrades to ConstReference when the wrapped vector is const). More...
 
typedef std::conditional< std::is_const< V >::value, typename V::ConstClosureType, typename V::ClosureType >::type VectorClosureType
 Closure type used to store the wrapped vector internally (mutable or const flavor). More...
 
typedef const SelfType ConstClosureType
 Constant closure type used when this proxy appears inside another expression. More...
 
typedef SelfType ClosureType
 Closure type used when this proxy appears inside another expression. More...
 
typedef Range< SizeTypeRangeType
 The Math::Range type defining the half-open index subrange. More...
 
- Public Types inherited from CDPL::Math::VectorExpression< VectorRange< V > >
typedef VectorRange< V > ExpressionType
 The derived vector expression type. More...
 
- Public Types inherited from CDPL::Math::Expression< E >
typedef E ExpressionType
 The derived expression type (made available to expression-template machinery). More...
 

Public Member Functions

 VectorRange (VectorType &v, const RangeType &r)
 Constructs the proxy viewing the subrange r of v. More...
 
Reference operator() (SizeType i)
 Returns a mutable reference to the element at index i of the view. More...
 
ConstReference operator() (SizeType i) const
 Returns a const reference to the element at index i of the view. More...
 
Reference operator[] (SizeType i)
 Returns a mutable reference to the element at index i of the view (alias for operator()). More...
 
ConstReference operator[] (SizeType i) const
 Returns a const reference to the element at index i of the view (alias for operator()). More...
 
SizeType getStart () const
 Returns the start index of the viewed range within the wrapped vector. More...
 
SizeType getSize () const
 Returns the size of the view (number of elements covered by the range). More...
 
bool isEmpty () const
 Tells whether the view is empty (zero-length range). More...
 
VectorClosureTypegetData ()
 Returns a reference to the wrapped vector (via its stored closure). More...
 
const VectorClosureTypegetData () const
 Returns a const reference to the wrapped vector (via its stored closure). More...
 
VectorRangeoperator= (const VectorRange &r)
 Copies the elements of r into this view (writing through to the wrapped vector). More...
 
template<typename E >
VectorRangeoperator= (const VectorExpression< E > &e)
 Assigns the vector expression e to this view (writing through to the wrapped vector). More...
 
template<typename E >
VectorRangeoperator+= (const VectorExpression< E > &e)
 Adds the vector expression e componentwise to this view. More...
 
template<typename E >
VectorRangeoperator-= (const VectorExpression< E > &e)
 Subtracts the vector expression e componentwise from this view. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, VectorRange >::type & operator*= (const T &t)
 Multiplies every element of this view by the scalar t. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, VectorRange >::type & operator/= (const T &t)
 Divides every element of this view by the scalar t. More...
 
template<typename E >
VectorRangeassign (const VectorExpression< E > &e)
 Assigns the vector expression e to this view without intermediate temporary (use only when e does not alias the wrapped vector). More...
 
template<typename E >
VectorRangeplusAssign (const VectorExpression< E > &e)
 Adds the vector expression e to this view without intermediate temporary. More...
 
template<typename E >
VectorRangeminusAssign (const VectorExpression< E > &e)
 Subtracts the vector expression e from this view without intermediate temporary. More...
 
void swap (VectorRange &r)
 Swaps the elements of this view with those of r. More...
 
- Public Member Functions inherited from CDPL::Math::VectorExpression< VectorRange< V > >
const ExpressionTypeoperator() () const
 Returns a const reference to the derived vector expression. More...
 
ExpressionTypeoperator() ()
 Returns a reference to the derived vector expression. More...
 

Friends

void swap (VectorRange &r1, VectorRange &r2)
 ADL-enabled free-function form of swap(). More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Math::VectorExpression< VectorRange< V > >
 VectorExpression ()
 
 ~VectorExpression ()
 
- Protected Member Functions inherited from CDPL::Math::Expression< E >
 Expression ()
 
 ~Expression ()
 

Detailed Description

template<typename V>
class CDPL::Math::VectorRange< V >

Vector-expression proxy that views a contiguous half-open subrange of an underlying vector.

Template Parameters
VThe wrapped vector type.

Member Typedef Documentation

◆ VectorType

template<typename V >
typedef V CDPL::Math::VectorRange< V >::VectorType

The wrapped vector type.

◆ SizeType

template<typename V >
typedef V::SizeType CDPL::Math::VectorRange< V >::SizeType

The size type used by the wrapped vector.

◆ DifferenceType

template<typename V >
typedef V::DifferenceType CDPL::Math::VectorRange< V >::DifferenceType

The signed difference type used by the wrapped vector.

◆ ValueType

template<typename V >
typedef V::ValueType CDPL::Math::VectorRange< V >::ValueType

The element value type of the wrapped vector.

◆ ConstReference

template<typename V >
typedef V::ConstReference CDPL::Math::VectorRange< V >::ConstReference

Constant reference type to an element.

◆ Reference

template<typename V >
typedef std::conditional<std::is_const<V>::value, typename V::ConstReference, typename V::Reference>::type CDPL::Math::VectorRange< V >::Reference

Mutable reference type (degrades to ConstReference when the wrapped vector is const).

◆ VectorClosureType

template<typename V >
typedef std::conditional<std::is_const<V>::value, typename V::ConstClosureType, typename V::ClosureType>::type CDPL::Math::VectorRange< V >::VectorClosureType

Closure type used to store the wrapped vector internally (mutable or const flavor).

◆ ConstClosureType

template<typename V >
typedef const SelfType CDPL::Math::VectorRange< V >::ConstClosureType

Constant closure type used when this proxy appears inside another expression.

◆ ClosureType

template<typename V >
typedef SelfType CDPL::Math::VectorRange< V >::ClosureType

Closure type used when this proxy appears inside another expression.

◆ RangeType

template<typename V >
typedef Range<SizeType> CDPL::Math::VectorRange< V >::RangeType

The Math::Range type defining the half-open index subrange.

Constructor & Destructor Documentation

◆ VectorRange()

template<typename V >
CDPL::Math::VectorRange< V >::VectorRange ( VectorType v,
const RangeType r 
)
inline

Constructs the proxy viewing the subrange r of v.

Parameters
vThe wrapped vector.
rThe half-open index range selecting the viewed subrange.

Member Function Documentation

◆ operator()() [1/2]

template<typename V >
Reference CDPL::Math::VectorRange< V >::operator() ( SizeType  i)
inline

Returns a mutable reference to the element at index i of the view.

Parameters
iThe zero-based index within the view.
Returns
A mutable reference to the underlying element v(range(i)).

◆ operator()() [2/2]

template<typename V >
ConstReference CDPL::Math::VectorRange< V >::operator() ( SizeType  i) const
inline

Returns a const reference to the element at index i of the view.

Parameters
iThe zero-based index within the view.
Returns
A const reference to the underlying element v(range(i)).

◆ operator[]() [1/2]

template<typename V >
Reference CDPL::Math::VectorRange< V >::operator[] ( SizeType  i)
inline

Returns a mutable reference to the element at index i of the view (alias for operator()).

Parameters
iThe zero-based index within the view.
Returns
A mutable reference to the underlying element.

◆ operator[]() [2/2]

template<typename V >
ConstReference CDPL::Math::VectorRange< V >::operator[] ( SizeType  i) const
inline

Returns a const reference to the element at index i of the view (alias for operator()).

Parameters
iThe zero-based index within the view.
Returns
A const reference to the underlying element.

◆ getStart()

template<typename V >
SizeType CDPL::Math::VectorRange< V >::getStart ( ) const
inline

Returns the start index of the viewed range within the wrapped vector.

Returns
The start index of the range.

◆ getSize()

template<typename V >
SizeType CDPL::Math::VectorRange< V >::getSize ( ) const
inline

Returns the size of the view (number of elements covered by the range).

Returns
The number of elements in the view.

◆ isEmpty()

template<typename V >
bool CDPL::Math::VectorRange< V >::isEmpty ( ) const
inline

Tells whether the view is empty (zero-length range).

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

◆ getData() [1/2]

template<typename V >
VectorClosureType& CDPL::Math::VectorRange< V >::getData ( )
inline

Returns a reference to the wrapped vector (via its stored closure).

Returns
A reference to the wrapped vector closure.

◆ getData() [2/2]

template<typename V >
const VectorClosureType& CDPL::Math::VectorRange< V >::getData ( ) const
inline

Returns a const reference to the wrapped vector (via its stored closure).

Returns
A const reference to the wrapped vector closure.

◆ operator=() [1/2]

template<typename V >
VectorRange& CDPL::Math::VectorRange< V >::operator= ( const VectorRange< V > &  r)
inline

Copies the elements of r into this view (writing through to the wrapped vector).

Parameters
rThe source range view.
Returns
A reference to itself.

◆ operator=() [2/2]

template<typename V >
template<typename E >
VectorRange& CDPL::Math::VectorRange< V >::operator= ( const VectorExpression< E > &  e)
inline

Assigns the vector expression e to this view (writing through to the wrapped vector).

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ operator+=()

template<typename V >
template<typename E >
VectorRange& CDPL::Math::VectorRange< V >::operator+= ( const VectorExpression< E > &  e)
inline

Adds the vector expression e componentwise to this view.

Template Parameters
EThe source vector expression type.
Parameters
eThe vector expression to add.
Returns
A reference to itself.

◆ operator-=()

template<typename V >
template<typename E >
VectorRange& CDPL::Math::VectorRange< V >::operator-= ( const VectorExpression< E > &  e)
inline

Subtracts the vector expression e componentwise from this view.

Template Parameters
EThe source vector expression type.
Parameters
eThe vector expression to subtract.
Returns
A reference to itself.

◆ operator*=()

template<typename V >
template<typename T >
std::enable_if<IsScalar<T>::value, VectorRange>::type& CDPL::Math::VectorRange< V >::operator*= ( const T &  t)
inline

Multiplies every element of this view by the scalar t.

Template Parameters
TThe scalar type.
Parameters
tThe scalar multiplier.
Returns
A reference to itself.

◆ operator/=()

template<typename V >
template<typename T >
std::enable_if<IsScalar<T>::value, VectorRange>::type& CDPL::Math::VectorRange< V >::operator/= ( const T &  t)
inline

Divides every element of this view by the scalar t.

Template Parameters
TThe scalar type.
Parameters
tThe scalar divisor.
Returns
A reference to itself.

◆ assign()

template<typename V >
template<typename E >
VectorRange& CDPL::Math::VectorRange< V >::assign ( const VectorExpression< E > &  e)
inline

Assigns the vector expression e to this view without intermediate temporary (use only when e does not alias the wrapped vector).

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ plusAssign()

template<typename V >
template<typename E >
VectorRange& CDPL::Math::VectorRange< V >::plusAssign ( const VectorExpression< E > &  e)
inline

Adds the vector expression e to this view without intermediate temporary.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ minusAssign()

template<typename V >
template<typename E >
VectorRange& CDPL::Math::VectorRange< V >::minusAssign ( const VectorExpression< E > &  e)
inline

Subtracts the vector expression e from this view without intermediate temporary.

Template Parameters
EThe source vector expression type.
Parameters
eThe source vector expression.
Returns
A reference to itself.

◆ swap()

template<typename V >
void CDPL::Math::VectorRange< V >::swap ( VectorRange< V > &  r)
inline

Swaps the elements of this view with those of r.

Parameters
rThe view to swap with.

Friends And Related Function Documentation

◆ swap

template<typename V >
void swap ( VectorRange< V > &  r1,
VectorRange< V > &  r2 
)
friend

ADL-enabled free-function form of swap().

Parameters
r1The first view.
r2The second view.

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