Functions clear() and clearAndDestroy()
To remove all items from the collection, you can use the functions clear() and clearAndDestroy():
 
virtual voidclear();
virtual voidclearAndDestroy();
The function clearAndDestroy() not only removes the items, but also calls the virtual destructor for each item. You must use this function with care. The function does check to see if the same item occurs more than once in a collection (by building an RWIdentitySet internally), and thereby deletes each item only once. However, it cannot check whether an item is shared between two different collections. You must also be certain that every member of the collection was allocated off the heap.