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
- Node.js | util.types.isWeakSet() Method
- Node.js | Buffer.writeInt16BE() Method
- Node.js | util.types.isMap() Method
- Node.js | util.types.isWeakMap() Method
- Node.js | util.types.isMapIterator() Method
- Node.js | util.types.isBooleanObject() Method
- Node.js | util.types.isSetIterator() Method
- cin get() in C++ with Examples
- Difference between Increment and Decrement Operators
- What is the difference between (NaN != NaN) & (NaN !== NaN)?
- PHP | Unset Session Variable
- Building App For Google Assistant Without Any Coding
- Map of Vectors in C++ STL with Examples
- Problem in comparing Floating point numbers and how to compare them correctly?
- exit(0) vs exit(1) in C/C++ 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 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.