max_load_factor(): This function is available in the File: unordered_set.h. This function is a build-in function in STL of C++. This function returns (or set the max load factor value) a value to which the unordered_set load factor is less.
Approach 1: When the function does not take any argument.
Syntax:
float std::unordered_set<int>::max_load_factor() const
This functions returns a positive number that the unordered_set tries to keep the load factor less than or equal to.
File: unordered_set.h
C++
#include <bits/stdc++.h>using namespace std;int main(){unordered_set<int> st = {1, 2, 3, 4, 10, 23, 45};cout << st.max_load_factor() << "\n";return 0;}
Output:
1
Approach 2: When the function takes one argument.
Syntax:
void std::unordered_set<int>::max_load_factor(float __z)
This function takes one argument of type float as its parameter. This functions change the unordered_set maximum load factor to the new value.
Parameters: One parameter is required for this function.
__z – The new maximum load factor.
C++
#include <bits/stdc++.h>using namespace std;int main(){unordered_set<int> st = {1, 2, 3, 4, 10, 23, 45};float z = 0.45;st.max_load_factor(z);cout << "New load factor: " << st.max_load_factor() << "\n";return 0;}
Output:
New load factor: 0.45
No comments:
Post a Comment