NAME
OTC_DequeI -
Core for implementing deque and list structures without an index.
SYNOPSIS
#include <OTC/collctn/dequei.hh>
class OTC_DequeI
{
public:
~OTC_DequeI();
OTC_DequeI();
OTC_DequeI(OTC_DequeI const& theDeque);
inline OTC_LinkList* list() const;
inline u_int population() const;
inline OTC_Boolean isEmpty() const;
void remove(OTC_Link* theLink);
inline void removeAll();
void removeFirst();
void removeLast();
OTC_Link* first() const;
OTC_Link* last() const;
void addFirst(OTC_Link* theLink);
void addLast(OTC_Link* theLink);
void addBeforeLink(OTC_Link* theNewLink, OTC_Link* theOldLink);
void addAfterLink(OTC_Link* theNewLink, OTC_Link* theOldLink);
};
CLASS TYPE
Concrete
DESCRIPTION
The OTC_DequeI class factors out details necessary for
implementing deque and list structures which do not require
indexes. Factoring these details into this class means
that they do not have to be part of the template interface
which would be wrapped around this class. This class still
provides access to the underlying list and also to the links
in the list so that iteration mechanisms can be provided. You
should however, always use the member functions of this class when
wishing to manipulate the list. In other words you should not add
or remove links directly to or from the list as that will
invalidate the cached population maintained by this class.
INITIALISATION
OTC_DequeI();
OTC_DequeI(OTC_DequeI const& theDeque);
Creates a deque which is an alias for
theDeque. Ie., each shares and access
the same implementation.
QUERY
inline OTC_LinkList* list() const;
Returns the underlying list.
inline u_int population() const;
Returns the number of live links in the
deque.
inline OTC_Boolean isEmpty() const;
Returns OTCLIB_TRUE if there are no
live links in the deque.
REMOVAL
void remove(OTC_Link* theLink);
Removes theLink from the deque. If
theLink is not in this deque, the result
is undefined. Using this function to
delete a link not in this deque, will at
the minimum invalidate the population
for this deque.
inline void removeAll();
Removes all links from the deque.
void removeFirst();
Removes the first link in the deque. If
the deque is empty, an exception is
raised.
void removeLast();
Removes the last link in the deque. If
the deque is empty, an exception is
raised.
ACCESS
OTC_Link* first() const;
Returns the first link in the deque.
Raises an exception if the deque is empty.
OTC_Link* last() const;
Returns the last link in the deque. Raises
an exception if the deque is empty.
ADDITION
void addFirst(OTC_Link* theLink);
Adds theLink at the start of the
the deque.
void addLast(OTC_Link* theLink);
Adds theLink at the end of the
the deque.
void addBeforeLink(OTC_Link* theNewLink, OTC_Link* theOldLink);
Adds theNewLink before theOldLink
in this list. If theOldLink is not
in this list, the result is undefined.
If theOldLink is the start anchor,
theNewLink will be added as the
first link in the list. If theNewLink
is already in a list, the result
is undefined.
void addAfterLink(OTC_Link* theNewLink, OTC_Link* theOldLink);
Adds theNewLink after theOldLink
in this list. If theOldLink is not
in this list, the result is undefined.
If theOldLink is the end anchor,
theNewLink will be added as the
last link in the list. If theNewLink
is already in a list, the result
is undefined.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED