#include <OTC/collctn/icursor.hh> template<class T, class L> class OTC_ItemCursor : public OTC_LinkCursor, public OTC_Cursor<T> {
public:
static os_typespec* get_os_typespec();
~OTC_ItemCursor();
OTC_ItemCursor( OTC_LinkList* aList, OTC_Direction theDirection=OTCLIB_FORWARD, OTC_Protection theProtection=OTCLIB_SAFE );
OTC_ItemCursor( OTC_LinkList* aList, OTC_Linkable* theStart, OTC_Linkable* theEnd, OTC_Direction theDirection=OTCLIB_FORWARD, OTC_Protection theProtection=OTCLIB_SAFE );
OTC_ItemCursor(OTC_ItemCursor<T,L> const& theIter);
void reset();
void next();
T& item();
OTC_Boolean isValid() const;
OTC_Cursor<T>* clone();
};
OTC_Cursor
, which iterates over the items
in an instance of OTC_LinkList
. The type of the class derived
from OTC_Link
and which are held by the link list must be
supplied as the second template argument. The class derived
from OTC_Link
must provide a function called item()
. This
function must return a reference to a modifiable object of type
T
.
OTC_ItemCursor(
OTC_LinkList* aList,
OTC_Direction theDirection=OTCLIB_FORWARD,
OTC_Protection theProtection=OTCLIB_SAFE
);
aList
is the list being iterated over.
theDirection
indicates which way
traversal is to occur. If theDirection
is OTCLIB_FORWARD
then traversal will be
from the start aList
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_ItemCursor(
OTC_LinkList* aList,
OTC_Linkable* theStart,
OTC_Linkable* theEnd,
OTC_Direction theDirection=OTCLIB_FORWARD,
OTC_Protection theProtection=OTCLIB_SAFE
);
aList
is the list being iterated 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_ItemCursor(OTC_ItemCursor<T,L> const& theIter);
theIter
.
void reset();
void next();
T& item();
OTC_Boolean isValid() const;
OTCLIB_TRUE
while there is a
link under the current location of the
iterator amd not an anchor point. In other
words if the iterator is located over a
link which has been killed then
OTCLIB_TRUE
will still be returned.
OTC_Cursor<T>* clone();