RWSlistCollectables(3C++) RWSlistCollectables(3C++)
NameRWSlistCollectables - Rogue Wave library class
Synopsis
// Smalltalk typedef:
typedef RWSlistCollectables LinkedList ;
#include <rw/slistcol.h>
RWSlistCollectables a;
Description
Class RWSlistCollectables represents a group of ordered elements, without
keyed access. Duplicates are allowed. The ordering of elements is
determined externally, by the order of insertion and removal. An object
stored by RWSlistCollectables must inherit abstract base class
RWCollectable. The virtual function isEqual() (see class RWCollectable)
is required to find a match between a target and an item in the
collection Class RWSlistCollectables is implemented as a singly-linked
list, which allows for efficient insertion and removal, but efficient
movement in only one direction. This class corresponds to the Smalltalk
class LinkedList.
Persistence
Polymorphic
Public ConstructorsRWSlistCollectables();
Constructs an empty linked list.
RWSlistCollectables(RWCollectable* a);
Constructs a linked list with single item a.
Public Member Operators
RWBoolean
operator==(const RWSlistCollectables& s) const;
Returns TRUE if self and s have the same number of members and if for
every item in self, the corresponding item at the same index in s isEqual
Page 1
RWSlistCollectables(3C++) RWSlistCollectables(3C++)
to it.
Public Member Functions
virtual RWCollectable*
append(RWCollectable*);
Redefined from RWSequenceable. Inserts the item at the end of the
collection and returns it. Returns nil if the insertion was
unsuccessful.
virtual void
apply(RWapplyCollectable ap, void*);
Redefined from class RWCollection. This function has been redefined to
apply the user-defined function pointed to by ap to each member of the
collection, in order, from first to last.
virtual RWCollectable*&
at(size_t i);
virtual const RWCollectable*
at(size_t i) const;
Redefined from class RWSequenceable. The index i must be between 0 and
the number of items in the collection less one, or an exception of type
RWBoundsErr will be thrown. Note that for a linked list, these functions
must traverse all the links, making them not particularly efficient.
virtual RWspace
binaryStoreSize() const;
Inherited from class RWCollection.
virtual void
clear();
Redefined from class RWCollection.
virtual void
clearAndDestroy();
Inherited from class RWCollection.
virtual int
compareTo(const RWCollectable* a) const;
Page 2
RWSlistCollectables(3C++) RWSlistCollectables(3C++)
Inherited from class RWCollectable.
virtual RWBoolean
contains(const RWCollectable* target) const;
Inherited from class RWCollection.
RWBoolean
containsReference(const RWCollectable* e) const;
Returns true if the list contains an item that is identical to the item
pointed to by e (that is, that has the address e).
virtual size_t
entries() const;
Redefined from class RWCollection.
virtual RWCollectable*
find(const RWCollectable* target) const;
Redefined from class RWCollection. The first item that matches target is
returned, or nil if no item was found.
RWCollectable*
findReference(const RWCollectable* e) const;
Returns the first item that is identical to the item pointed to by e
(that is, that has the address e), or nil if none is found.
virtual RWCollectable*
first() const;
Redefined from class RWSequenceable. Returns the item at the beginning
of the list.
RWCollectable*
get();
Returns and removes the item at the beginning of the list.
virtual unsigned
hash() const;
Page 3
RWSlistCollectables(3C++) RWSlistCollectables(3C++)
Inherited from class RWCollectable.
virtual size_t
index(const RWCollectable* c) const;
Redefined from class RWSequenceable. Returns the index of the first item
that isEqual to the item pointed to by c. If there is no such item,
returns RW_NPOS.
virtual RWCollectable*
insert(RWCollectable* c);
Redefined from class RWCollection. Adds the item to the end of the
collection and returns it. Returns nil if the insertion was
unsuccessful.
void
insertAt(size_t indx, RWCollectable* e);
Redefined from class RWSequenceable. Adds a new item to the collection
at position indx. The item previously at position i is moved to i+1,
etc. The index indx must be between 0 and the number of items in the
collection, or an exception of type RWBoundsErr will be thrown.
virtual RWClassID
isA() const;
Redefined from class RWCollectable to return __RWSLISTCOLLECTABLES.
virtual RWBoolean
isEmpty() const;
Redefined from class RWCollection.
virtual RWCollectable*
last() const;
Redefined from class RWSequenceable. Returns the value at the end of the
collection.
virtual size_t
occurrencesOf(const RWCollectable* target) const;
Redefined from class RWCollection. Returns the number of items that
isEqual to the item pointed to by target.
Page 4
RWSlistCollectables(3C++) RWSlistCollectables(3C++)
size_t
occurrencesOfReference(const RWCollectable* e) const;
Returns the number of items that are identical to the item pointed to by
e (that is, that have the address e).
virtual RWCollectable*
prepend(RWCollectable*);
Redefined from class RWSequenceable. Adds the item to the beginning of
the collection and returns it. Returns nil if the insertion was
unsuccessful.
virtual RWCollectable*
remove(const RWCollectable* target);
Redefined from class RWCollection. Removes and returns the first item
that isEqual to the item pointed to by target. Returns nil if there is
no such item.
virtual void
removeAndDestroy(const RWCollectable* target);
Inherited from class RWCollection.
RWCollectable*
removeReference(const RWCollectable* e);
Removes and returns the first item that is identical to the item pointed
to by e (that is, that has the address e). Returns nil if there is no
such item.
virtual void
restoreGuts(RWvistream&);
virtual void
restoreGuts(RWFile&);
virtual void
saveGuts(RWvostream&) const;
virtual void
saveGuts(RWFile&) const;
Inherited from class RWCollection.
RWStringID
stringID();
Page 5
RWSlistCollectables(3C++) RWSlistCollectables(3C++)
(acts virtual) Inherited from class RWCollectable.
Page 6