public member function
<unordered_set>

std::unordered_set::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 a specific key
Returns the bounds of a range that includes all the elements that compare equal to k. In unordered_set containers, where keys are unique, the range will include one element at most.

If k does not match any element in the container, the range returned has end as both its lower and upper range bounds.

All iterators in an unordered_set have const access to the elements (even those whose type is not prefixed with const_): Elements can be inserted or removed, but not modified while in the container.

Parameters

k
Value to be compared.
Member type key_type is the type of the elements in the container. In unordered_set containers it is the same as value_type, defined as an alias of the class's 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. Both may be aliases of the same iterator type.

Example

See unordered_multiset::equal_range.

Complexity

Average case: constant.
Worst case: linear in container size.

Iterator validity

No changes.

See also

  • 9316991614 2018-02-25
  • 191841613 2018-02-25
  • 16411612 2018-02-25
  • 6081981611 2018-02-25
  • 1784561610 2018-02-25
  • 4651609 2018-02-25
  • 9348111608 2018-02-25
  • 2513771607 2018-02-25
  • 6478461606 2018-02-24
  • 4985791605 2018-02-24
  • 5637141604 2018-02-24
  • 282181603 2018-02-24
  • 6217941602 2018-02-24
  • 5076141601 2018-02-24
  • 714281600 2018-02-24
  • 6607141599 2018-02-24
  • 949041598 2018-02-24
  • 6809961597 2018-02-24
  • 671871596 2018-02-24
  • 7107821595 2018-02-24