RWSet(3C++) RWSet(3C++)
NameRWSet - Rogue Wave library class
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 with the same has
value as c for which isEqual(c) returns TRUE. In this case, method
insert(c) will not add it, thus insuring that there are no duplicates.
The iterator for this class is RWSetIterator.
Persistence
Polymorphic
Public ConstructorsRWSet (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().
Public Member Operators
void
operator=(const RWSet& h);
Assignment operator. Makes a shallow copy of the collection h.
Page 1
RWSet(3C++) RWSet(3C++)
RWBoolean
operator==(const RWSet& h);
Returns TRUE if self and h have the same number of elements and if for
every key in self there is a corresponding key in h which isEqual.
RWBoolean
operator!=(const RWSet& h);
Returns the negation of operator==(), above.
RWBoolean
operator<=(const RWSet& h);
Returns TRUE if self is a subset of h, that is, every element of self
has a counterpart in h which isEqual. Note: If you inherit from RWSet
in the presence of the C++ Standard Library, we recommend that you
override this operator and explicitly forward the call. Overload
resolution in C++ will choose the Standard Library provided global
operators over inherited class members. These global definitions are not
appropriate for set-like partial orderings.
RWBoolean
operator<(const RWSet& h);
Returns TRUE if self is a proper subset of h, that is, every element of
self has a counterpart in h which isEqual, but where the two sets are not
identical.
RWSet&
operator*=(const RWSet& h);
Sets self to be the intersection of self and h. Returns self.
Public Member Functions
virtual void
apply(RWapplyCollectable ap, void*);
Redefined from class RWCollection to apply the user-supplied function
pointed to by ap to each member of the collection in a (generally)
unpredictable order. This supplied function must not do anything to the
items that could change the ordering of the collection.
virtual RWspace
binaryStoreSize() const;
Page 2
RWSet(3C++) RWSet(3C++)
Inherited from class RWCollection.
virtual void
clear();
Inherited from class RWCollection.
virtual void
clearAndDestroy();
Redefined from class RWCollection.
virtual int
compareTo(const RWCollectable* a) const;
Inherited from class RWCollectable.
virtual RWBoolean
contains(const RWCollectable* target) const;
Inherited from class RWCollection.
virtual size_t
entries() const;
Inherited from class RWCollection.
virtual RWCollectable*
find(const RWCollectable* target) const;
Returns the item in self which isEqual to the item pointed to by target
or nil if no item is found. Hashing is used to narrow the search.
virtual unsigned
hash() const;
Inherited from class RWCollectable.
virtual RWCollectable*
insert(RWCollectable* c);
Adds c to the collection and returns it. If an item is already in the
collection which isEqual to c, then the old item is returned and the new
item is not inserted.
Page 3
RWSet(3C++) RWSet(3C++)
virtual RWClassID
isA() const;
Redefined from class RWCollectable to return __RWSET.
virtual RWBoolean
isEmpty() const;
Inherited from class RWCollectable.
virtual RWBoolean
isEqual(const RWCollectable* a) const;
Redefined from class RWCollection.
void
intersectWith(const RWSet& h, RWSet& ret) const;
Computes the intersection of self and h, and inserts the result into ret
(which may be either empty or not, depending on the effect desired). It
may be slightly more efficient than operator*=().
virtual size_t
occurrencesOf(const RWCollectable* target) const;
Redefined from class RWCollection. Returns the count of entries that
isEqual to the item pointed to by target. Because duplicates are not
allowed for this collection, only 0 or 1 can be returned.
virtual RWCollectable*
remove(const RWCollectable* target);
Redefined from class RWCollection. Returns and removes the item that
isEqual to the item pointed to by target, or nil if there is no item.
virtual void
removeAndDestroy(const RWCollectable* target);
Inherited from class RWCollection.
void
resize(size_t n = 0);
Resizes the internal hashing table to leave n slots. If n==0, resizes to
Page 4
RWSet(3C++) RWSet(3C++)
3*entries()/2.
virtual void
restoreGuts(RWvistream&);
virtual void
restoreGuts(RWFile&);
virtual void
saveGuts(RWvostream&) const;
virtual void
saveGuts(RWFile&) const;
Inherited from class RWCollection.
RWStringID
stringID();
(acts virtual) Inherited from class RWCollectable.
Page 5