multimap clear() function in C++ STL
The multimap clear() function is an inbuilt function in C++ STL which is used to remove all elements from the multimap container (which are destroyed), leaving the container with a size of 0.
Syntax :
mymultimap_name.clear()
Parameters: This function does not take any arguments.
Return Value: This function does not returns anything. The return type of the function is void. It just empties the whole container.
Below program illustrate the multimap::clear() function in C++:
// CPP program to illustrate the // multimap::clear() function #include <cstring> #include <iostream> #include <map> using namespace std; int main() { // Creating multimap of string and int multimap<string, int> mymultimap; // Inserting 3 Items with their value // using insert function mymultimap.insert(pair<string, int>("Item1", 10)); mymultimap.insert(pair<string, int>("Item2", 20)); mymultimap.insert(pair<string, int>("Item3", 30)); cout << "Size of the multimap before using " << "clear function : "; cout << mymultimap.size() << '\n'; // Removing all the elements // present in the multimap mymultimap.clear(); cout << "Size of the multimap after using" << " clear function : "; cout << mymultimap.size() << '\n'; return 0; } |
Size of the multimap before using clear function : 3 Size of the multimap after using clear function : 0
Recommended Posts:
- multimap::crbegin() and multimap::crend() in C++ STL
- multimap::cbegin() and multimap::cend() in C++ STL
- multimap size() function in C++ STL
- multimap get_allocator() function in C++ STL
- multimap upper_bound() function in C++ STL
- multimap lower_bound() function in C++ STL
- multimap swap() function in C++ STL
- multimap empty() function in C++ STL
- multimap value_comp() function in C++ STL
- multimap::begin() and multimap::end() in C++ STL
- multiset clear() function in C++ STL
- unordered_multiset clear() function in C++ STL
- PHP | Imagick clear() Function
- unoredered_set clear() function in C++ STL
- unordered_multimap clear() 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.



