Last Updated : 11 Jul, 2025
The unordered_multiset::max_load_factor() is a built-in function in C++ STL which returns the maximum
load factorof the unordered_multiset container. This function also provides with an option of setting the maximum
load factor.
Syntax(To return the maximum load factor):
unordered_multiset_name.max_load_factor()Parameters:
The function does not accept any parameters.
Return Value:It returns an integral values which denotes the maximum load factor of the container. Below programs illustrate the unordered_multiset::max_load_factor() function:
Program 1:
CPP
// C++ program to illustrate
// unordered_multiset::max_load_factor()
#include <iostream>
#include <unordered_set>
using namespace std;
int main()
{
// declaration
unordered_multiset<char> s1;
s1 = { 'a', 'b', 'c', 'd' };
// displaying initial parameters
cout << "Current parameters are :\n";
cout << "max_load_factor= " << s1.max_load_factor() << endl;
cout << "load_factor= " << s1.load_factor() << endl;
cout << "size of s1= " << s1.size() << endl;
cout << "bucket_count= " << s1.bucket_count() << endl;
return 0;
}
Output:
Current parameters are : max_load_factor= 1 load_factor= 0.571429 size of s1= 4 bucket_count= 7Program 2
:
CPP
// c++ program to illustrate
// unordered_multiset::max_load_factor()
#include <iostream>
#include <unordered_set>
using namespace std;
int main()
{
// declaration
unordered_multiset<char> s1;
s1 = { 'a', 'b', 'c', 'd' };
// displaying initial parameters
cout << "Current parameters are :\n";
cout << "max_load_factor= " << s1.max_load_factor() << endl;
cout << "load_factor= " << s1.load_factor() << endl;
cout << "size of s1= " << s1.size() << endl;
cout << "bucket_count= " << s1.bucket_count() << endl;
// changing max_load_factor
s1.max_load_factor(0.5);
cout << endl;
// displaying final parameters
cout << "Final parameters are :\n";
cout << "max_load_factor= " << s1.max_load_factor() << endl;
cout << "load_factor= " << s1.load_factor() << endl;
cout << "size of s1= " << s1.size() << endl;
cout << "bucket_count= " << s1.bucket_count() << endl;
return 0;
}
Output:
Current parameters are : max_load_factor= 1 load_factor= 0.571429 size of s1= 4 bucket_count= 7 Final parameters are : max_load_factor= 0.5 load_factor= 0.235294 size of s1= 4 bucket_count= 17
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