Using the erase Member Function on a Multiset
#include <set>
#include <iostream>
using namespace std;
typedef multiset <int> MSETINT;
int main ()
{
MSETINT msetIntegers;
msetIntegers.insert (43);
msetIntegers.insert (78);
msetIntegers.insert (78);
msetIntegers.insert (-1);
msetIntegers.insert (124);
MSETINT::const_iterator iElement;
cout << msetIntegers.size () << " elements.";
for ( iElement = msetIntegers.begin (); iElement != msetIntegers.end (); ++ iElement )
cout << *iElement << endl;
int nNumberToErase = 2;
cout << msetIntegers.count (nNumberToErase);
cout << nNumberToErase << endl;
msetIntegers.erase (nNumberToErase);
cout << msetIntegers.size () << " elements.";
for ( iElement = msetIntegers.begin (); iElement != msetIntegers.end (); ++ iElement )
cout << *iElement << endl;
return 0;
}
Related examples in the same category