![]() |
In C++, multimap stores key-value pairs and for the same key there can be multiple values in a multimap. In this article, we will learn how to delete a pair from a multimap in C++. Example Input: Remove a Pair from Multimap in C++To delete a pair from multimap, we can use the std::multimap::erase() function with a combination of std::find_if(). First, create a custom binary predicate function to pass to the find_if() function to check for the matching key-value pair and find the iterator using the find_if() function. Then remove the pair using erase() by passing the iterator in it. C++ Program to Delete a Pair from MultimapC++
Output
apple: 1 banana: 2 orange: 4 Time Complexity: O(N)
|
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |