C++ unordered_map

来源:互联网 发布:linux vi 全部删除 编辑:程序博客网 时间:2024/06/05 07:53

unordered_map,可以看做是一个哈希映射,当你需要记录大量K/V键值对时适用。

声明:

unordered_map<Key_Type, Value_Type> name;

使用时类似于map:name["you"] = "Alan";

cout<<name["you"]<<endl; // Alan

遍历

for (unordered_map<string,string>::iterator it = name.begin(); it != name.end; ++it) {  cout<<it->first<<" "<<it->second<<endl;}


0 0