max_bucket_count() Function in Unordered Set C++ STL Last Updated : 27 Nov, 2022 Comments Improve Suggest changes Like Article Like Report Prerequisite: unordered_set() in C++ The max_bucket_count() is the built-in function defined in C++ STL. This function returns the maximum number of buckets that the Unordered Set is able to hold. Syntax: unordered_set.max_bucket_count(); Parameters: It does not accept any parameter. Return Type: Returns the maximum number of buckets. Time Complexity: It takes constant time. Let's see with multiple examples: Example: C++ // C++ program to illustrate the // unordered_set::max_bucket_count function #include <bits/stdc++.h> using namespace std; int main() { // declaration of unordered_set unordered_set<int> s; cout << "Size is : " << s.size() << endl; cout << "Max bucket count is : " << s.max_bucket_count() << endl; // insert elements s.insert(5); s.insert(10); s.insert(15); s.insert(20); s.insert(25); cout << "Size is : " << s.size() << endl; cout << "Max bucket count is : " << s.max_bucket_count() << endl; return 0; } OutputSize is : 0 Max bucket count is : 1152921504606846975 Size is : 5 Max bucket count is : 1152921504606846975 Example: C++ // C++ program to illustrate the // unordered_set::max_bucket_count function #include <bits/stdc++.h> using namespace std; int main() { // declaration of unordered_set unordered_set<string> s; cout << "Size is : " << s.size() << endl; cout << "Max bucket count is : " << s.max_bucket_count() << endl; // insert elements s.insert("geeks"); s.insert("for"); s.insert("geeks"); cout << "Size is : " << s.size() << endl; cout << "Max bucket count is : " << s.max_bucket_count() << endl; return 0; } OutputSize is : 0 Max bucket count is : 768614336404564650 Size is : 2 Max bucket count is : 768614336404564650 Comment More infoAdvertise with us Next Article unordered_multiset max_bucket_count() function in C++ STL P pushpeshrajdx01 Follow Improve Article Tags : Technical Scripter C++ Technical Scripter 2022 STL cpp-unordered_set +1 More Practice Tags : CPPSTL Similar Reads unordered_set max_bucket_count() function in C++ STL 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. Para 2 min read unordered_set bucket_count() function in C++ STL The unordered_set::bucket_count() method is a builtin function in C++ STL which returns the total number of buckets present in an unordered_set container. The bucket is a slot in the unordered_set's internal hash table where elements are stored. Note: Buckets in unordered_set are numbered from 0 to 2 min read unordered_multiset max_bucket_count() function in C++ STL The unordered_multiset::max_bucket_count() is a built-in function in C++ STL which returns the maximum number of buckets that the unordered multiset container can have. This is the maximum it can have, it cannot exceed despite the collisions due to certain limitations on it. Syntax: unordered_multis 1 min read unordered_multiset max_bucket_count() function in C++ STL The unordered_multiset::max_bucket_count() is a built-in function in C++ STL which returns the maximum number of buckets that the unordered multiset container can have. This is the maximum it can have, it cannot exceed despite the collisions due to certain limitations on it. Syntax: unordered_multis 1 min read unordered_multiset bucket_count() function in C++ STL The unordered_multiset::bucket_count() is a built-in function in C++ STL which returns the total number of buckets in the unordered_multiset container. A bucket is a slot in the container's internal hash table to which elements are assigned based on their hash value. Syntax: unordered_multiset_name. 2 min read unordered_multiset bucket_count() function in C++ STL The unordered_multiset::bucket_count() is a built-in function in C++ STL which returns the total number of buckets in the unordered_multiset container. A bucket is a slot in the container's internal hash table to which elements are assigned based on their hash value. Syntax: unordered_multiset_name. 2 min read Like