- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does anybody knows of a concrete example for setting the initial capacity on the concurrrent_hash_map? I found recommendations of doing this to improve performance but looking at the members of the class it seems that you need to define a memory allocator too.
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, really specifying initial capacity can be useful for performance. If you know that after creating concurrent_hash_map instert or emplace operations will be performed, allocating at the beginning of the memory will save time on inserts in concurrent_hash_map.
If you do not specify the allocator as a template parameter, then the default allocator will be taken, in the file concurrent_hash_map.h you can find a list of default template parameters .
So an example of such a constructor might be:
concurrent_hash_map<int, int> my_map(10);
![](/skins/images/AF5E7FF58F8A386030D1DB97A0249C2E/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page