public member function
<unordered_map>
std::unordered_multimap::equal_rangepair<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
Returns the bounds of a range that includes all the elements in the container with a key that compares equal to k.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).
Member types iterator and const_iterator are forward iterator types.
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
// unordered_multimap::equal_range
#include <iostream>
#include <string>
#include <unordered_map>
#include <algorithm>
typedef std::unordered_multimap<std::string,std::string> stringmap;
int main ()
{
stringmap myumm = {
{"orange","FL"},
{"strawberry","LA"},
{"strawberry","OK"},
{"pumpkin","NH"}
};
std::cout << "Entries with strawberry:";
auto range = myumm.equal_range("strawberry");
for_each (
range.first,
range.second,
[](stringmap::value_type& x){std::cout << " " << x.second;}
);
return 0;
}
Entries with strawberry: LA OK
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4