Domi
Multi-dimensional, distributed data structures
|
Reverse iterator class suitable for multi-dimensional arrays. More...
#include <Domi_MDRevIterator.hpp>
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_type & | operator* () |
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. | |
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:
and declare rbegin(), rend() and crbegin(), crend() methods:
Domi::MDRevIterator< MDARRAY >::MDRevIterator | ( | const MDARRAY & | mdarray, |
bool | end_index = false |
||
) |
MDRevIterator constructor.
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.
Domi::MDRevIterator< MDARRAY >::MDRevIterator | ( | const MDARRAY & | mdarray, |
const Teuchos::ArrayView< dim_type > & | index | ||
) |
Index constructor.
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.
Domi::MDRevIterator< MDARRAY >::MDRevIterator | ( | const MDRevIterator< MDARRAY > & | source | ) |
Copy constructor.
source | [in] The source MDRevIterator to be copied |
|
inline |
Return the current index value along the given axis.
axis | [in] Requested axis for index value |
bool Domi::MDRevIterator< MDARRAY >::operator!= | ( | const MDRevIterator< MDARRAY > & | other | ) | const |
Inequality operator.
other | [in] Iterator to be compared to |
MDRevIterator< MDARRAY > & Domi::MDRevIterator< MDARRAY >::operator= | ( | const MDRevIterator< MDARRAY > & | source | ) |
Assignment operator.
source | [in] Source iterator for assignment |
bool Domi::MDRevIterator< MDARRAY >::operator== | ( | const MDRevIterator< MDARRAY > & | other | ) | const |
Equality operator.
other | [in] Iterator to be compared to |