#include <OTC/collctn/linkcurs.hh> class OTC_LinkCursor {
public:
inline OTC_Direction direction() const;
inline void reverse();
inline void reset();
inline void next();
inline OTC_Boolean isValid() const;
protected:
virtual ~OTC_LinkCursor();
OTC_LinkCursor( OTC_LinkList* theList, OTC_Direction theDirection, OTC_Protection theProtection=OTCLIB_SAFE );
OTC_LinkCursor( OTC_LinkList* theList, OTC_Linkable* theStart, OTC_Linkable* theEnd, OTC_Direction theDirection, OTC_Protection theProtection=OTCLIB_SAFE );
OTC_LinkCursor(OTC_LinkCursor const& theIter);
inline OTC_Link* link() const;
};
OTC_LinkCursor
class encapsulates most of the operations
needed when implementing a cursor over an instance of
OTC_LinkedList
.
inline OTC_Direction direction() const;
inline void reverse();
inline void reset();
inline void next();
inline OTC_Boolean isValid() const;
OTCLIB_TRUE
if the iterator
is located over a link.
OTC_LinkCursor(
OTC_LinkList* theList,
OTC_Direction theDirection,
OTC_Protection theProtection=OTCLIB_SAFE
);
theList
should be the list which you
wish to iterate over. theDirection
should indicate the direction in which
you wish the iterator to initially
proceed. If theDirection
is
OTCLIB_FORWARD
then the direction of
traversal will be from the start of the
list to the end. If it is
OTCLIB_BACKWARD
then it will be in the
opposite direction. theProtection
determines whether reference counting is
performed on the links in the list.
Reference counting ensures the integrity of
the iterator when removals and additions
are perfomed. The values for
theProtection
are OTCLIB_SAFE
and
OTCLIB_UNSAFE
. The default argument is
OTCLIB_UNSAFE
.
OTC_LinkCursor(
OTC_LinkList* theList,
OTC_Linkable* theStart,
OTC_Linkable* theEnd,
OTC_Direction theDirection,
OTC_Protection theProtection=OTCLIB_SAFE
);
theList
should be the list which you
wish to iterate over. theStart
and
theEnd
are the anchor points within that
list which define the bounds of the
iterator. If theDirection
is
OTCLIB_FORWARD
then traversal will be
from the theStart
to theEnd
. If it is
OTCLIB_BACKWARD
then it will be in the
opposite direction. Note that this class
relies on theStart
preceeding theEnd
in the list. theProtection
determines whether reference counting is
performed on the links in the list.
Reference counting ensures the integrity of
the iterator when removals and additions
are perfomed. The values for
theProtection
are OTCLIB_SAFE
and
OTCLIB_UNSAFE
. The default argument is
OTCLIB_UNSAFE
.
OTC_LinkCursor(OTC_LinkCursor const& theIter);
theIter
is an iterator which you
wish to clone, ie., this iterator will
traverse the same list and will initially
be located at the same location and
moving in the same direction.
inline OTC_Link* link() const;
0
will be returned.