hash_map和unordered_map之间的区别? [英] Difference between hash_map and unordered_map?

查看:856
本文介绍了hash_map和unordered_map之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现在c ++中实现哈希映射将被称为unordered_map。当我查找为什么他们不只是使用hash_map,我发现显然有相容性问题的hash_map的实现unordered_map解析( http://en.wikipedia.org/wiki/Unordered_map_%28C%2B%2B%29 )。 wiki页面没有提供更多的信息,所以我想知道是否有人知道一些与hash_map的问题unordered_map解析

I recently discovered that the implementation of the hash map in c++ will be called unordered_map. When I looked up why they weren't just using hash_map, I discovered that apparently there are compatiblity issues with the implementation of hash_map that unordered_map resolves(http://en.wikipedia.org/wiki/Unordered_map_%28C%2B%2B%29). The 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之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆