Hash Map: Doxygen and Reserve?

Hash Map: Doxygen and Reserve?

Dear all, I have two very simple questions.

The first is this: am I missing the doxygen documentation for concurrent_hash_map? The only documentation I've seen is this: http://www.threadingbuildingblocks.org/docs/help/tbb_userguide/concurrent_hash_map.htm

The second is: how can I reserve memory? The std::unordered_map gives me std::unordered_map::reserve, but TBB's implementation seems to provide only a protected method... and I'd really like to avoid subclassing for just this simple task. But maybe there's a way I'm not aware of.

Thanks!

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

How about using rehash() instead?

(Added) There's also a Reference Manual, but the doxygen content unfortunately hides under tbb::interface5::concurrent_hash_map (so you always have to check those interface... versions).

(Added) For completeness: you reserve for "buckets", not for "memory" (there will still be allocations for elements); don't overlook the constructor that allows you to reserve in advance; don't subclass concurrent_hash_map in the hope of using reserve() as in std::unordered_map (it doesn't have the same effect).

(2014-06-18 Correction: ordered_map->unordered_map)

Quote:

Raf Schietekat wrote:

How about using rehash() instead?

(Added) There's also a Reference Manual, but the doxygen content unfortunately hides under tbb::interface5::concurrent_hash_map (so you always have to check those interface... versions).

Thanks, Raf, I didn't see that! I wonder why it is hidden down there, honestly, I never looked into those namespaces...

Quote:

Raf Schietekat wrote:

(Added) For completeness: you reserve for "buckets", not for "memory" (there will still be allocations for elements); don't overlook the constructor that allows you to reserve in advance; don't subclass concurrent_hash_map in the hope of using reserve() as in std::ordered_map (it doesn't have the same effect).

Ok, I won't subclass it.

Thanks, as always you're really helpful!

Leave a Comment

Please sign in to add a comment. Not a member? Join today