casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
casa::ArrayIterator< T > Class Template Reference

Iterate an Array cursor through another Array. More...

#include <ArrayIter.h>

Inheritance diagram for casa::ArrayIterator< T >:
casa::ArrayPositionIterator casa::MatrixIterator< T > casa::VectorIterator< T >

List of all members.

Public Member Functions

 ArrayIterator (Array< T > &arr, uInt byDim=1)
 Step through array "arr" over the first byDim axes (using a cursor of dimensionality "byDim").
 ArrayIterator (Array< T > &arr, const IPosition &axes, Bool axesAreCursor=True)
 Step through an array using the given axes.
virtual ~ArrayIterator ()
virtual void next ()
 Move the cursor to the next position.
virtual void set (const IPosition &cursorPos)
 Set the cursor to the given position.
virtual void reset ()
 Reset the cursor to the beginning.
Array< T > & array ()
 Return the cursor.
virtual ArrayBasegetArray ()
 Get the array in the cursor.

Protected Attributes

Array< T > * ap_p
 
      

Private Member Functions

void init (Array< T > &)
 helper function to centralize construction work
void apSetPointer (Int stepDim)
 helper function to set the pointer to the new data position in ap after a step in the given dimension.
 ArrayIterator (const ArrayIterator< T > &)
ArrayIterator< T > & operator= (const ArrayIterator< T > &)

Private Attributes

Array< T > * pOriginalArray_p
Bool readOnly_p
IPosition offset_p
T * dataPtr_p

Detailed Description

template<class T>
class casa::ArrayIterator< T >

Iterate an Array cursor through another Array.

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
ArrayIterator steps an array section (the "cursor") through an array.
The cursor "refers" to storage in the array, so that changing the
values in the cursor changes values in the original array. Like with
ArrayPositionIterator, the cursor presently only moves through the array from
bottom to top in the obvious way; however one may of course iterate
through a slice ("array section"). This class is derived from
ArrayPositionIterator since it also has a position (the blc of the cursor)
which moves through the array volume.

<br><strong>Tip:</strong><em>  The origin of the cursor, i;e; the subarray that moves
  through the larger array, is always zero;
</em><br>
    Array<Float> to, from;
    //... set to and from, check that they are conformant
    ArrayIterator toiter(to,1);
    ArrayIterator fromiter(from,1);
    while (! toiter.pastEnd() ) {
        toiter.array() = fromiter.array();  // copy vector by vector
        toiter.next(); fromiter.next();
    }

Definition at line 72 of file ArrayIter.h.


Constructor & Destructor Documentation

template<class T>
casa::ArrayIterator< T >::ArrayIterator ( Array< T > &  arr,
uInt  byDim = 1 
) [explicit]

Step through array "arr" over the first byDim axes (using a cursor of dimensionality "byDim").

template<class T>
casa::ArrayIterator< T >::ArrayIterator ( Array< T > &  arr,
const IPosition axes,
Bool  axesAreCursor = True 
)

Step through an array using the given axes.

The axes can be given in two ways:

  1. axesAreCursor=True means that the axes form the cursor axes. The remaining axes will form the iteration axes. This is the default.
  2. axesAreCursor=False means the opposite. In this case the iteration axes can be given in any order.

E.g. when using iteration axes 2,0 for an array with shape [5,3,7], each iteration step returns a cursor (containing the data of axis 1). During the iteration axis 2 will vary most rapidly (as it was given first).

template<class T>
virtual casa::ArrayIterator< T >::~ArrayIterator ( ) [virtual]
template<class T>
casa::ArrayIterator< T >::ArrayIterator ( const ArrayIterator< T > &  ) [private]

Member Function Documentation

template<class T>
void casa::ArrayIterator< T >::apSetPointer ( Int  stepDim) [private]

helper function to set the pointer to the new data position in ap after a step in the given dimension.

-1 resets it to the beginning.

template<class T>
Array<T>& casa::ArrayIterator< T >::array ( ) [inline]

Return the cursor.

(Perhaps we should have a fn() that returns a reference to the original array as well?)

Definition at line 118 of file ArrayIter.h.

References casa::ArrayIterator< T >::ap_p.

template<class T>
virtual ArrayBase& casa::ArrayIterator< T >::getArray ( ) [virtual]

Get the array in the cursor.

This is only implemented in the derived ArrayIterator class. By default it throws an exception.

Reimplemented from casa::ArrayPositionIterator.

template<class T>
void casa::ArrayIterator< T >::init ( Array< T > &  ) [private]

helper function to centralize construction work

template<class T>
virtual void casa::ArrayIterator< T >::next ( ) [virtual]

Move the cursor to the next position.

Reimplemented from casa::ArrayPositionIterator.

template<class T>
ArrayIterator<T>& casa::ArrayIterator< T >::operator= ( const ArrayIterator< T > &  ) [private]
template<class T>
virtual void casa::ArrayIterator< T >::reset ( ) [virtual]

Reset the cursor to the beginning.

Reimplemented from casa::ArrayPositionIterator.

template<class T>
virtual void casa::ArrayIterator< T >::set ( const IPosition cursorPos) [virtual]

Set the cursor to the given position.

The position can only contain the iteration axes or it can be the full position.
In the first case the position must to be given in the order of the iteration axes as given in the constructor. In the latter case the position must be given in natural order (as given by function pos and only the cursor axes are taken into account.

Reimplemented from casa::ArrayPositionIterator.


Member Data Documentation

template<class T>
Array<T>* casa::ArrayIterator< T >::ap_p [protected]

      

A pointer to the cursor.

Definition at line 125 of file ArrayIter.h.

Referenced by casa::ArrayIterator< T >::array(), casa::MatrixIterator< T >::matrix(), and casa::VectorIterator< T >::vector().

template<class T>
T* casa::ArrayIterator< T >::dataPtr_p [private]

Definition at line 137 of file ArrayIter.h.

template<class T>
IPosition casa::ArrayIterator< T >::offset_p [private]

Definition at line 136 of file ArrayIter.h.

template<class T>
Array<T>* casa::ArrayIterator< T >::pOriginalArray_p [private]

Definition at line 134 of file ArrayIter.h.

template<class T>
Bool casa::ArrayIterator< T >::readOnly_p [private]

Definition at line 135 of file ArrayIter.h.


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