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
- Find the Deepest Node in a Binary Tree Using Queue STL - SET 2
- Kotlin mutableSetOf() method
- Kotlin Map : mapOf()
- Kotlin Set : setOf()
- Kotlin list : listOf()
- PHP | Imagick levelImage() Function
- Kotlin | apply vs with
- Kotlin Ranges
- What are the main differences between the Java platform and other platforms?
- How to place the image above the slider in mobile view in bootstrap?
- How to get the same behavior with confirm and bootstrap modal?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.