https://blog.csdn.net/qq_40838478/article/details/114664223
int main()
{
unordered_map<int, string> map = { { 0,"123" } };
map.insert(pair<int, string>(1, "abc")); //使用pair方式插入
map.insert(pair<int, string>{2, "hello"});
map.insert(pair<int, string>{3, "world"});
map[4] = "rgb"; //使用[]进行单个插入,key重复的,则覆盖
auto iter = map.begin();
while (iter != map.end())
{
cout << iter->first << "," << iter->second << endl;
++iter;
}
auto iterator = map.find(2);//find()返回一个指向2的迭代器
if (iterator != map.end())
{
cout << endl << iterator->first << "," << iterator->second << endl;
}
return 0;
}