NAME
OTC_MList -
A list class which can be modified through an iterator(modifier).
SYNOPSIS
#include <OTC/collctn/mlist.hh>
template<class T>
class OTC_MList
{
public:
static os_typespec* get_os_typespec();
inline OTC_MList();
OTC_MList(OTC_MList<T> const& theList);
inline OTC_MList(OTC_MList<T>& theList, OTC_ShallowCopy);
OTC_MList<T>& operator=(OTC_MList<T> const& theList);
inline u_int population() const;
inline OTC_Boolean isEmpty() const;
inline void addFirst(T const& theItem);
inline void addLast(T const& theItem);
inline T& first();
inline T const& first() const;
inline T& last();
inline T const& last() const;
inline void removeAll();
inline void removeFirst();
inline void removeLast();
void apply(
OTC_Visitor<T>& theApplicator,
OTC_Direction theDirection=OTCLIB_FORWARD,
OTC_Protection theProtection=OTCLIB_SAFE
) const;
void apply(
OTC_Worker<T>& theApplicator,
OTC_Direction theDirection=OTCLIB_FORWARD,
OTC_Protection theProtection=OTCLIB_SAFE
);
};
CLASS TYPE
Concrete
DESCRIPTION
OTC_MList implements a list of objects where access to and
manipulation of items, is permitted on items occurring at the
ends of the list. Manipulation and removal of items may also
be achieved through a separate class specific iterator and
modifier.
INITIALISATION
inline OTC_MList();
OTC_MList(OTC_MList<T> const& theList);
Creates a copy of theList.
inline OTC_MList(OTC_MList<T>& theList, OTC_ShallowCopy);
Creates an alias for theList.
ASSIGNMENT
OTC_MList<T>& operator=(OTC_MList<T> const& theList);
Replaces the contents of this list with
the items contained in theList.
QUERY
inline u_int population() const;
Returns the number of items in the
list.
inline OTC_Boolean isEmpty() const;
Returns OTCLIB_TRUE if the the list
is empty.
ADDITION
inline void addFirst(T const& theItem);
Inserts theItem at the head of the list.
inline void addLast(T const& theItem);
Appends theItem to the tail of the list.
ACCESS
inline T& first();
Returns a reference to the first item in
the list. If the list is empty, an
exception is raised.
inline T const& first() const;
Returns a reference to the first item in
the list. If the list is empty, an
exception is raised.
inline T& last();
Returns a reference to the last item in
the list. If the list is empty, an
exception is raised.
inline T const& last() const;
Returns a reference to the last item in
the list. If the list is empty, an
exception is raised.
REMOVAL
inline void removeAll();
Removes all items from the list.
inline void removeFirst();
Removes the first item in the list. If
the list is empty, an exception is
raised.
inline void removeLast();
Removes the first item in the list. If
the list is empty, an exception is
raised.
APPLICATORS
void apply(
OTC_Visitor<T>& theApplicator,
OTC_Direction theDirection=OTCLIB_FORWARD,
OTC_Protection theProtection=OTCLIB_SAFE
) const;
Applies theApplicator to each of the
items in the collection. The direction
being determined by theDirection. Valid
values are OTCLIB_FORWARD and
OTCLIB_BACKWARD.
void apply(
OTC_Worker<T>& theApplicator,
OTC_Direction theDirection=OTCLIB_FORWARD,
OTC_Protection theProtection=OTCLIB_SAFE
);
Applies theApplicator to each of the
items in the collection. The direction
being determined by theDirection. Valid
values are OTCLIB_FORWARD and
OTCLIB_BACKWARD.
NOTES
The OTC_Bucket class is used internally to hold items in the
list. Thus, the OTC_BaseActions class may be used to provide
actions to be performed, when items are inserted and removed from
the list.
SEE ALSO
OTC_Bucket, OTC_BaseActions, OTC_MListIterator,
OTC_MListModifier
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED