multimap empty() function in C++ STL
Last Updated :
12 Jun, 2023
The multimap::empty() is a boolean type observer function in C++ STL which tells whether the container is empty or not. This function returns true when the multimap container is empty (i.e. the size of the container is 0). Being an observer function it does not modify the multimap in any way.
Syntax:
multimap1.empty()
Return Value: This method returns a boolean type value. It returns true when multimap is empty else returns false.
Below program illustrate the multimap::empty() function:
CPP
#include <iostream>
#include <map>
using namespace std;
int main()
{
multimap< char , int > mmap;
if (mmap.empty())
cout << "multimap is empty\n" ;
mmap.insert(pair< char , int >( 'a' , 26));
mmap.insert(pair< char , int >( 'b' , 30));
mmap.insert(pair< char , int >( 'c' , 44));
if (mmap.empty())
cout << "multimap is empty\n" ;
else
cout << "multimap is not empty\n" ;
return 0;
}
|
Output:
multimap is empty
multimap is not empty
Time Complexity : O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...