NAME
OTC_LinkList -
A doubly linked list.
SYNOPSIS
#include <OTC/collctn/linklist.hh>
class OTC_LinkList : public OTC_Resource
{
public:
static os_typespec* get_os_typespec();
OTC_LinkList();
~OTC_LinkList();
void removeAll();
u_int population() const;
OTC_Boolean isEmpty() const;
inline OTC_LinkIterator items(
OTC_Protection theProtection=OTCLIB_SAFE
) const;
OTC_Link* first() const;
OTC_Link* last() const;
inline void addFirst(OTC_Link* theLink);
inline void addLast(OTC_Link* theLink);
};
CLASS TYPE
Concrete
DESCRIPTION
OTC_LinkList provides the anchor points on which to hang a list
of objects derived from the OTC_Link class. The class gives easy
access to the start and end of the list, and the ability to insert
objects at the start and end.
If it is necessary to insert objects into the middle of the list,
you will need to use the iterator to get to a point, adjacent
to where the insertion is required, and use either of the
addBefore() and addAfter() operations provided by the
OTC_Link object.
DESTRUCTION
~OTC_LinkList();
Invokes removeAll() to kill all the
links in the list.
void removeAll();
Kills all links in the list.
QUERY
u_int population() const;
Returns the number of live links in the
list. This is calculated by iterating over
the contents of the list.
OTC_Boolean isEmpty() const;
Returns OTCLIB_TRUE if the list is empty.
ITERATION
inline OTC_LinkIterator items(
OTC_Protection theProtection=OTCLIB_SAFE
) const;
Returns an iterator over items 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.
ACCESS
OTC_Link* first() const;
Returns the link at the head of the list,
or 0 if the list is empty.
OTC_Link* last() const;
Returns the last link in the list, or
0 if the list is empty.
INSERTION
inline void addFirst(OTC_Link* theLink);
Add theLink at the start of the list.
inline void addLast(OTC_Link* theLink);
Add theLink at the end of the list.
NOTE
Any instances of objects derived from OTC_Link placed into
the list, must be created on the free store. If objects created
on the stack, at global scope, or as members of another object are
added to the list, the result is undefined. In this situation,
the destructor of the object added to the list will ultimately
have its destructor invoked twice.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1992 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED