//解释其插入、删除和下标操作:
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main() {
vector<int> a, b, c, d, e;
map<int, vector<int>> c1{ {1,a},{2,b},{3,c},{4,d} };
map<string, float> c2;
c2.insert({ "otto",22.3 });
c2.insert(pair<const string, float>("ottop", 22.4));
c2.erase("otto"); //按key删除直接删即可
for (auto pos = c2.begin(); pos != c2.end();) {
if (abs(pos->second - 22.3)<0.01)
pos = c2.erase(pos); //按value删除就需要迭代器的技巧,直接erase(pos)会使pos失效。
else pos++;
}
cout << endl;
c2["abc"]; //最后是subscript的用法,1、可以不是int型;2、没有该key就是插入操作,其value=0;
c2["def"];
cout << c2["abc"] << endl;
c2["def"] = 22.5;
cout << c2["def"] << endl;
}