Imagine++
Public Member Functions | Protected Attributes | List of all members
Imagine::CoordsIterator< dim > Class Template Reference

Iterator on Coordinates. More...

#include "Imagine/Common.h"

Inheritance diagram for Imagine::CoordsIterator< dim >:

Public Member Functions

 CoordsIterator ()
 Empty constructor. More...
 
 CoordsIterator (const Coords< dim > &a, const Coords< dim > &b)
 Constructor. More...
 
bool operator!= (const CoordsIterator &it) const
 Inequality test. More...
 
Coords< dim > operator* () const
 Dereference. More...
 
CoordsIteratoroperator++ ()
 Pre-increment. More...
 
CoordsIterator operator++ (int)
 Post-increment. More...
 
const Coords< dim > * operator-> () const
 Member selection. More...
 
CoordsIteratoroperator= (const CoordsIterator &it)
 Assignment. More...
 
bool operator== (const CoordsIterator &it) const
 Equality test. More...
 

Protected Attributes

Coords< dim > _a
 begin
 
Coords< dim > _b
 end
 
Coords< dim > _pos
 Current position.
 
bool _stop
 end reached?
 

Detailed Description

template<int dim>
class Imagine::CoordsIterator< dim >

Iterator on Coords. Iterates over rectangular region. Used to iterate over a MultiArray while being aware of coordinates.

Parameters
dimdimension
Examples:
Common/test/test.cpp, and Images/test/test.cpp.

Constructor & Destructor Documentation

◆ CoordsIterator() [1/2]

template<int dim>
Imagine::CoordsIterator< dim >::CoordsIterator ( )
inline

Constructs a stopped iterator, useful to check end of iteration with operator!=.

CoordsIterator<2> it1; // uninitialized iterator

◆ CoordsIterator() [2/2]

template<int dim>
Imagine::CoordsIterator< dim >::CoordsIterator ( const Coords< dim > &  a,
const Coords< dim > &  b 
)
inline

Constructs an iterator over a rectangular region from a to b

Parameters
a,blimits of rectangular region
CoordsIterator<2> it2(Coords<2>(1,1),Coords<2>(5,3)); // iterator for 1<=x<=5, 1<=y<=3

Member Function Documentation

◆ operator!=()

template<int dim>
bool Imagine::CoordsIterator< dim >::operator!= ( const CoordsIterator< dim > &  it) const
inline

Inequality test

Parameters
ititerator for comparision
Returns
true if operator==() is false
if (it1!=it2) cout << "it1 is different from it2" << endl; // !=

◆ operator*()

template<int dim>
Coords<dim> Imagine::CoordsIterator< dim >::operator* ( ) const
inline

Dereference: coordinate position

Returns
position
for (CoordsIterator<2> it(Coords<2>(0,0),Coords<2>(1,2)); it != CoordsIterator<2>() ; ++ it) // pre ++
cout << *it << endl; // dereference

◆ operator++() [1/2]

template<int dim>
CoordsIterator& Imagine::CoordsIterator< dim >::operator++ ( )
inline

Pre-increment: advance to next position. Becomes stopped if end is reached

Returns
self reference
for (CoordsIterator<2> it(Coords<2>(0,0),Coords<2>(1,2)); it != CoordsIterator<2>() ; ++ it) // pre ++
cout << *it << endl; // dereference

◆ operator++() [2/2]

template<int dim>
CoordsIterator Imagine::CoordsIterator< dim >::operator++ ( int  )
inline

Post-increment: advance to next position. Becomes stopped if end is reached

Returns
value before increment
for (CoordsIterator<2> it(Coords<2>(0,0),Coords<2>(1,2)); it != CoordsIterator<2>() ; ) // post ++ and member selection
cout << it++->x() << endl; // ...

◆ operator->()

template<int dim>
const Coords<dim>* Imagine::CoordsIterator< dim >::operator-> ( ) const
inline

Member selection: pointer to coordinate position

Returns
pointer to position
for (CoordsIterator<2> it(Coords<2>(0,0),Coords<2>(1,2)); it != CoordsIterator<2>() ; ) // post ++ and member selection
cout << it++->x() << endl; // ...

◆ operator=()

template<int dim>
CoordsIterator& Imagine::CoordsIterator< dim >::operator= ( const CoordsIterator< dim > &  it)
inline

Assigns from another CoordsIterator

Parameters
itsource iterator
Returns
self reference
it1=it2; // iterator assignment

◆ operator==()

template<int dim>
bool Imagine::CoordsIterator< dim >::operator== ( const CoordsIterator< dim > &  it) const
inline

Equality test

Parameters
ititerator for comparision
Returns
true if
  • both are stopped
  • or both are non stopped and at same position
if (it1==it2) cout << "it1 equals it2" << endl; // ==


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