hash表相关
头文件
#include <unordered_map>
定义与初始化
unordered_map<int,string> unomap;
unordered_map<int,string> unomap = {{1,"dd"},{2,"ssss"}};
打印查找
for(auto x: unomap){
cout<<unomap[x.first]<<endl;
cout<<x.second<<endl; //以value值输出
}
myMap.insert(pair<int,string>(3,"陈二"));//插值用pair的形式
myMap.insert(pair<int,string>(3,"陈二"));//以pair的形式插入
myMap[2] = "zhangsan";
//类比python字典,有加替换,value,没有直接创建一个出来。