1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
// unordered_multiset::erase
#include <iostream>
#include <string>
#include <unordered_set>
int main ()
{
std::unordered_multiset<std::string> myums =
{"fish","duck","cow","cow","pig","hen","sheep"};
myums.erase ( myums.begin() ); // erasing by iterator
myums.erase ( "sheep" ); // erasing by key
myums.erase ( myums.find("fish"), myums.end() ); // erasing by range
std::cout << "myums contains:";
for ( const std::string& x: myums ) std::cout << " " << x;
std::cout << std::endl;
return 0;
}
| |