Skip to content
Related Articles

Related Articles

unordered_multiset max_size in C++ STL
  • Last Updated : 04 Oct, 2018

The max_size() of unordered_multiset takes the maximum number of elements that the unordered_multiset container is able to hold due to system or It gets the maximum size of the controlled sequence.


size_type max_size() const;

where size_type is an unsigned integral type.

Returns : The member function returns the length of the longest sequence that the object can hold. In short, the maximum number of elements.

Below program illustrate the unordered_multiset max_size function :-

Example 1:

#include <iostream>
#include <unordered_set>
using namespace std;
int main()
    // Define the unordered_set
    unordered_multiset<int> num{ 1, 2, 3, 4, 5, 6 };
    cout << "Maximum size = "
         << num.max_size() << "\n";
    cout << "Current size = "
         << num.size();
    return 0;
Maximum size = 1152921504606846975
Current size = 6

Complexity :
It takes constant(O(1)) time of complexity to perform an operation.

Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up
Recommended Articles
Page :