casa::VectorIterator< T > Class Template Reference
[Arrays]

#include <VectorIter.h>

Inheritance diagram for casa::VectorIterator< T >:

Inheritance graph
[legend]
Collaboration diagram for casa::VectorIterator< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class casa::VectorIterator< T >

Iterate an Vector cursor through another Array.

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

VectorIterator steps a Vector (the "cursor") through an array for the given axis. The cursor "refers" to storage in the array, so that changing the values in the cursor changes values in the original array.

This class is derived from ArrayIterator; basically it only adds the vector() member function which allows you to access the cursor as a Vector.

Tip: The origin of the cursor, i.e. the subarray that moves through the larger array, is always zero.

In this example we sum all the elements of an array; of course we already have the "sum" function in ArrayMath.h that we should use instead.

    Array<Float> af;
    // set af
    VectorIterator vi(af);
    Float sum = 0.0;
    uInt n = vi.vector().nelements();
    while (! vi.pastEnd()) {
        for (Int i=0; i < n; i++) {   // N.B.; cursor always 0 based.
            sum += vi.vector()(i);
        }
        vi.next();
    }

Definition at line 74 of file VectorIter.h.

Public Member Functions

 VectorIterator (Array< T > &a, uInt axis=0)
 Iterate by vector cursors through array "a".
Vector< T > & vector ()
 Return a Vector at the current position.

Private Member Functions

 VectorIterator (const VectorIterator< T > &)
 Not implemented.
VectorIterator< T > & operator= (const VectorIterator< T > &)
 Not implemented.


Constructor & Destructor Documentation

template<class T>
casa::VectorIterator< T >::VectorIterator ( Array< T > &  a,
uInt  axis = 0 
) [explicit]

Iterate by vector cursors through array "a".

The vector cursor is taken for the given axis.

template<class T>
casa::VectorIterator< T >::VectorIterator ( const VectorIterator< T > &   )  [private]

Not implemented.


Member Function Documentation

template<class T>
Vector<T>& casa::VectorIterator< T >::vector (  )  [inline]

Return a Vector at the current position.

Definition at line 82 of file VectorIter.h.

template<class T>
VectorIterator<T>& casa::VectorIterator< T >::operator= ( const VectorIterator< T > &   )  [private]

Not implemented.


The documentation for this class was generated from the following file:
Generated on Mon Sep 1 22:43:48 2008 for NRAOCASA by  doxygen 1.5.1