PSCF v1.1
Public Member Functions | List of all members
Util::ArrayIterator< Data > Class Template Reference

Forward iterator for an Array or a C array. More...

#include <ArrayIterator.h>

Public Member Functions

 ArrayIterator ()
 Default constructor. More...
 
void setCurrent (Data *ptr)
 Set the current pointer value. More...
 
void setEnd (Data *ptr)
 Set the value of the end pointer. More...
 
bool isEnd () const
 Has the end of the array been reached? More...
 
bool notEnd () const
 Is the current pointer not at the end of the array? More...
 
Data * get () const
 Return a pointer to the current data. More...
 

Operators

Data & operator* () const
 Return a reference to the current Data. More...
 
Data * operator-> () const
 Return a pointer to the current Data object. More...
 
ArrayIterator< Data > & operator++ ()
 Increment the current pointer. More...
 

Detailed Description

template<typename Data>
class Util::ArrayIterator< Data >

Forward iterator for an Array or a C array.

An ArrayIterator is an abstraction of a pointer, similar to an STL forward iterator. The * operator returns a reference to an associated Data object, the -> operator returns a pointer to that object. The ++ operator increments the current pointer by one array element.

Unlike an STL forward iterator, an ArrayIterator contains the address of the end of the array. The isEnd() method can be used to test for termination of a for or while loop. When isEnd() is true, the current pointer is one past the end of the array, and thus the iterator has no current value, and cannot be incremented further.

An ArrayIterator behave like a pointer to non-const data, and provides read-write access to the objects to which it points. A ConstArrayIterator behaves like a pointer to const, and provides read-only access

Definition at line 36 of file ArrayIterator.h.

Constructor & Destructor Documentation

◆ ArrayIterator()

template<typename Data >
Util::ArrayIterator< Data >::ArrayIterator ( )
inline

Default constructor.

Constructs an uninitialized iterator.

Definition at line 46 of file ArrayIterator.h.

Member Function Documentation

◆ setCurrent()

template<typename Data >
void Util::ArrayIterator< Data >::setCurrent ( Data *  ptr)
inline

Set the current pointer value.

Parameters
ptrPointer to current element of the array

Definition at line 56 of file ArrayIterator.h.

Referenced by Util::Array< Data >::begin(), Util::DSArray< Data >::begin(), Util::FArray< Data, Capacity >::begin(), Util::FSArray< Data, Capacity >::begin(), and Util::GArray< Data >::begin().

◆ setEnd()

template<typename Data >
void Util::ArrayIterator< Data >::setEnd ( Data *  ptr)
inline

Set the value of the end pointer.

Parameters
ptrPointer to one element past last element of the array

Definition at line 64 of file ArrayIterator.h.

Referenced by Util::Array< Data >::begin(), Util::DSArray< Data >::begin(), Util::FArray< Data, Capacity >::begin(), Util::FSArray< Data, Capacity >::begin(), and Util::GArray< Data >::begin().

◆ isEnd()

template<typename Data >
bool Util::ArrayIterator< Data >::isEnd ( ) const
inline

Has the end of the array been reached?

Returns
true if at end, false otherwise.

Definition at line 72 of file ArrayIterator.h.

◆ notEnd()

template<typename Data >
bool Util::ArrayIterator< Data >::notEnd ( ) const
inline

Is the current pointer not at the end of the array?

Returns
true if not at end, false otherwise

Definition at line 80 of file ArrayIterator.h.

◆ get()

template<typename Data >
Data * Util::ArrayIterator< Data >::get ( ) const
inline

Return a pointer to the current data.

Returns
true if at end, false otherwise

Definition at line 88 of file ArrayIterator.h.

◆ operator*()

template<typename Data >
Data & Util::ArrayIterator< Data >::operator* ( ) const
inline

Return a reference to the current Data.

Returns
reference to associated Data object

Definition at line 99 of file ArrayIterator.h.

◆ operator->()

template<typename Data >
Data * Util::ArrayIterator< Data >::operator-> ( ) const
inline

Return a pointer to the current Data object.

Returns
const pointer to the Data object

Definition at line 107 of file ArrayIterator.h.

◆ operator++()

template<typename Data >
ArrayIterator< Data > & Util::ArrayIterator< Data >::operator++ ( )
inline

Increment the current pointer.

Returns
this ArrayIterator, after modification

Definition at line 115 of file ArrayIterator.h.


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