casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | List of all members
casacore::VectorIterator< T, Alloc > Class Template Reference

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

#include <VectorIter.h>

Inheritance diagram for casacore::VectorIterator< T, Alloc >:
casacore::ArrayIterator< T, Alloc > casacore::ArrayPositionIterator

Public Member Functions

 VectorIterator (Array< T, Alloc > &a, size_t axis=0)
 Iterate by vector cursors through array "a". More...
 
Vector< T, Alloc > & vector ()
 Return a Vector at the current position. More...
 
- Public Member Functions inherited from casacore::ArrayIterator< T, Alloc >
 ArrayIterator (const Array< T, Alloc > &arr, size_t byDim=1)
 Step through array "arr" over the first byDim axes (using a cursor of dimensionality "byDim"). More...
 
 ArrayIterator (const Array< T, Alloc > &arr, const IPosition &axes, bool axesAreCursor=true)
 Step through an array using the given axes. More...
 
virtual void next () override
 Move the cursor to the next position. More...
 
virtual void set (const IPosition &cursorPos) override
 Set the cursor to the given position. More...
 
virtual void reset () override
 Reset the cursor to the beginning. More...
 
Array< T, Alloc > & array ()
 Return the cursor. More...
 
virtual ArrayBasegetArray () override
 Get the array in the cursor. More...
 
- Public Member Functions inherited from casacore::ArrayPositionIterator
 ArrayPositionIterator (const IPosition &shape, const IPosition &origin, size_t byDim)
 Define the shape and origin of the volume the cursor will step through. More...
 
 ArrayPositionIterator (const IPosition &shape, size_t byDim)
 
 ArrayPositionIterator (const IPosition &shape, const IPosition &axes, bool axesAreCursor=true)
 Step through an array using the given axes. More...
 
virtual ~ArrayPositionIterator ()
 
void origin ()
 
bool atStart () const
 Returns true of the cursor is at the origin. More...
 
bool pastEnd () const
 Returns true if the cursor has moved past the end of its volume. More...
 
const IPositionpos () const
 Return the position of the cursor. More...
 
IPosition endPos () const
 Return the end position of the cursor. More...
 
size_t ndim () const
 What is the dimensionality of the volume we are iterating through? More...
 
const IPositioniterAxes () const
 Return the iteration axes. More...
 
const IPositioncursorAxes () const
 Return the cursor axes. More...
 

Private Member Functions

 VectorIterator (const VectorIterator< T, Alloc > &)=delete
 Not implemented. More...
 
VectorIterator< T, Alloc > & operator= (const VectorIterator< T, Alloc > &)=delete
 Not implemented. More...
 

Additional Inherited Members

- Protected Member Functions inherited from casacore::ArrayPositionIterator
size_t nextStep ()
 Advance cursor to its next position and tell which dimension stepped. More...
 
size_t dimIter () const
 What is the dimensionality of the "step" the cursor takes, i.e. More...
 
- Protected Attributes inherited from casacore::ArrayIterator< T, Alloc >
std::unique_ptr< Array< T,
Alloc > > 
ap_p
 The cursor. More...
 

Detailed Description

template<typename T, typename Alloc = std::allocator<T>>
class casacore::VectorIterator< T, Alloc >

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
float sum = 0.0;
size_t 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 73 of file VectorIter.h.

Constructor & Destructor Documentation

template<typename T , typename Alloc = std::allocator<T>>
casacore::VectorIterator< T, Alloc >::VectorIterator ( Array< T, Alloc > &  a,
size_t  axis = 0 
)
explicit

Iterate by vector cursors through array "a".

The vector cursor is taken for the given axis.

template<typename T , typename Alloc = std::allocator<T>>
casacore::VectorIterator< T, Alloc >::VectorIterator ( const VectorIterator< T, Alloc > &  )
privatedelete

Not implemented.

Member Function Documentation

template<typename T , typename Alloc = std::allocator<T>>
VectorIterator<T, Alloc>& casacore::VectorIterator< T, Alloc >::operator= ( const VectorIterator< T, Alloc > &  )
privatedelete

Not implemented.

template<typename T , typename Alloc = std::allocator<T>>
Vector<T, Alloc>& casacore::VectorIterator< T, Alloc >::vector ( )
inline

Return a Vector at the current position.

Definition at line 81 of file VectorIter.h.

References casacore::ArrayIterator< T, Alloc >::ap_p.


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