PSCF v1.1
|
Bidirectional iterator for a List. More...
#include <ListIterator.h>
Public Member Functions | |
ListIterator () | |
Default constructor. More... | |
ListIterator (List< Data > const &list) | |
Constructor for initialized iterator. More... | |
void | setCurrent (Node< Data > *nodePtr) |
Point the iterator at a Node. More... | |
bool | isEnd () const |
Has the end of the list been reached? More... | |
bool | isBack () const |
Is this the back of the List? More... | |
bool | isFront () const |
Is this the front of the List? More... | |
Operators | |
Data const & | operator* () const |
Get a const reference to the associated Data object. More... | |
Data & | operator* () |
Get the associated Data object. More... | |
Data const * | operator-> () const |
Get a pointer to const to the associated Data object. More... | |
Data * | operator-> () |
Get a pointer to the associated Data object. More... | |
ListIterator< Data > & | operator++ () |
Go to the next element in a linked list. More... | |
ListIterator< Data > & | operator-- () |
Go to the previous element in a linked list. More... | |
Bidirectional iterator for a List.
A ListIterator provides bidirectional input/output access to a linked list, similar to an STL bidirectional iterator. An * operator returns a reference to an associated Data object. The ++ and – operators change the current pointer to the next or prev element in a list.
The isEnd() method returns true if either end of the list has already been passed by a previous ++ or – operation. When isEnd() is true, the iterator is no longer usable, since it no longer points to a Node and cannot be incremented or decremented.
Definition at line 27 of file ListIterator.h.
|
inline |
Default constructor.
Creates a "dead" iterator, for which isEnd()==true. Before it can be used, such an iterator must be initialized by either the ListIterator<Data>::setCurrent() method or the List<Data>::begin() method of an associated List.
Definition at line 40 of file ListIterator.h.
|
inlineexplicit |
Constructor for initialized iterator.
Creates an iterator that points to the front of a List. Calls List<Data>::begin(*this) internally.
list | parent List |
Definition at line 52 of file ListIterator.h.
References Util::List< Data >::begin().
|
inline |
Point the iterator at a Node.
Definition at line 61 of file ListIterator.h.
Referenced by Util::List< Data >::begin().
|
inline |
Has the end of the list been reached?
Return true if the current pointer is null, indicating that the previous increment or decrement passed an end of the list.
Definition at line 72 of file ListIterator.h.
|
inline |
Is this the back of the List?
Definition at line 80 of file ListIterator.h.
|
inline |
Is this the front of the List?
Definition at line 88 of file ListIterator.h.
|
inline |
Get a const reference to the associated Data object.
Definition at line 99 of file ListIterator.h.
|
inline |
Get the associated Data object.
Definition at line 107 of file ListIterator.h.
|
inline |
Get a pointer to const to the associated Data object.
Definition at line 115 of file ListIterator.h.
|
inline |
Get a pointer to the associated Data object.
Definition at line 123 of file ListIterator.h.
|
inline |
Go to the next element in a linked list.
This method assigns the current pointer to the address of the next Node in the list, and then returns *this. If there is no next Node, the current pointer is set null, and any subsequent call to isEnd() will return true.
Definition at line 136 of file ListIterator.h.
|
inline |
Go to the previous element in a linked list.
This method assigns the current Node to the previous in the List, and returns a reference to *this.
Definition at line 150 of file ListIterator.h.