public member function
<unordered_set>
std::unordered_multiset::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 that compare equal to k.If k does not match any element in the container, the range returned has end as both its lower and upper range bounds.
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
// unordered_multiset::equal_range
#include <iostream>
#include <string>
#include <unordered_set>
int main ()
{
std::unordered_multiset<std::string> myums =
{"cow","pig","pig","chicken","pig","chicken"};
auto myrange = myums.equal_range("pig");
std::cout << "These pigs were found:";
while ( myrange.first != myrange.second ) {
std::cout << " " << *myrange.first++;
}
std::cout << std::endl;
return 0;
}
These pigs were found: pig pig pig
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