STL
This commit is contained in:
@@ -22,6 +22,7 @@ int main(){
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
cout << a.count(3) << endl;
|
cout << a.count(3) << endl;
|
||||||
a.erase(6);
|
a.erase(6);
|
||||||
|
//û<><C3BB>.at()<29><>a[i]<5D><><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7>ʵ<EFBFBD>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>it++
|
||||||
for(auto it = a.begin(); it != a.end(); it++){
|
for(auto it = a.begin(); it != a.end(); it++){
|
||||||
cout << *it << " ";
|
cout << *it << " ";
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ int main(int argc, char* argv[]){
|
|||||||
b.insert(make_pair(3,"333"));
|
b.insert(make_pair(3,"333"));
|
||||||
b.emplace(make_pair(4,"444"));
|
b.emplace(make_pair(4,"444"));
|
||||||
cout << b.count(3) << endl;
|
cout << b.count(3) << endl;
|
||||||
|
//û<><C3BB>.at()<29><>a[i]<5D><><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7>ʵ<EFBFBD>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>it++
|
||||||
for(auto it = b.begin(); it != b.end(); it++){
|
for(auto it = b.begin(); it != b.end(); it++){
|
||||||
cout << it->first << ", " << it->second << " ";
|
cout << it->first << ", " << it->second << " ";
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
|
BIN
STL/STL-map/multimap.exe
Normal file
BIN
STL/STL-map/multimap.exe
Normal file
Binary file not shown.
0
STL/STL-unordered_map/README.MD
Normal file
0
STL/STL-unordered_map/README.MD
Normal file
0
STL/STL-unordered_set/README.MD
Normal file
0
STL/STL-unordered_set/README.MD
Normal file
Reference in New Issue
Block a user