C++ STL 是否包含哈希表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2192976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does the STL contain a hashtable?
提问by Mithrax
Possible Duplicates:
Hashtable in C++?
can anybody offer a simple hash_map example in C++?
Does the STL contain an implementation of a hashtable?
STL 是否包含哈希表的实现?
If so, can you provide a brief example of how to use it?
如果是这样,您能否提供一个简短的示例来说明如何使用它?
回答by Kornel Kisielewicz
Current standard implementation doesn't, STL::TR1does, see Unordered Map.
当前的标准实现没有,STL::TR1有,请参阅Unordered Map。
Most modern compilers have a TR1 implementation, if that fails, you may always use the Boost TR1implementation.
大多数现代编译器都有 TR1 实现,如果失败,您可以始终使用Boost TR1实现。
- MSVC has it for VS2008 via service pack 1
- GCC has it shipped with 4.x, but you can make it work with 3.4.x too AFAIR
- MSVC 通过 Service Pack 1 将其用于 VS2008
- GCC 随 4.x 一起提供,但您也可以使其与 3.4.x 一起使用 AFAIR
Usage is almost the same as with a std::map.
用法几乎与 std::map 相同。
回答by bdd
While not officially part of the STL standard,hash_map and hash_set are commonly used to improve searching times......
虽然不是 STL 标准的正式组成部分,但hash_map 和 hash_set 通常用于提高搜索时间......
http://msdn.microsoft.com/en-us/library/0d462wfh%28VS.80%29.aspx
http://msdn.microsoft.com/en-us/library/0d462wfh%28VS.80%29.aspx
So, long story short--no .
所以,长话短说——不。
回答by Maurits Rijk
A quick google came up with this description of hash_map.
一个快速的谷歌想出了hash_map 的这个描述。