Last Updated : 05 Jun, 2023
The unordered_set::max_bucket_count() is a built-in function in C++ STL which is used to find the maximum number of buckets that unordered_set can have. This function returns the maximum number of buckets a system can have because of the constraints specified by the system and some limitations.
Parameters : This function does not take any parameters.
Syntax :
size_type max_bucket_count()
Where, size_type is an unsigned integral type.
Return Value : It returns the maximum number of buckets that the unordered_set container can have.
Exceptions : An Exception is thrown if any element comparison object throws exception.
Below program illustrate the unordered_set::max_bucket_count() function:
CPP
// 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;
}
Output:
Elements : [20][10] max_size : 1152921504606846975 max_bucket_count() : 1152921504606846975 max_load_factor() : 1
Time Complexity: It takes constant time of complexity to perform an operation.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4