unordered_set::max_bucket_count()是C++ STL中的內置函數,用於查找unordered_set可以具有的最大存儲桶數。
由於係統指定的約束和某些限製,此函數返回係統可以具有的最大存儲桶數。
參數:此函數不帶任何參數。
用法:
size_type max_bucket_count()
其中,size_type是無符號整數類型。
返回值:它返回unordered_set容器可以具有的最大存儲桶數。
異常:如果任何元素比較對象都拋出異常,則拋出Exception。
以下示例程序旨在說明unordered_set::max_bucket_count()函數:
// CPP program to illustrate
// unordered_set::max_bucket_count() function
#include <iostream>
#include <unordered_set>
using namespace std;
int main()
{
unordered_set<int> Myset;
Myset.insert(10);
Myset.insert(20);
// printing the contents
cout<<"Elements : ";
for (auto it = Myset.begin(); it != Myset.end(); ++it)
cout << "[" << *it << "]";
cout << endl;
// inspect current parameters
cout << "max_size : " << Myset.max_size() << endl;
cout << "max_bucket_count() : " << Myset.max_bucket_count() << endl;
cout << "max_load_factor() : " << Myset.max_load_factor() << endl;
return 0;
}
輸出:
Elements : [20][10] max_size : 1152921504606846975 max_bucket_count() : 1152921504606846975 max_load_factor() : 1
輸出:
[20][10] max_size : 1152921504606846975 max_bucket_count() : 1152921504606846975 max_load_factor() : 1
時間複雜度:執行操作需要固定的複雜時間。
相關用法
- C++ log()用法及代碼示例
- C++ div()用法及代碼示例
- C++ fma()用法及代碼示例
- C++ real()用法及代碼示例
- C++ map key_comp()用法及代碼示例
- C++ imag()用法及代碼示例
- C++ regex_iterator()用法及代碼示例
注:本文由純淨天空篩選整理自SoumikMondal大神的英文原創作品 unordered_set max_bucket_count() function in C++ STL。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。