unordered_map
#include <iostream>
#include <string>
#include <unordered_map>
int main()
{
// 创建包含三个字符串的(映射到字符串的)unordered_map
std::unordered_map<std::string, std::string> u =
{
{"red", "#FF0000"},
{"green", "#00FF00"},
{"blue", "#0000FF"}
};
map<string,string> xs;
xs.insert(make_pair("555","44444"));
xs["222"] ="aaa";
xs["333"] ="aaaa";
for (auto x:xs) {
cout<<x.first<<"\t"<<x.second<<endl;
}
}
find方法查找
map<string,string> mm;
mm["12"] ="12";
mm["13"] ="13";
mm["14"] ="14";
auto iterator = mm.find("13");
if (iterator != mm.end()){
cout<< iterator->first<<"\t"<<iterator->second<<endl;
}