STL
This commit is contained in:
31
STL/STL-map/multimap.cpp
Normal file
31
STL/STL-map/multimap.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
bool cmp(int a, int b){
|
||||
return a < b;
|
||||
}
|
||||
|
||||
int main(){
|
||||
auto cmpl = [](int a, int b){
|
||||
return a > b;
|
||||
};
|
||||
multimap<int, string, bool(*)(int, int)> a(cmp);
|
||||
multimap<int, string, decltype(cmpl)> b(cmpl);
|
||||
a.insert({{1,"111"},{2,"222"},{1,"11"},{1,"1"},{2,"22"},{3,"333"}});//emplaceֻ<65><D6BB><EFBFBD><EFBFBD>make_pair<69><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ôд
|
||||
//pair<const int, string><3E><>Key<65><79>const<73><74><EFBFBD>ε<EFBFBD>
|
||||
for(pair<int, string> x : a){
|
||||
cout << x.first << ", " << x.second << " ";
|
||||
}
|
||||
cout << endl;
|
||||
cout << a.find(1)->second << " " << a.count(1) << endl;
|
||||
a.erase(a.find(1));
|
||||
cout << a.find(1)->second << " " << a.count(1) << endl;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
1, 111 1, 11 1, 1 2, 222 2, 22 3, 333
|
||||
111 3
|
||||
11 2
|
||||
*/
|
||||
|
Reference in New Issue
Block a user