unordered_map max_bucket_count in C++ STL Last Updated : 14 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The unordered_map::max_bucket_count is a built in function in C++ STL. It returns the maximum number of buckets unordered_map container can have. Syntax unordered_map.max_bucket_count() Parameters : It does not accept any parameter. Return Type : Returns maximum number of buckets. Return type is an unsigned integer. Example-1: CPP // C++ program to illustrate the // unordered_map::max_bucket_count function #include <bits/stdc++.h> using namespace std; int main() { // declaration of unordered_map unordered_map<int, int> sample; cout << "Size is : " << sample.size() << endl; cout << "Max bucket count is : " << sample.max_bucket_count() << endl; // insert elements sample.insert({ 5, 10 }); sample.insert({ 10, 10 }); sample.insert({ 15, 10 }); sample.insert({ 20, 10 }); sample.insert({ 21, 10 }); cout << "Size is : " << sample.size() << endl; cout << "Max bucket count is : " << sample.max_bucket_count() << endl; return 0; } Output: Size is : 0 Max bucket count is : 1152921504606846975 Size is : 5 Max bucket count is : 1152921504606846975 Example-2: CPP // C++ program to illustrate the // unordered_map::max_bucket_count function #include <bits/stdc++.h> using namespace std; int main() { // declaration of unordered_map unordered_map<char, int> sample; cout << "Size is : " << sample.size() << endl; cout << "Max bucket count is : " << sample.max_bucket_count() << endl; // insert elements sample.insert({ 'a', 10 }); sample.insert({ 'b', 10 }); sample.insert({ 'c', 10 }); sample.insert({ 'd', 10 }); sample.insert({ 'e', 10 }); sample.insert({ 'f', 10 }); cout << "Size is : " << sample.size() << endl; cout << "Max bucket count is : " << sample.max_bucket_count() << endl; return 0; } Output: Size is : 0 Max bucket count is : 1152921504606846975 Size is : 6 Max bucket count is : 1152921504606846975 Complexity: Its Complexity is constant. Comment More infoAdvertise with us Next Article unordered_map max_bucket_count in C++ STL A ankit15697 Follow Improve Article Tags : C++ cpp-unordered_map cpp-unordered_map-functions Practice Tags : CPP Similar Reads unordered_map bucket() in C++ STL The unordered_map::bucket() is a built-in STL function in C++ which returns the bucket number where the element with the key k is located in the map. Syntax: size_type bucket(key) Parameter: The function accepts one mandatory parameter key which specifies the key whose bucket number is to be returne 1 min read 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 max_bucket_count() Function in Unordered Set C++ STL 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: Re 2 min read unordered_multimap max_bucket_count() function in C++ STL The unordered_multimap::max_bucket_count() is a built-in function in C++ STL which returns the maximum number of buckets that the unordered multimap container can have. This is the maximum it can have, it cannot exceed despite the collisions due to certain limitations on it. Syntax: unordered_multim 2 min read unordered_multimap bucket_count() function in C++ STL The unordered_multimap::bucket_count() is a built-in function in C++ STL which returns the total number of buckets in the unordered_multimap 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_multimap_name. 2 min read Like