delete from multiset c++ code example
Example: how to erase element from multiset c++
#include <iostream>
#include <set>
int main()
{
std::multiset<int>ms;
ms.insert(1);
ms.insert(1);
ms.insert(2);
ms.insert(2);
ms.insert(3);
ms.insert(3);
for(auto& it : ms) {
std::cout<<it<<' ';
}
std::cout<<'\n';
ms.erase(2);
for(auto& it : ms) {
std::cout<<it<<' ';
}
std::cout<<'\n';
ms.erase(ms.begin());
for(auto& it : ms) {
std::cout<<it<<' ';
}
std::cout<<'\n';
ms.erase(ms.find(3));
for(auto& it : ms) {
std::cout<<it<<' ';
}
return 0;
}