size_type bucket ( const key_type& k ) const;
// unordered_set::bucket #include <iostream> #include <string> #include <unordered_set> int main () { std::unordered_set<std::string> myset = {"water","sand","ice","foam"}; for (const std::string& x: myset) { std::cout << x << " is in bucket #" << myset.bucket(x) << std::endl; } return 0; } |
unordered_set::bucket_count | 返回存储桶的数量(公众成员函数) |
unordered_set::bucket_size | 返回存储桶的容量(公众成员函数) |
unordered_set::find | 获取元素的迭代器(公众成员函数) |