1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
// unordered_multimap::bucket_count
#include <iostream>
#include <string>
#include <unordered_map>
int main ()
{
std::unordered_multimap<std::string,std::string> myumm = {
{"bed","bedroom"},
{"oven","kitchen"},
{"towel","bathroom"},
{"towel","beach"},
{"plant","garden"}
};
unsigned n = myumm.bucket_count();
std::cout << "myumm has " << n << " buckets.\n";
for (unsigned i=0; i<n; ++i) {
std::cout << "bucket #" << i << " contains: ";
for (auto it = myumm.begin(i); it!=myumm.end(i); ++it)
std::cout << "[" << it->first << ":" << it->second << "] ";
std::cout << "\n";
}
return 0;
}
| |