jeudi 3 mars 2016

Unexpected behaviour of max_bucket_count function

According to the C++ reference, unordered_set::max_bucket_count() function should return the maximum number of buckets the container can have on the system running the program http://ift.tt/1OTNZ4K

However, with visual studio 2015, the output of bucket_count and max_bucket_count is same, even when number of elements in unordered_set is small.

unordered_set<string> us;
ifstream ifs("small_words.txt");
string word;
while (ifs >> word) {
    us.insert(word);
}

cout << "Number of elements: " << us.size() << endl;
cout << "bucket_count: " << us.bucket_count() << endl;
cout << "max_bucket_count: " << us.max_bucket_count() << endl;

Output:

Number of elements: 41
bucket_count: 64
max_bucket_count: 64

Is there a valid explanation for this behaviour?

Aucun commentaire:

Enregistrer un commentaire