Boost :: unordered_map missing reserve () like std :: unordered_map

For my next task, I need to use a very large hash; since I have an old compiler, I cannot use C ++ 0x std::unordered_map . Ideally, I need a reserve call to make a 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 achieve the same?

2 associative container is the same; I see the rehash function and the same constructor for controlling the number of buckets, but not the function about the number of elements.

Can you help me?

+2
c ++ unordered-map boost-unordered
source share
1 answer

reserve can be emulated using rehash , as in table 103 in N3376.

 a.rehash(n) Post: a.bucket_count() > a.size() / a.max_load_factor() and a.bucket_count() >= nareserve(n) Same as a.rehash(ceil(n / a.max_load_factor())) 
+6
source share

All Articles