hash_map 和 unordered_map 的区别?

Difference between hash_map and unordered_map?(hash_map 和 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 的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)