unordered_multiset load_factor() function in C++ STL Last Updated : 02 Aug, 2018 Comments Improve Suggest changes Like Article Like Report The unordered_multiset::load_factor() is a built-in function in C++ STL which returns returns the current load factor in the unordered_multiset 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. Syntax: unordered_multiset_name.load_factor Parameter: The function does no accepts any parameter. Return Value: The function returns the current load factor. It can be of integer or double type. Below programs illustrate the unordered_multiset::load_factor() function: Program 1: CPP // C++ program to illustrate the // unordered_multiset::load_factor() function #include <bits/stdc++.h> using namespace std; int main() { // declaration unordered_multiset<char> sample; // inserts element sample.insert('a'); sample.insert('b'); cout << "The size is: " << sample.size(); cout << "\nThe bucket_count is: " << sample.bucket_count(); cout << "\nThe load_factor is: " << sample.load_factor(); sample.insert('b'); sample.insert('b'); cout << "\n\nThe size is: " << sample.size(); cout << "\nThe bucket_count is: " << sample.bucket_count(); cout << "\nThe load_factor is: " << sample.load_factor(); sample.insert('z'); cout << "\n\nThe size is: " << sample.size(); cout << "\nThe bucket_count is: " << sample.bucket_count(); cout << "\nThe load_factor is: " << sample.load_factor(); return 0; } Output: The size is: 2 The bucket_count is: 3 The load_factor is: 0.666667 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 Program 2: CPP // C++ program to illustrate the // unordered_multiset::load_factor() function #include <bits/stdc++.h> using namespace std; int main() { // declaration unordered_multiset<int> sample; // inserts element sample.insert(1); sample.insert(1); cout << "The size is: " << sample.size(); cout << "\nThe bucket_count is: " << sample.bucket_count(); cout << "\nThe load_factor is: " << sample.load_factor(); sample.insert(1); sample.insert(2); cout << "\n\nThe size is: " << sample.size(); cout << "\nThe bucket_count is: " << sample.bucket_count(); cout << "\nThe load_factor is: " << sample.load_factor(); sample.insert(2); cout << "\n\nThe size is: " << sample.size(); cout << "\nThe bucket_count is: " << sample.bucket_count(); cout << "\nThe load_factor is: " << sample.load_factor(); return 0; } Output: The size is: 2 The bucket_count is: 3 The load_factor is: 0.666667 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 Comment More infoAdvertise with us Next Article unordered_multiset empty() function in C++STL G gopaldave Follow Improve Article Tags : Misc C++ STL CPP-Functions cpp-unordered_multiset +1 More Practice Tags : CPPMiscSTL Similar Reads Unordered Multiset in C++ STL In C++, unordered multiset is an unordered associative container that works similarly to an unordered set, but it can store multiple copies of the same value. It provides fast insert, delete and search operations using hashing, but the elements are not in any particular order.Example: C++#include 7 min read unordered_multiset begin() function in C++ STL The unordered_multiset::begin() is a built-in function in C++ STL which returns an iterator pointing to the first element in the container or to the first element in one of its bucket. Syntax: unordered_multiset_name.begin(n) Parameters: The function accepts one parameter. If a parameter is passed, 2 min read unordered_multiset end() function in C++ STL The unordered_multiset::end() is a built-in function in C++ STL which returns an iterator pointing to the position immediately after the last element in the container or to the position immediately after the last element in one of its bucket. Syntax: unordered_multiset_name.end(n) Parameters: The fu 2 min read unordered_multiset size() in C++ STL The size() method of unordered_multiset is used to count the number of elements of unordered_set it is called with. It takes the number of elements in the container and counts the number of elements. Syntax: size_type size() const; where size_type is an unsigned integral type. Return Value: This fun 1 min read unordered_multiset empty() function in C++STL The unordered_multiset::empty() is a built-in function in C++ STL which returns a boolean value. It returns true if the unordered_multiset container is empty. Otherwise, it returns false. Syntax: unordered_multiset_name.empty() Parameters: The function does not accepts any parameter. Return Value: I 2 min read unordered_multiset insert() function in C++ STL The unordered_multiset::insert() is a built-in function in C++ STL that inserts new elements in the unordered_multiset. This increases the container size. Also notice that elements with the same value are also stored as many times they are inserted. Syntax: Unordered_multiset_name.insert(element) Pa 2 min read unordered_multiset emplace() function in C++ STL The unordered_multiset::emplace() is a built-in function in C++ STL which inserts a new element in the unordered_multiset container. The insertion is done automatically at the position according to the container's criterion. It increases the size of the container by one. Syntax: unordered_multiset_n 2 min read unordered_multiset find() function in C++STL The unordered_multiset::find() is a built-in function in C++ STL which returns an iterator which points to the position which has the element val. If the element does not contain the element val, then it returns an iterator which points to a position past the last element in the container. Syntax: u 2 min read unordered_multiset erase() function in C++ STL The unordered_multiset::erase() function is a built-in function in C++ STL which is used to remove either a single element or, all elements with a definite value or, a range of elements ranging from start(inclusive) to end(exclusive). This decreases the size of the container by the number of element 2 min read unordered_multiset count() function in C++ STL The unordered_multiset::count() is a built-in function in C++ STL which returns the count of elements in the unordered_multiset container which is equal to a given value. Syntax: unordered_multiset_name.count(val) Parameters: The function accepts a single mandatory parameter val which specifies the 2 min read Like