unordered_map的原理和使用
来源:互联网 发布:ubuntu怎么查看分区 编辑:程序博客网 时间:2024/06/19 02:40
1.原理
unordered_map: unordered_map内部实现了一个哈希表,因此其元素的排列顺序是杂乱的,无序的
2.使用
a.查找元素是否存在unordered_map<
int, int> map中是否存在x:
map.find(x)!=map.end()或
map.count(x)!=0
b.插入数据
map.insert(Map::value_type(1,”Raoul”));
c.遍历
unordered_map<
key,T>
::iterator it;
(*it).first; //the key value
(*it).second //the mapped value
for(unordered_map<
key,T>
::iterator iter=mp.begin();iter!=mp.end();iter++)
{ cout<<”key value is”<first;
cout<<” the mapped value is “<< iter->second;}
3.评价
优点:
因为内部实现了哈希表,因此其查找速度非常的快
缺点:
哈希表的建立比较耗费时间
适用处:
对于查找问题,unordered_map会更加高效一些,因此遇到查找问题,常会考虑一下用unordered_map
0 0
- unordered_map的原理和使用
- hash_map/unordered_map原理和使用
- map/unordered_map原理和使用整理
- hash_map/unordered_map原理和使用整理
- map/unordered_map原理和使用整理
- map/unordered_map原理和使用整理
- hash_map和unordered_map的使用
- hash_map,unordered_map的使用
- unordered_map的使用
- unordered_map和map的区别
- Codeforces165A 练习使用unordered_map和set
- boost:unordered_map和std::map的使用详解和性能比较
- C++11 unordered_map 无序容器的使用
- C++11中std::unordered_map的使用
- 【leetcode】Two Sum(unordered_map的使用)
- STL map和unordered_map的区别
- unordered_map 与 map 的区别和联系
- c++的multimap(set)和unordered_map(set)
- 【Java设计模式05】——适配器模式
- 总结一下JAVA的设计模式
- Springboot获取请求参数
- android bindservice以及activity和service传递数据
- windows 远程桌面连接
- unordered_map的原理和使用
- Visual Studio Code Git版本控制 更改语言成英文
- 数组的循环移位
- Nginx的nginx.conf配置文件中文注释说明
- sql常用函数
- wireshark找到与http请求对应的响应数据
- 20170408_网络常用的测试工具
- C++(笔记)三种继承机制
- ZOJ2838【LCA在线查询】