The unordered_map::max_load_factor in C++ STL is a built in function which is used to get and set maximum load factor in unordered_map. Load factor is the ratio between number of elements in container and number of buckets. By default unordered_map max_load factor is 1.0.
Syntax: There are two type of functions for max_load_factor.
- float max_load_factor()
- void max_load_factor(float new_size)
Return type: Only first version returns max_load_factor.
Parameter: Only second version accept new size.
- First version return maximum load factor.
- Second version sets new load factor.
Current size is : 6 Current load factor is : 0.857143 Current Max load factor is 1 Current size is : 6 Current load factor is : 0.857143 Current Max load factor is 2.5
Current size is : 4 Current load factor is : 0.571429 Current Max load factor is 1 Current size is : 4 Current load factor is : 0.571429 Current Max load factor is 2.5
Complexity : O(1).
- Minimum cells to be flipped to get a 2*2 submatrix with equal elements
- Nested Loops in C++ with Examples
- _Find_first() function in C++ bitset with Examples
- _Find_next() function in C++ bitset with Examples
- Left-Right traversal of all the levels of N-ary tree
- Difference between Iterators and Pointers in C/C++ with Examples
- ostream::seekp(pos) method in C++ with Exmaples
- Default Methods in C++ with Examples
- C++ Tutorial
- Hello World Program : First program while learning Programming
- Difference between Argument and Parameter in C/C++ with Examples
- <cfloat> float.h in C/C++ with Examples
- C/C++ #include directive with Examples
- C/C++ if else statement with Examples
- C/C++ if statement with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.