ArrayIter Class Template Reference

Inheritance diagram for ArrayIter:

PlugInBase


Public Methods

 ArrayIter (oa::oaInt4 initialCap=0)
virtual ~ArrayIter ()
virtual bool next (typename I::Type &objOut)
virtual void reset ()
void add (const T &elem)

Detailed Description

template<class I, class T>
class ArrayIter< I, T >

This is a simple array based implementation of the IIter class. It is templated for two parameters: the actual interface to use as the iteration interface (this is assumed to be an expansion of the IIter templated interface) and the implementation type to use to store the elements of the array (which must be polymorphic with the iteration type of "I"). Note that IIter has an internal typedef, "Type", by which ArrayIter determines the iteration type of the IIter interface. The second parameter is provided to allow for a different storage type for the array elements than the raw iteration type. For example, if the IIter is an iterator of interface pointers, one often uses an array of SPtr's to store the elements in the array, aiding in the management of the pointer reference counts.


Constructor & Destructor Documentation

template<class I, class T>
ArrayIter< I, T >::ArrayIter oa::oaInt4    initialCap = 0
 

This is the constructor for the ArrayIter class. It preallocates the internal array and sets the iteration location such that the first "next" call will return the first element.

Parameters:
initialCap If the actual number or the approximate magnitude of elements is known, the client can use this parameter to set the initial size of the buffer.

template<class I, class T>
ArrayIter< I, T >::~ArrayIter   [virtual]
 

This is the destructor for the ArrayIter class. It frees the internal buffer of elements.


Member Function Documentation

template<class I, class T>
void ArrayIter< I, T >::add const T &    elem
 

This function is used to add an element of type T to the end of this array.

Parameters:
elem A reference to an object of type T to add to the array. This operation is accomplished via an assignment. All appropriate operators will be invoked as a result.

template<class I, class T>
bool ArrayIter< I, T >::next typename I::Type &    objOut [virtual]
 

This is the implementation of the "IIter<I>::next()" function. It increments the location stored in "current" and returns the element at that new location via the "objOut" parameter.

Parameters:
objOut This parameter will be set to the next element in the array. This is done via an assignment of an element of type T to the output parameter of type I::Type. All appropriate operators will be invoked as a result.

template<class I, class T>
void ArrayIter< I, T >::reset   [virtual]
 

This function resets the internal state such that the next time "next()" is called, the first element of the array will be returned.


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

Return to top of page