#include <set>
    void clear();

The function clear() deletes all of the elements in the multiset. This will call the destructor for all of the elements in the multiset. clear() runs in linear time.

After a call to clear, the multiset's new size will be zero. The multiset's capacity however, will not be changed, and the multiset will not release its allocated memory.

If you want to empty a multiset of all of its elements, as well as its capacity, then you can use the swap trick:

    std:: multiset aMultiset;
    aMultiset.swap( std::multiset() );

This will create a new temporary empty multiset, which will swap with the multiset you wish to empty.

Related Topics: erase, swap