[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

| MultiArrayNavigator< MULTI_ITERATOR, N > Class Template Reference |

A navigator that provides access 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::iterator | iterator
typedef MULTI_ITERATOR::multi_difference_type | shape_type

## Public Member Functions

bool | atEnd () const
bool | hasMore () const
| MultiArrayNavigator (MULTI_ITERATOR const &i, shape_type const &shape, unsigned int inner_dimension)
void | operator++ ()
void | operator++ (int)

## Detailed Description

### template<class MULTI_ITERATOR, unsigned int N>
class vigra::MultiArrayNavigator< MULTI_ITERATOR, N >

A navigator that provides access to the 1D subranges of an n-dimensional range given by a vigra::MultiIterator and an nD shape.

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}: iterate along {x, y, z}-axis respectively
Navigator::iterator i = nav.begin(), end = nav.end();
for(; i != end; ++i)
// do something
}
}

## Member Typedef Documentation

## ◆ shape_type

typedef MULTI_ITERATOR::multi_difference_type shape_type

The required shape type for the given iterator type.

## ◆ iterator

typedef MULTI_ITERATOR::iterator iterator

The iterator type for the inner loop (result of begin() and end()).

## Constructor & Destructor Documentation

## ◆ MultiArrayNavigator()

MultiArrayNavigator | ( | MULTI_ITERATOR const & | i,
|  | shape_type const & | shape,
|  | unsigned int | inner_dimension
| ) |  |

Construct navigator for multi-dimensional iterator `i`, array shape `shape` and inner loop dimension `inner_dimension`.

## Member Function Documentation

## ◆ operator++() [1/2]

void operator++ | ( |  | ) |

Advance to next starting location.

## ◆ operator++() [2/2]

void operator++ | ( | int |  | ) |

Advance to next starting location.

## ◆ hasMore()

bool hasMore | ( |  | ) | const

true if there are more elements.

## ◆ atEnd()

bool atEnd | ( |  | ) | const

true if iterator is exhausted.

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

- vigra/navigator.hxx

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.11.0