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 的区别?


基础教程推荐
- C++,'if' 表达式中的变量声明 2021-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 设计字符串本地化的最佳方法 2022-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01