这个 无序的多重映射::最大桶数() 在C++ STL中是一个内置函数,它返回无序多联机容器可以拥有的最大桶数。这是它所能拥有的最大值,尽管存在碰撞,但由于某些限制,它不能超过。
null
语法 :
unordered_multimap_name.max_bucket_count()
参数 :该函数不接受任何内容。
返回值 :该函数返回可能的最大桶数。
下面的程序说明了 无序的多重映射::最大桶数() 功能:
方案1 :
// C++ program to illustrate the // unordered_multimap::max_bucket_count() #include <iostream> #include <unordered_map> using namespace std; int main() { // declaration unordered_multimap< char , char > sample; // inserts key and element sample.insert({ 'a' , 'b' }); sample.insert({ 'a' , 'b' }); sample.insert({ 'a' , 'd' }); sample.insert({ 'b' , 'e' }); sample.insert({ 'b' , 'd' }); cout << "The maximum bucket count is: " << sample.max_bucket_count(); return 0; } |
输出:
The maximum bucket count is: 1152921504606846975
方案2 :
// C++ program to illustrate the // unordered_multimap::max_bucket_count() #include <iostream> #include <unordered_map> using namespace std; int main() { // declaration unordered_multimap< int , int > sample; // inserts key and element sample.insert({ 1, 2 }); sample.insert({ 1, 3 }); sample.insert({ 2, 4 }); sample.insert({ 5, 8 }); sample.insert({ 7, 10 }); cout << "The maximum bucket count is: " << sample.max_bucket_count(); return 0; } |
输出:
The maximum bucket count is: 1152921504606846975
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END