[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]
![]() |
MultiArrayNavigator Class Template Reference | ![]() |
---|
A navigator that provides acces to the 1D subranges of an n-dimensional range given by a vigra::MultiIterator and an nD shape. More...
#include "vigra/navigator.hxx"
Public Types | |
typedef MULTI_ITERATOR::multi_difference_type | shape_type |
typedef MULTI_ITERATOR::iterator | iterator |
Public Methods | |
MultiArrayNavigator (MULTI_ITERATOR const &i, shape_type const &shape, unsigned int inner_dimension) | |
void | operator++ () |
void | operator++ (int) |
bool | hasMore () const |
bool | atEnd () const |
Detailed Description |
Normally, the innermost loop of an iteration extends over the innermost dimension of a given array. Sometimes, however, it is necessary to have some other dimension in the inner loop. For example, instead of iterating over the rows, the inner loop should extend over the columns. The class MultiArrayNavigator encapsulates the necessary functionality. Given an arbitrary dimensional array (represented by a vigra::MultiIterator/shape pair), and the desired inner loop dimension d
, it moves the encapsulated iterator to all possible starting points of 1D subsets along the given dimension (e.g. all columns). By calling begin()
and end()
, one can then obtain an STL-compatible 1-dimensional iterator for the current subset.
The template parameters specify the embedded iterator type and its dimension.
Usage:
#include "vigra/navigator.hxx"
Namespace: vigra
typedef vigra::MultiArray<3, int> Array; Array a(Array::size_type(X, Y, Z)); typedef vigra::MultiArrayNavigator<Array::traverser, 3> Navigator; for(int d=0; d<3; ++d) { // create Navigator for dimension d Navigator nav(a.traverser_begin(), a.shape(), d); // outer loop: move navigator to all starting points // of 1D subsets that run parallel to coordinate axis d for(; nav.hasMore(); ++nav) { // inner loop: linear iteration over current subset // d == {0, 1, 2}: interate along {x, y, z}-axis respectively Navigator::iterator i = nav.begin(), end = nav.end(); for(; i != end; ++i) // do something } }
|
The iterator type for the inner loop (result of begin() and end()). |
|
The required shape type for the given iterator type. |
|
Construct navigator for multi-dimensional iterator |
|
true if iterator is exhausted. |
|
true if there are more elements. |
|
Advance to next starting location. |
|
Advance to next starting location. |
© Ullrich Köthe (koethe@informatik.uni-hamburg.de) |
html generated using doxygen and Python
|