NAME
OTC_MListIterator -
Iterator over an OTC_MList. No modification allowed.
SYNOPSIS
#include <OTC/collctn/mlstiter.hh>
template<class T>
class OTC_MListIterator
{
public:
inline OTC_MListIterator(
OTC_MList<T> const& theList,
OTC_Protection theProtection=OTCLIB_SAFE
);
inline void prev();
inline void next();
inline void resetFirst();
inline void resetLast();
inline T const& item() const;
inline OTC_Boolean isValid() const;
protected:
inline T& _item() const;
inline void _remove();
inline void _addBefore(T const& theItem);
inline void _addAfter(T const& theItem);
};
CLASS TYPE
Concrete
DESCRIPTION
This class is an iterator specifically for the OTC_MList class.
Modification of items through the iterator is not permitted.
If modification of items held by an instance of OTC_MList,
through an iterator is required, the OTC_MListModifier class
should be used.
This iterator can be moved both forward and backwards. The
life of the iterator, cannot extend beyond the life of the
list being iterated over.
INITIALISATION
inline OTC_MListIterator(
OTC_MList<T> const& theList,
OTC_Protection theProtection=OTCLIB_SAFE
);
Initialises the iterator. The iterator
will be located over the first item in
theList, or if the list is empty at the
start of the list. The argument
theProtection determines if reference
counting will actually be performed on
links in the list. The default of
OTCLIB_SAFE will result in reference
counting being performed. A value of
OTCLIB_UNSAFE will turn off reference
counting. In this later case, the list
should not be modified while the iterator
exists as the state of the iterator will
be corrupted.
MOVEMENT
inline void prev();
Moves the iterator to the previous item.
inline void next();
Moves the iterator to the next item.
inline void resetFirst();
Resets the iterator to the first item,
or if the list is empty, at the start
of the list.
inline void resetLast();
Resets the iterator to the last item,
or if the list is empty, at the end
of the list.
RETRIEVAL
inline T const& item() const;
Returns the item under the current
location of the iterator. Raises an
exception if there is no item under the
iterator.
inline OTC_Boolean isValid() const;
Returns OTCLIB_TRUE while there is a
valid item under the current location
of the iterator.
SEE ALSO
OTC_MListModifier
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED