NAME
OTC_SimpleList -
Linked list with inbuilt iterator.
SYNOPSIS
#include <OTC/collctn/simplist.hh>
template<class T>
class OTC_SimpleList
{
public:
OTC_SimpleList();
~OTC_SimpleList();
inline u_int population() const;
inline OTC_Boolean isEmpty() const;
inline OTC_Boolean isValid() const;
inline OTC_Boolean isStart() const;
inline OTC_Boolean isEnd() const;
inline void next() const;
inline void prev() const;
void resetFirst() const;
void resetLast() const;
void addBefore(T const& theItem);
void addAfter(T const& theItem);
void addFirst(T const& theItem);
void addLast(T const& theItem);
inline T& item();
inline T const& item() const;
inline T& first();
inline T const& first() const;
inline T& last();
inline T const& last() const;
void removeAll();
void remove();
void removeFirst();
void removeLast();
};
CLASS TYPE
Concrete
DESCRIPTION
Do not use this class, instead, use OTC_IList. The OTC_IList
class is exactly the same as this class, only the name has
changed. This class will be removed in a future version.
CONSTRUCTION
OTC_SimpleList();
DESTRUCTION
~OTC_SimpleList();
Invokes removeAll() to kill all buckets
in the list. Note that if pointers are
held in the list and they need to be
deleted, the destructor should not be
relied upon to delete them. Instead, you
should iterate manually over the list and
delete each pointer.
POPULATION
inline u_int population() const;
Returns the number of items in the
list.
inline OTC_Boolean isEmpty() const;
Returns OTCLIB_TRUE if the list is empty.
ITERATION
inline OTC_Boolean isValid() const;
Returns OTCLIB_TRUE if the iterator is
located over a live item.
inline OTC_Boolean isStart() const;
Returns OTCLIB_TRUE if the iterator is
located off the start of the list.
inline OTC_Boolean isEnd() const;
Returns OTCLIB_TRUE if the iterator is
located off the end of the list.
inline void next() const;
Moves the iterator onto the next item.
inline void prev() const;
Moves the iterator onto the previous item.
void resetFirst() const;
Moves the iterator to the first item in
the list. If the list is empty, the
iterator will be placed off the end of
the list.
void resetLast() const;
Moves the iterator to the last item in
the list. If the list is empty, the
iterator will be placed off the start of
the list.
ADDITION
void addBefore(T const& theItem);
Adds theItem before the item where the
iterator is currently located. If the
iterator is located off the end of the
list, the effect is that theItem is
appended to the list. If the iterator is
off the start of the list, the effect
is that theItem is prepended to the
list. After the operation, the iterator
will be located on the newly inserted
item.
void addAfter(T const& theItem);
Adds theItem after the item where the
iterator is currently located. If the
iterator is located off the end of the
list, the effect is that theItem is
appended to the list. If the iterator is
off the start of the list, the effect
is that theItem is prepended to the
list. After the operation, the iterator
will be located on the newly inserted
item.
void addFirst(T const& theItem);
Adds theItem at the head of the list.
The location of the iterator is unchanged.
void addLast(T const& theItem);
Adds theItem after the last item in
the list. The location of the iterator
is unchanged.
LOOKING
inline T& item();
If the iterator is located over a valid
item, a reference to the item is returned.
If there is not a valid item under the
iterator, an exception is raised.
inline T const& item() const;
If the iterator is located over a valid
item, a reference to the item is returned.
If there is not a valid item under the
iterator, an exception is raised.
inline T& first();
If the list is not empty, a reference
is returned to the item on the head of
the list. If the list is empty, an
exception is raised.
inline T const& first() const;
If the list is not empty, a reference is
returned to the item on the head of the
list. If the list is empty, an exception
is raised.
inline T& last();
If the list is not empty, a reference is
returned to the last item in the list. If
the list is empty, an exception is raised.
inline T const& last() const;
If the list is not empty, a reference is
returned to the last item in the list. If
the list is empty, an exception is raised.
REMOVING
Note that if pointers are held in the list and they need to be
deleted, you should delete the objects explicitly as the
remove() functions will not delete objects pointed at, by
pointers in the list.
void removeAll();
Kills all buckets holding items in the
list.
void remove();
If the iterator is located over a valid
item, the bucket which is holding the item
is killed. The bucket is only unlinked
from the list and destroyed when the
iterator is moved.
void removeFirst();
If the list is not empty, the first
item in the list is killed. If the
internal iterator is not located on
the first item, it will be removed
immediately.
void removeLast();
If the list is not empty, the last
item in the list is killed. If the
internal iterator is not located on
the first item, it will be removed
immediately.
SEE ALSO
OTC_Holder
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1992 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED