public member function
<unordered_map>
std::unordered_multimap::equal_range
pair<iterator,iterator> equal_range ( const key_type& k );pair<const_iterator,const_iterator> equal_range ( const key_type& k ) const;
Get range of elements with specific key
If k does not match any key in the container, an empty range is returned (i.e., a pair where both its members
first and second compare equal).Parameters
- k
- Key value to be compared.
Member type key_type is the type of the keys for the elements in the container, defined in unordered_multimap as an alias of its first template parameter (Key).
Return value
The function returns a pair, where its member pair::first is an iterator to the lower bound of the range, and pair::second is an iterator to its upper bound. The elements in the range are those between these two iterators, including pair::first, but not pair::second.Member types
iterator and const_iterator are forward iterator types.Example
|
|
Output:
Entries with strawberry: LA OK
Complexity
Average case: constant.Worst case: linear in container size.
Iterator validity
No changes.See also
- unordered_multimap::count
- Count elements with a specific key (public member function)
- unordered_multimap::find
- Get iterator to element (public member function)
- unordered_multimap::begin
- Return iterator to beginning (public member type)