#include <CNCL/DLIterator.h>
CN_DLITERATOR
CNSLIterator
None
CNDLList, CNDLObject
CNDLIterator
is an iterator to traverse a CNDLList
doubly
linked list.
Constructors:
CNDLIterator();
CNDLIterator(CNParam *param);
CNDLIterator
.
CNDLIterator(const CNDLList *new_list);
CNDLIterator(const CNDLList &new_list);
CNDLIterator
with linked list list
. The iterator
is reset to the first element in the list.
In addition to the member functions required by CNCL, CNDLIterator
provides or defines more efficiently:
void reset(const CNDLList *new_list);
void reset(const CNDLList &new_list);
void reset();
new_list
and/or sets the iterator
to the first element in the list.
CNDLObject *position()
CNDLObject *get_position()
NIL
, if none is available.
void position(CNDLObject *pos)
void set_position(CNDLObject *pos)
CNObject *last_object();
CNObject *last();
NIL
, if none is available.
CNObject *prev_object();
CNObject *prev();
CNObject *operator --();
CNObject *operator --(int);
NIL
, if none is available.
The following examples show how to use a CNDLIterator
object to
traverse a linked list:
Forward:
CNDLList list; ... CNDLIterator trav(list); CNObject *obj; while(obj = trav++) { // Do something with obj ... }
Alternate forward:
for(trav.reset(list); obj=trav.object(); trav.next()) { // ... }
Backward:
for(trav.last(); obj=trav.object(); trav--) { // ... }
Go to the first, previous, next, last section, table of contents.