boost :: unordered_map missing reserve()like std :: unordered_map [英] boost::unordered_map missing reserve() like std::unordered_map
问题描述
对于我的下一个任务,我需要使用一个非常大的哈希;因为我有一个旧的编译器,我不能使用C ++ 0x std :: unordered_map
。理想情况下,我需要调用 reserve
为大量项目提前腾出空间。我在 boost :: unordered_map
中找不到此方法:是否有任何可实现相同的地方或函数?
2关联容器是相同的;我可以看到 rehash
函数和相同的构造函数用于控制桶的数量,但不是一个关于一些元素的函数。
$ b $
可以使用N3376中的表103中的 rehash
来模拟。
a .rehash(n)
发布:a.bucket_count()> a.size()/ a.max_load_factor()
和a.bucket_count()> = n。
a.reserve(n)与a.rehash(ceil(n / a.max_load_factor())相同)
For my next task I need to use a very big hash; since I have an old compiler I cannot use C++0x std::unordered_map
. Ideally I need is a call to reserve
to make room in advance for a large number of items. I cannot find this method in boost::unordered_map
: is there any place or function that achieves the same?
The 2 associative container are the same; I can see rehash
function and the same constructor for controlling the number of buckets, but not a function about a number of elements.
Can you help me with that?
reserve
can be emulated by rehash
as in Table 103 in N3376.
a.rehash(n)
Post: a.bucket_count() > a.size() / a.max_load_factor()
and a.bucket_count() >= n.
a.reserve(n) Same as a.rehash(ceil(n / a.max_load_factor()))
这篇关于boost :: unordered_map missing reserve()like std :: unordered_map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!