Boost - unordered_set 教程/示例/有什么吗?
我想在项目中使用 unordered_set
。
然而,它的文档要么不完整,要么只是技术参考,没有示例。
任何人都可以提供处理该问题的在线资源的链接吗?也欢迎书籍,最好是免费的。谷歌搜索没有返回任何有价值的信息。
谢谢!
I'd like to use unordered_set
in a project.
However, documentation for it is either incomplete or just a technical reference, no examples.
Can anyone provide links to online resources which deal with it? Books also welcome, preferably free. Google searching returned nothing of value.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最常见用例的代码:
输出
更多信息
http://www.cplusplus.com/reference/unordered_set/unordered_set/find/
Code for the most common use case:
Output
More Information
http://www.cplusplus.com/reference/unordered_set/unordered_set/find/
关于它的文档很少,因为它的行为与
std::set
,但它需要散列和等于函数而不是比较函数。只需查找std::set
的示例,并将其替换为std::unordered_set
你应该没问题。如果您需要编写哈希函数,文档中有示例,即 这个。
There's little docs on it because it behaves exactly like
std::set
, with the exception that it requires a hashing and equals function instead of a comparison function. Just look up examples forstd::set
, and replace them withstd::unordered_set
and you should be fine.If you need to write a hashing function, there are examples in the docs, i.e. this one.
boost 容器实际上是 C++ 标准库技术报告(称为 TR1)首先指定的接口的实现,如 boost 文档中所述。目前它们似乎已成为新标准工作草案的一部分。如果您搜索 tr1 和 unordered_set,Google 会显示更多文档/示例。我喜欢 MSDN 参考,其中也有一些示例:
http://msdn.microsoft .com/en-us/library/bb982739.aspx
http://www .google.de/search?q=tr1+unordered_set
The boost containers are effectively an implementation of the interface first specified by the C++ Standard Library Technical Report (known as TR1), as mentioned in the boost docs. They seem to be part of the new standards working draft by now. Google turns up some more documentation/examples if you search for tr1 and unordered_set. I like the MSDN reference, which also has some samples:
http://msdn.microsoft.com/en-us/library/bb982739.aspx
http://www.google.de/search?q=tr1+unordered_set
我会尝试使用与
std::set
或其他容器相同的访问方法,http://www.boost.org/doc/libs/1_37_0/doc/html/unordered.html 似乎同意。I would try using the same methods of access that you use on
std::set
or other containers, http://www.boost.org/doc/libs/1_37_0/doc/html/unordered.html seems to agree.