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 function returns the length of the controlled sequence or in short, it returns the number of elements in the container.

Below program illustrate the unordered_multiset size() function :-



Example :

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
#include <unordered_set>
  
using namespace std;
  
int main()
{
  
    // Define the unordered_set
    unordered_multiset<int> numbers{ 1, 2, 3, 4, 5, 6 };
  
    // Calculate and print
    // the size of the unordered_multiset
    cout << "The container has "
         << numbers.size()
         << " elements in it";
}

chevron_right


Output:

The container has 6 elements in it

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



My Personal Notes arrow_drop_up

2nd year student of Information Technology JADAVPUR UNIVERSITY

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.