Go to the first, previous, next, last section, table of contents.


CNSLIterator -- Iterator of Single Linked List

SYNOPSIS

#include <CNCL/SLIterator.h>

TYPE

CN_SLITERATOR

BASE CLASSES

CNObject

DERIVED CLASSES

CNDLIterator

RELATED CLASSES

CNSLList, CNSLObject

DESCRIPTION

CNSLIterator is an iterator to traverse a CNSLList single linked list.

Constructors:

CNSLIterator();
CNSLIterator(CNParam *param);
Initializes CNSLIterator.
CNSLIterator(const CNSLList *new_list);
CNSLIterator(const CNSLList &new_list);
Initializes CNSLIterator with linked list list. The iterator is reset to the first element in the list.

In addition to the member functions required by CNCL, CNSLIterator provides:

void reset(const CNSLList *new_list);
void reset(const CNSLList &new_list);
void reset();
Resets the iterator to a new list new_list and/or sets the iterator to the first element in the list.
CNObject *object()
CNObject *get_object()
Gets the referenced object from the current iterator position. It returns the object or NIL, if none is available.
CNSLObject *position()
CNSLObject *get_position()
Gets the current iterator position (node in the list). It returns a pointer to the node or NIL, if none is available.
void position(CNSLObject *pos)
void set_position(CNSLObject *pos)
Moves the iterator to the referenced node in the list.
CNObject *first_object();
CNObject *first();
Sets the iterator to the first element in the list. It returns the referenced object or NIL, if none is available.
CNObject *last_object();
CNObject *last();
Sets the iterator to the last element in the list. It returns the referenced object or NIL, if none is available.
CNObject *next_object();
CNObject *next();
CNObject *operator ++();
CNObject *operator ++(int);
Moves the iterator to the next element in the list. It returns the current referenced object (the one BEFORE moving the iterator) or NIL, if none is available.

An example which shows the use of a Iterators object to traverse a double linked list can be found at the end of the class CNDIterator.


Go to the first, previous, next, last section, table of contents.