PSCF v1.1
|
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... | |
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.
|
inline |
Default constructor.
Constructs an uninitialized iterator.
Definition at line 46 of file ArrayIterator.h.
|
inline |
Set the current pointer value.
ptr | Pointer 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().
|
inline |
Set the value of the end pointer.
ptr | Pointer 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().
|
inline |
Has the end of the array been reached?
Definition at line 72 of file ArrayIterator.h.
|
inline |
Is the current pointer not at the end of the array?
Definition at line 80 of file ArrayIterator.h.
|
inline |
Return a pointer to the current data.
Definition at line 88 of file ArrayIterator.h.
|
inline |
Return a reference to the current Data.
Definition at line 99 of file ArrayIterator.h.
|
inline |
Return a pointer to the current Data object.
Definition at line 107 of file ArrayIterator.h.
|
inline |
Increment the current pointer.
Definition at line 115 of file ArrayIterator.h.