Tools.h++ Manual
104011 Tandem Computers Incorporated 15-13
15
Functions clear() and clearAndDestroy()
virtual void clear();
virtual void clearAndDestroy();
The function
clear()
removes all items from the collection.
The function
clearAndDestroy()
not only removes the items, but also calls
the virtual destructor for each item. Although it does check to see if the same
item occurs more than once in a collection (by building an IdentitySet
internally) and thereby deletes each item only once, it must still be used with
care. It cannot check to see whether an item is shared between two different
collections. You must also be certain that all possible members of the collection
were allocated off the heap.
15.5 Other functions shared by all RWCollections
There are several other functions that are shared by all classes that inherit from
RWCollection
. Note that these are not virtual functions.
Class conversions
RWBag asBag() const;
RWSet asSet() const;
RWOrdered asOrderedCollection() const;
RWBinaryTree asSortedCollection() const
These functions allow any collection class to be converted into a
RWBag
,
RWSet
,
RWOrdered
, or a
SortedCollection
(i.e., a
RWBinaryTree
).
Inserting and removing other collections
void operator+=(const RWCollection&);
void operator-=(const RWCollection&);
These functions insert or remove (respectively) the contents of their argument.