Tools.h++ Manual

21-160 104011 Tandem Computers Incorporated
21
RWSequenceable
RWSequenceable
|
RWCollection
|
RWCollectable
Synopsis
#include <rw/seqcltn.h>
typedef RWSequenceable SequenceableCollection; // Smalltalk
typedef
Description Class
RWSequenceable
is an abstract base class for collections that can be
accessed via an index. It inherits class
RWCollection
as a public base class
and adds a few extra virtual functions. This documentation only describes
these extra functions.
Public member functions
RWCollectable* append(RWCollectable*) = 0;
Adds the item to the end of the collection and returns it. Returns nil if the
insertion was unsuccessful.
virtual RWCollectable*& at(size_t i);
virtual const RWCollectable* at(size_t i) const;
Allows access to the
i
'th element of the collection. The first variant can be
used as an lvalue, the second cannot. The index i must be between zero and
the number of items in the collection less one, or an exception of type
RWBoundsErr
will be thrown.
virtual RWCollectable* first() const = 0;
Returns the first item in the collection.
virtual size_t index(const RWCollectable* c)
const = 0;
Returns the index number of the first item that "matches" the item pointed to
by
c
. If there is no such item, returns
RW_NPOS
. For most collections, an item
"matches" the target if either
isEqual()
or
compareTo()
find equivalence,
whichever is appropriate for the actual collection type.