在C++ STL中的unordered_multimap.bucket_count()函数
unordered_multimap::bucket_count() 是C++ STL中的内置函数,它返回unordered_multimap容器中的桶(bucket)总数。 桶是容器内部哈希表中的插槽,元素根据其哈希值被分配到这些插槽中。
语法:
参数: 该函数不接受任何参数。
返回值: 返回一个无符号整数类型,表示桶的总计数。
下面的程序说明了上面的函数:
程序1:
程序2:
桶总数:7 桶 0: {b, c}, 桶 1: {c, b}, 桶 2: {r, a}, 桶 3: 空的 桶 4: 空的 桶 5: 空的 桶 6: {a, b}, {a, b}, “`