Tools.h++ Manual

21-162 104011 Tandem Computers Incorporated
21
RWSet
RWSet
|
RWHashTable
|
RWCollection
|
RWCollectable
Synopsis
typedef RWSet Set; // Smalltalk typedef.
#include <rw/rwset.h>
RWSet h;
Description Class
RWSet
represents a group of unordered elements, not accessible by an
external key, where duplicates are not allowed. It corresponds to the
Smalltalk
class
Set
.
An object stored by
RWSet
must inherit abstract base class
RWCollectable
,
with suitable definition for virtual functions
hash()
and
isEqual()
(see class
RWCollectable
). The function
hash()
is used to find objects with the same
hash value, then
isEqual()
is used to confirm the match.
An item
c
is considered to be "already in the collection" if there is a member of
the collection for which
isEqual(c)
returns
TRUE
. In this case, the message
insert(c)
will not add it, thus insuring that there are no duplicates.
The iterator for this class is
RWSetIterator
.
Public constructors
RWSet (size_t n = RWDEFAULT_CAPACITY);
Constructs an empty set with
n
hashing buckets.
RWSet (const RWSet & h);
Copy constructor. Makes a shallow copy of the collection
h
.
virtual ~RWSet();
Calls
clear()
.