Domi
Multi-dimensional, distributed data structures
|
Iterator class suitable for multi-dimensional arrays. More...
#include <Domi_MDIterator.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 | |
MDIterator (const MDARRAY &mdarray, bool end_index=false) | |
MDIterator constructor. More... | |
MDIterator (const MDARRAY &mdarray, const Teuchos::ArrayView< dim_type > &index) | |
Index constructor. More... | |
MDIterator (const MDIterator< MDARRAY > &source) | |
Copy constructor. More... | |
~MDIterator () | |
Destructor. | |
Standard Operators | |
MDIterator< MDARRAY > & | operator= (const MDIterator< MDARRAY > &source) |
Assignment operator. More... | |
bool | operator== (const MDIterator< MDARRAY > &other) const |
Equality operator. More... | |
bool | operator!= (const MDIterator< MDARRAY > &other) const |
Inequality operator. More... | |
value_type & | operator* () |
Dereferencing operator. | |
pointer | operator-> () const |
Dereferencing arrow operator. | |
MDIterator< MDARRAY > & | operator++ () |
Prefix increment operator. | |
MDIterator< MDARRAY > | operator++ (int) |
Postfix increment operator. | |
MDIterator< MDARRAY > & | operator-- () |
Prefix decrement operator. | |
MDIterator< MDARRAY > | operator-- (int) |
Postfix decrement operator. | |
Friends | |
template<typename T2 > | |
std::ostream & | operator<< (std::ostream &os, const MDIterator< T2 > &a) |
Stream output operator. | |
Iterator class suitable for multi-dimensional arrays.
This iterator is specialized for multi-dimensional arrays. It can be used like a standard 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 iterator avoids those stride gaps by keeping an internal record of the multi- dimensional index, and only iterating over valid indexes.
To apply MDIterator 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, dim_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 MDIterator will declare the MDIterator to be a friend and to typedef the fully qualified class. For example, within the MDArray< T > class:
and declare begin(), end() and cbegin(), cend() methods:
Domi::MDIterator< MDARRAY >::MDIterator | ( | const MDARRAY & | mdarray, |
bool | end_index = false |
||
) |
MDIterator 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::MDIterator< MDARRAY >::MDIterator | ( | const MDARRAY & | mdarray, |
const Teuchos::ArrayView< dim_type > & | index | ||
) |
Index constructor.
mdarray | [in] The multi-dimensional array object on which the iterator will act upon |
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::MDIterator< MDARRAY >::MDIterator | ( | const MDIterator< MDARRAY > & | source | ) |
Copy constructor.
source | [in] The source MDIterator to be copied |
|
inline |
Return the current index value along the given axis.
axis | [in] Requested axis for index value |
bool Domi::MDIterator< MDARRAY >::operator!= | ( | const MDIterator< MDARRAY > & | other | ) | const |
Inequality operator.
other | [in] Iterator to be compared to |
MDIterator< MDARRAY > & Domi::MDIterator< MDARRAY >::operator= | ( | const MDIterator< MDARRAY > & | source | ) |
Assignment operator.
source | [in] Source iterator for assignment |
bool Domi::MDIterator< MDARRAY >::operator== | ( | const MDIterator< MDARRAY > & | other | ) | const |
Equality operator.
other | [in] Iterator to be compared to |