Domi
Multi-dimensional, distributed data structures
Loading...
Searching...
No Matches
List of all members
Domi::MDRevIterator< MDARRAY > Class Template Reference

Reverse iterator class suitable for multi-dimensional arrays. More...

#include <Domi_MDRevIterator.hpp>

+ Inheritance diagram for Domi::MDRevIterator< MDARRAY >:

Public Types

MDARRAY typedefs
typedef MDARRAY::value_type value_type
 Value type.
 
typedef MDARRAY::pointer pointer
 Pointer type.
 

Public Member Functions

Constructors and Destructor
 MDRevIterator (const MDARRAY &mdarray, bool end_index=false)
 MDRevIterator constructor.
 
 MDRevIterator (const MDARRAY &mdarray, const Teuchos::ArrayView< dim_type > &index)
 Index constructor.
 
 MDRevIterator (const MDRevIterator< MDARRAY > &source)
 Copy constructor.
 
 ~MDRevIterator ()
 Destructor.
 

Standard Operators

MDRevIterator< MDARRAY > & operator= (const MDRevIterator< MDARRAY > &source)
 Assignment operator.
 
bool operator== (const MDRevIterator< MDARRAY > &other) const
 Equality operator.
 
bool operator!= (const MDRevIterator< MDARRAY > &other) const
 Inequality operator.
 
value_typeoperator* ()
 Dereferencing operator.
 
pointer operator-> () const
 Dereferencing arrow operator.
 
MDRevIterator< MDARRAY > & operator++ ()
 Prefix increment operator.
 
MDRevIterator< MDARRAYoperator++ (int)
 Postfix increment operator.
 
MDRevIterator< MDARRAY > & operator-- ()
 Prefix decrement operator.
 
MDRevIterator< MDARRAYoperator-- (int)
 Postfix decrement operator.
 
dim_type index (int axis) const
 Return the current index value along the given axis.
 
template<typename T2 >
std::ostream & operator<< (std::ostream &os, const MDRevIterator< T2 > &a)
 Stream output operator.
 

Detailed Description

template<class MDARRAY>
class Domi::MDRevIterator< MDARRAY >

Reverse iterator class suitable for multi-dimensional arrays.

This reverse iterator is specialized for multi-dimensional arrays. It can be used like a standard reverse iterator, without knowledge of the number of dimensions of the array. It is designed to iterate only over valid elements of the array. It is possible, especially with sliced views into a parent array, for the data buffer to have stride gaps that do not belong to the array. This reverse iterator avoids those stride gaps by keeping an internal record of the multi- dimensional index, and only iterating over valid indexes.

To apply MDRevIterator to all three multi-dimensional array types (MDArray, MDArrayView and MDArrayRCP), the class is templated on parameter class MDARRAY, which is intended to be any one of the three MDArray types. The MDARRAY class is expected to support the the typedefs size_type and value_type, the numDims() method and the _ptr, _strides, _dimensions, and _layout attributes.

It is intended that the array class that will use the MDRevIterator will declare the MDRevIterator to be a friend and to typedef the fully qualified class. For example, within the MDArray< T > class:

friend class MDRevIterator< MDArray< T > >;
friend class MDRevIterator< MDArray< const T > >;
typedef MDRevIterator< MDArray< T > > reverse_iterator;
typedef MDRevIterator< MDArray< const T > > const_reverse_iterator;
Memory-safe templated multi-dimensional array class.
Definition Domi_MDArray.hpp:287
Reverse iterator class suitable for multi-dimensional arrays.
Definition Domi_MDRevIterator.hpp:100

and declare rbegin(), rend() and crbegin(), crend() methods:

reverse_iterator rbegin() { return reverse_iterator(*this ); }
reverse_iterator rend() { return reverse_iterator(*this, true); }
const_reverse_iterator crbegin() const { return const_reverse_iterator(*this ); }
const_reverse_iterator crend() const { return const_reverse_iterator(*this, true); }

Constructor & Destructor Documentation

◆ MDRevIterator() [1/3]

template<class MDARRAY >
Domi::MDRevIterator< MDARRAY >::MDRevIterator ( const MDARRAY & mdarray,
bool end_index = false )

MDRevIterator constructor.

Parameters
mdarray[in] The multi-dimensional array object on which the iterator will act upon
end_index[in] If true, set the internal index to the MDARRAY end() index. If false, set the internal index to the MDARRAY begin() index. Default false.

Produces an iterator with index corresponding to either the MDARRAY begin() or end() methods, depending on the value of the end_index argument.

◆ MDRevIterator() [2/3]

template<class MDARRAY >
Domi::MDRevIterator< MDARRAY >::MDRevIterator ( const MDARRAY & mdarray,
const Teuchos::ArrayView< dim_type > & index )

Index constructor.

Parameters
mdarray[in] The multi-dimensional array object on which will be iterated.
index[in] A Teuchos::ArrayView that specifies where the internal index of the iterator should start.

Produces an iterator with index corresponding to the given index.

◆ MDRevIterator() [3/3]

template<class MDARRAY >
Domi::MDRevIterator< MDARRAY >::MDRevIterator ( const MDRevIterator< MDARRAY > & source)

Copy constructor.

Parameters
source[in] The source MDRevIterator to be copied

Member Function Documentation

◆ index()

template<class MDARRAY >
dim_type Domi::MDRevIterator< MDARRAY >::index ( int axis) const
inline

Return the current index value along the given axis.

Parameters
axis[in] Requested axis for index value

◆ operator!=()

template<class MDARRAY >
bool Domi::MDRevIterator< MDARRAY >::operator!= ( const MDRevIterator< MDARRAY > & other) const

Inequality operator.

Parameters
other[in] Iterator to be compared to

◆ operator=()

Assignment operator.

Parameters
source[in] Source iterator for assignment

◆ operator==()

template<class MDARRAY >
bool Domi::MDRevIterator< MDARRAY >::operator== ( const MDRevIterator< MDARRAY > & other) const

Equality operator.

Parameters
other[in] Iterator to be compared to

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

Generated for Domi by doxygen 1.10.0