size_type bucket_count() const noexcept;
// unordered_set::bucket_count #include <iostream> #include <string> #include <unordered_set> int main () { std::unordered_set<std::string> myset = {"Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"}; unsigned n = myset.bucket_count(); std::cout << "myset has " << n << " buckets.\n"; for (unsigned i=0; i<n; ++i) { std::cout << "bucket #" << i << " contains:"; for (auto it = myset.begin(i); it!=myset.end(i); ++it) std::cout << " " << *it; std::cout << "\n"; } return 0; } |
unordered_set::bucket | 定位元素的存储桶(公众成员函数) |
unordered_set::bucket_size | 返回存储桶的大小(公众成员函数) |
unordered_set::load_factor | 返回存储桶的元素平均数量(负载系数)(公众成员函数) |
unordered_set::max_load_factor | 获取或设置存储桶最大的负载系数(公众成员函数) |