multimap empty() function in C++ STL
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:
// C++ program to demonstrate // std::multimap::empty #include <iostream> #include <map> using namespace std; int main() { // declaring multimap multimap<char, int> mmap; // checking if mmap is empty or not if (mmap.empty()) cout << "multimap is empty\n"; // inserting values to mmap // thus making it non empty mmap.insert(pair<char, int>('a', 26)); mmap.insert(pair<char, int>('b', 30)); mmap.insert(pair<char, int>('c', 44)); // checking that mmap is now not empty if (mmap.empty()) cout << "multimap is empty\n"; else cout << "multimap is not empty\n"; return 0; } |
multimap is empty multimap is not empty
Recommended Posts:
- multimap get_allocator() function in C++ STL
- multimap clear() function in C++ STL
- multimap value_comp() function in C++ STL
- multimap upper_bound() function in C++ STL
- multimap size() function in C++ STL
- multimap lower_bound() function in C++ STL
- multimap swap() function in C++ STL
- multimap::crbegin() and multimap::crend() in C++ STL
- multimap::cbegin() and multimap::cend() in C++ STL
- multimap::begin() and multimap::end() in C++ STL
- unordered_multimap empty() function in C++ STL
- multiset empty() function in C++ STL
- unordered_multiset empty() function in C++STL
- unordered_set empty() function in C++ STL
- list empty() function in C++ STL
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.



