Specify the minimum number of buckets when creating boost :: unordered_map

I am trying to use boost :: unordered_map to cache some values. I am trying to specify the minimum number of buckets in the constructor:

#include <boost/unordered_map.hpp>
typedef boost::unordered_map<float, float> Mycache;
Mycache cache((std::size_t)25165843,
              boost::hash<float>(),
              std::equal_to<float>(),
              std::allocator<std::pair<float const, float> >());

But when I display information about my unordered_map at the end of the program:

g ++:

unordered_map.size(): 15861612
unordered_map.load_factor: 10.0845
unordered_map.bucket_count: 1572869
unordered_map.max_size: 1572868
unordered_map.max_load_factor: 1
unordered_map.max_bucket_count: 1572869

VC ++:

unordered_map.size(): 13916119
unordered_map.load_factor: 8.8476
unordered_map.bucket_count: 1572869
unordered_map.max_size: 1572868
unordered_map.max_load_factor: 1
unordered_map.max_bucket_count: 1572869

How to specify the minimum number of buckets?

+3
source share
2 answers

boost::unordered_map::max_bucket_count() , , unordered_map. , . : MSDN , " " ( ), ++ 0x , , .

, ++ 0x , , , , .

, 1572869, , .

+2

, max_bucket_count ​​Boost 1.38, .

+3

Source: https://habr.com/ru/post/1705531/


All Articles