Multisets are associative containers available in the C++ Standard Library. They are similar to sets with an addition that multiple keys with equivalent values are allowed. The multiset::clear()
is a method available in the STL that removes all elements from the container.
Syntax:
set_name.clear();
Parameters: The multiset::clear()
does not accept any parameter:
Return value: none
Example of multiset::clear() method
#include <iostream> #include <set> using namespace std; int main() { multiset<int> m; m.insert(1); m.insert(2); m.insert(3); m.insert(4); cout<<m.size()<<endl; m.clear(); cout<<"Size after clear: "<<m.size(); }
Output:
4 Size after clear: 0