multimap size() function in C++ STL
Last Updated :
12 Jun, 2023
The multimap::size() is a built-in function in C++ STL which returns the number of elements in the multimap container.
Syntax:
multimap_name.size()
Parameters: The function does not accept any parameter.
Return Value: This function returns the number of elements a multimap container has.
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
multimap< int , int > mp;
mp.insert({ 2, 30 });
mp.insert({ 1, 40 });
mp.insert({ 2, 60 });
mp.insert({ 2, 20 });
mp.insert({ 1, 50 });
mp.insert({ 4, 50 });
cout << "multimap mp has " << mp.size()
<< " number of elements" ;
return 0;
}
|
Output:
multimap mp has 6 number of elements
Time Complexity: O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...