The unordered_map::load_factor() is a built-in function in C++ STL which returns the current load factor in the unordered_map container. The load factor is the ratio between the number of elements in the container (its size) and the number of buckets (bucket_count):
load_factor = size / bucket_count
The load factor influences the probability of collision in the hash table (i.e., the probability of two elements being located in the same bucket). The container automatically increases the number of buckets to keep the load factor below a specific threshold (its max_load_factor), by causing a rehash each time when an expansion is needed.
Parameter: The function does not accept any parameter.
Return Value: The function returns the current load factor.
The size is: 4 The bucket_count is: 7 The load_factor is: 0.571429 The size is: 5 The bucket_count is: 7 The load_factor is: 0.714286 The size is: 6 The bucket_count is: 7 The load_factor is: 0.857143
The size is: 4 The bucket_count is: 7 The load_factor is: 0.571429 The size is: 6 The bucket_count is: 7 The load_factor is: 0.857143 The size is: 7 The bucket_count is: 17 The load_factor is: 0.411765
- Minimum cells to be flipped to get a 2*2 submatrix with equal elements
- CSS | fit-content() Property
- How to change the placeholder text using jQuery?
- Laravel | Route::resource vs Route::controller
- Python - Call function from another function
- Python - Initialize empty array of given length
- Ruby Static Members
- Node.js | Buffers
- Node.js | Console
- Node.js | Callback Concept
- Node.js | First Application
- Nested Loops in C++ with Examples
- _Find_first() function in C++ bitset with Examples
- _Find_next() function in C++ bitset with Examples
- Data Abstraction in Ruby
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.