1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
// unordered_multimap::bucket_size
#include <iostream>
#include <string>
#include <unordered_map>
int main ()
{
std::unordered_multimap<std::string,std::string> myumm = {
{"John","Alpha"},
{"Alfred","Beta"},
{"Thomas","Gamma"},
{"John","Delta"}
};
unsigned nbuckets = myumm.bucket_count();
std::cout << "myumm has " << nbuckets << " buckets:\n";
for (unsigned i=0; i<nbuckets; ++i) {
std::cout << "bucket #" << i << " has " << myumm.bucket_size(i) << " elements.\n";
}
return 0;
}
| |