Difference between hash_map and unordered_map?(hash_map 和 unordered_map 的区别?)
问题描述
最近发现C++中hash map的实现会叫unordered_map
.
I recently discovered that the implementation of the hash map in C++ will be called unordered_map
.
当我查看他们为什么不只是使用 hash_map
时,我发现显然 hash_map
的实现存在兼容性问题,即 unordered_map
解析(更多关于它这里).
When I looked up why they weren't just using hash_map
, I discovered that apparently there are compatibility issues with the implementation of hash_map
that unordered_map
resolves (more about it here).
那个 wiki 页面没有提供更多信息,所以我想知道是否有人知道 unordered_map
解决的 hash_map
的一些问题.
That wiki page doesn't give much more information so I wondering if anyone knew some of the issues with hash_map
that unordered_map
resolves.
推荐答案
由于C++标准库中没有定义哈希表,标准库的不同实现者会提供一个非标准的哈希表,通常命名为hash_map代码>.因为这些实现不是按照标准编写的,所以它们在功能和性能保证方面都有细微的差别.
Since there was no hash table defined in the C++ standard library, different implementors of the standard libraries would provide a non-standard hash table often named hash_map
. Because these implementations were not written following a standard they all had subtle differences in functionality and performance guarantees.
从 C++11 开始,已添加哈希表实现C++ 标准库标准.决定为该类使用替代名称,以防止与这些非标准实现发生冲突,并防止代码中包含 hash_table
的开发人员无意中使用新类.
Starting with C++11 a hash table implementation has been added to the C++ standard library standard. It was decided to use an alternate name for the class to prevent collisions with these non-standard implementations and to prevent inadvertent use of the new class by developers who had hash_table
in their code.
选择的备用名称是 unordered_map
,它确实更具描述性,因为它暗示了类的地图界面及其元素的无序性质.
The chosen alternate name is unordered_map
which really is more descriptive as it hints at the class's map interface and the unordered nature of its elements.
这篇关于hash_map 和 unordered_map 的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:hash_map 和 unordered_map 的区别?


基础教程推荐
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07