multiset equal_range() function in C++ STL
The multiset::equal_range() is a built-in function in C++ STL which returns an iterator of pairs. The pair refers to the range that includes all the elements in the container which have a key equivalent to k. The lower bound will be the element itself and the upper bound will point to the next element after key k. If there are no elements matching key K, the range returned is of length 0 with both iterators pointing to the first element which is greater than k according to the container’s internal comparison object (key_comp). If the key exceeds the maximum element in the set container, it returns an iterator pointing to the past the last element in the multiset container.
Parameters: The function accepts one mandatory parameter key which specifies the key whose range in the multiset container is to be returned.
Return Value: The function returns an iterator of pair.
Below program illustrates the above function.
The multiset elements are: 1 2 3 3 3 5 5 6 The lower bound of 3 is 3 The upper bound of 3 is 5 The lower bound of 10 is 8 The upper bound of 10 is 8 The lower bound of 0 is 1 The upper bound of 0 is 1
The multiset elements are: 1 2 3 3 3 5 5 6 The lower bound of 3 is 3 The upper bound of 3 is 5 The multiset elements are: 1 2 5 5 6