[ 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

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

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

## Member Typedef Documentation

typedef MULTI_ITERATOR::iterator iterator

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

typedef MULTI_ITERATOR::multi_difference_type shape_type

| The required shape type for the given iterator type.

## Constructor & Destructor Documentation

MultiArrayNavigator | ( | MULTI_ITERATOR const & | i,
|  | shape_type const & | shape,
|  | unsigned int | inner_dimension
| ) | `[inline]`

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

## Member Function Documentation

bool atEnd | ( |  | ) | const`[inline]`

| true if iterator is exhausted.

bool hasMore | ( |  | ) | const`[inline]`

| true if there are more elements.

void operator++ | ( | int |  | ) | `[inline]`

| Advance to next starting location.

void operator++ | ( |  | ) | `[inline]`

| Advance to next starting location.

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

- vigra/navigator.hxx

© Ullrich Köthe (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.4.0 (21 Dec 2005)