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

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

#include <ConstArrayIterator.h>

Public Member Functions

 ConstArrayIterator ()
 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 this not the end of the array? More...
 
const Data * get () const
 Return a pointer to the current data. More...
 

Operators

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

Detailed Description

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

Forward const iterator for an Array or a C array.

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

Unlike an STL const forward iterator, an ConstArrayIterator 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.

A ConstArrayIterator behave like a pointer to constant data, and provides read-only access to the object to which it points. Use an ArrayIterator if you need read-write access.

Definition at line 37 of file ConstArrayIterator.h.

Constructor & Destructor Documentation

◆ ConstArrayIterator()

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

Default constructor.


Constructs an uninitialized iterator.

Definition at line 47 of file ConstArrayIterator.h.

Member Function Documentation

◆ setCurrent()

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

Set the current pointer value.

Parameters
ptrPointer to current element of the array.

Definition at line 57 of file ConstArrayIterator.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::ConstArrayIterator< Data >::setEnd ( Data *  ptr)
inline

Set the value of the end pointer.

Parameters
ptrPointer to one element past end of array.

Definition at line 65 of file ConstArrayIterator.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::ConstArrayIterator< Data >::isEnd ( ) const
inline

Has the end of the array been reached?

Returns
true if at end, false otherwise.

Definition at line 73 of file ConstArrayIterator.h.

◆ notEnd()

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

Is this not the end of the array?

Returns
true if not at end, false otherwise.

Definition at line 81 of file ConstArrayIterator.h.

◆ get()

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

Return a pointer to the current data.

Returns
true if at end, false otherwise.

Definition at line 89 of file ConstArrayIterator.h.

◆ operator*()

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

Get a reference to the current Data.

Returns
reference to associated Data object

Definition at line 100 of file ConstArrayIterator.h.

◆ operator->()

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

Provide a pointer to the current Data object.

Returns
const pointer to the Data object

Definition at line 108 of file ConstArrayIterator.h.

◆ operator++()

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

Increment the current pointer.

Returns
this ConstArrayIterator, after modification.

Definition at line 116 of file ConstArrayIterator.h.


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