sorted
- 適当に突っ込んでからprintしてみると、ソートされていることが分かります
#include<bits/stdc++.h>
using namespace std;
int main(){
multiset<int> se;
se.insert(5);
se.insert(3);
se.insert(5);
se.insert(2);
se.insert(7);
for(int v : se){
cout << v << endl;
}
return 0;
}
2
3
5
5
7
値指定のerase
#include<bits/stdc++.h>
using namespace std;
int main(){
multiset<int> se;
se.insert(5);
se.insert(3);
se.insert(5);
se.insert(2);
se.insert(7);
se.erase(5);
for(int v : se){
cout << v << endl;
}
return 0;
}
2
3
7
#include<bits/stdc++.h>
using namespace std;
int main(){
multiset<int> se;
se.insert(5);
se.insert(3);
se.insert(5);
se.insert(2);
se.insert(7);
auto it = se.find(5);
se.erase(it);
for(int v : se){
cout << v << endl;
}
return 0;
}
2
3
5
7
まとめ