Clear content
All the elements in the container are dropped: their destructors are called, and they are removed from the container, leaving it with a size of 0.
Parameters
none
Return value
none
Example
// multiset::clear
#include <iostream>
#include <set>
using namespace std;
int main ()
{
multiset<int> mymultiset;
multiset<int>::iterator it;
mymultiset.insert (11);
mymultiset.insert (42);
mymultiset.insert (11);
cout << "mymultiset contains:";
for (it=mymultiset.begin(); it!=mymultiset.end(); ++it)
cout << " " << *it;
mymultiset.clear();
mymultiset.insert (200);
mymultiset.insert (100);
cout << "\nmymultiset contains:";
for (it=mymultiset.begin(); it!=mymultiset.end(); ++it)
cout << " " << *it;
cout << endl;
return 0;
}
|
Output:
mymultiset contains: 11 11 42 myset contains: 100 200
|
Complexity
Linear in size (destructors).
See also