NAME
OTC_LinkCursor -
Base class for cursors operating over a linked list.
SYNOPSIS
#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;
};
CLASS TYPE
Abstract
DESCRIPTION
The OTC_LinkCursor class encapsulates most of the operations
needed when implementing a cursor over an instance of
OTC_LinkedList.
ITERATION
inline OTC_Direction direction() const;
Returns the direction in which the
iterator is currently moving.
inline void reverse();
Reverses the direction in which the
iterator will move on the list.
inline void reset();
Resets the iterator back to the start
of the list. Note that if the iterator
is actually moving in the reverse
direction over the list the iterator
will be reset to the end of the list.
inline void next();
Moves the iterator onto the next
live link in the list.
inline OTC_Boolean isValid() const;
Returns OTCLIB_TRUE if the iterator
is located over a link.
INITIALISATION
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.
ACCESS TO LINK
inline OTC_Link* link() const;
Returns a pointer to the link which
the iterator is currently located over.
If the iterator is not located over
a link but an anchor point then 0
will be returned.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1993 TELSTRA CORPORATION LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED