标签:插入 tor begin i++ value lis list count int
undered_map<T1,T2> m; //T1是key值,T2是value值,初始的时候 m 是空映射
unordered_map<int, int> map;
for (int i=0; i<list.size(); i++){
map[i] = list[i];
}
cout << map[0] << endl;
for (unordered_map<int, int>::iterator i = map.begin(); i != map.end(); i++){
cout << i->first << ‘ ‘ << i->second << endl;
}
if (map.find(3) != map.end()) {
cout << "find key=" << map.find(3)->first << ", value=" << map.find(3)->second << endl;
}
if (map.count(5) > 0) {
cout << "find 5: " << map.count(5) << endl;
}
2021-4-1 C++ STL之unordered_map
标签:插入 tor begin i++ value lis list count int
原文地址:https://www.cnblogs.com/jobshenlei/p/14607780.html