Domi
Multi-dimensional, distributed data structures
 All Classes Files Functions Variables Typedefs Friends
Public Member Functions | Friends | 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

dim_type index (int axis) const
 Return the current index value along the given axis. More...
 
Constructors and Destructor
 MDRevIterator (const MDARRAY &mdarray, bool end_index=false)
 MDRevIterator constructor. More...
 
 MDRevIterator (const MDARRAY &mdarray, const Teuchos::ArrayView< dim_type > &index)
 Index constructor. More...
 
 MDRevIterator (const MDRevIterator< MDARRAY > &source)
 Copy constructor. More...
 
 ~MDRevIterator ()
 Destructor.
 
Standard Operators
MDRevIterator< MDARRAY > & operator= (const MDRevIterator< MDARRAY > &source)
 Assignment operator. More...
 
bool operator== (const MDRevIterator< MDARRAY > &other) const
 Equality operator. More...
 
bool operator!= (const MDRevIterator< MDARRAY > &other) const
 Inequality operator. More...
 
value_typeoperator* ()
 Dereferencing operator.
 
pointer operator-> () const
 Dereferencing arrow operator.
 
MDRevIterator< MDARRAY > & operator++ ()
 Prefix increment operator.
 
MDRevIterator< MDARRAY > operator++ (int)
 Postfix increment operator.
 
MDRevIterator< MDARRAY > & operator-- ()
 Prefix decrement operator.
 
MDRevIterator< MDARRAY > operator-- (int)
 Postfix decrement operator.
 

Friends

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;

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

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.

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.

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

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
template<class MDARRAY>
bool Domi::MDRevIterator< MDARRAY >::operator!= ( const MDRevIterator< MDARRAY > &  other) const

Inequality operator.

Parameters
other[in] Iterator to be compared to
template<class MDARRAY>
MDRevIterator< MDARRAY > & Domi::MDRevIterator< MDARRAY >::operator= ( const MDRevIterator< MDARRAY > &  source)

Assignment operator.

Parameters
source[in] Source iterator for assignment
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 on Fri Dec 20 2024 09:28:21 for Domi by doxygen 1.8.5