This effectively reduces the container size by the number of elements removed, calling each element's destructor.
Parameters
- position
- Iterator pointing to a single element to be removed from the multimap.
iterator is a member type, defined as a bidirectional iterator type. - x
- Key value of the elements to be removed from the multimap.
key_type is a member type defined in multimap containers as an alias of Key, which is the first template parameter and the type of the elements' keys. - first, last
- Iterators specifying a range within the multimap container to be removed: [first,last). i.e., the range includes all the elements between first and last, including the element pointed by first but not the one pointed by last.
Return value
Only for the second version, the function returns the number of elements erased (which may be zero if x does not match any element in the container).Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
Output:
a => 10 b => 30 c => 40 |
Complexity
For the first version ( erase(position) ), amortized constant.For the second version ( erase(x) ), logarithmic in container size plus linear in number of element removed (destructors).
For the last version ( erase(first,last) ), logarithmic in container size plus linear in the distance between first and last.
See also
| multimap::clear | Clear content (public member function) |
| multimap::insert | Insert element (public member function) |
| multimap::find | Get iterator to element (public member function) |
