腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
首页
学习
活动
专区
工具
TVP
最新优惠活动
返回腾讯云官网
121js
专栏成员
举报
2
文章
5446
阅读量
1
订阅数
订阅专栏
申请加入专栏
全部文章(2)
java(1)
c++(1)
javascript(1)
sql(1)
容器(1)
网络安全(1)
数据结构(1)
https(1)
搜索文章
搜索
搜索
关闭
C++ map 和 hashmap 区别
c++
容器
sql
数据结构
1. stl map is an associative array where keys are stored in sorted order using balanced trees. while hash_map is a hashed associated container, where keys are not stored in an ordered way. key, value pair is stored using a hashed function. 2. insertion and lookup takes ologn time in map, also performance would degrade as the key size increases. mainly balance operations on large key ranges would kill performance. while lookup is very efficient o(1) in hash_map. 3. map is useful where you want to store keys in sorted order, hash_map is used where keys order is not important and lookup is very efficient. 4. one more difference is map has the important property that inserting a new element into a map does not invalidate iterators that point to existing elements. erasing an element from a map also does not invalidate any iterators. performance would mostly be o(lgn) due to the implementation of a balanced tree. for map custom objects you would need at the minimum the following operators to store data in a map "<" ">" "==" and of course the other stuff for deep copy.
用户7436765
2020-06-07
2.9K
0
js & array & shuffle
https
网络安全
java
javascript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
用户7436765
2020-06-07
2.5K
0
没有更多了
社区活动
【纪录片】中国数据库前世今生
穿越半个世纪,探寻中国数据库50年的发展历程
立即查看
Python精品学习库
代码在线跑,知识轻松学
立即查看
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
立即体验
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
立即查看
领券
问题归档
专栏文章
快讯文章归档
关键词归档
开发者手册归档
开发者手册 Section 归档