std::unorde...:equal_range(3)
π NAME
okay so welcome to the C++ Standard Library manual, bestie β this page is all about std::unordered_set::equal_range. The NAME line is literally:
std::unordered_set::equal_range - std::unordered_set::equal_range
and yeah, it said what it said twice. iconique. π
πΈ Synopsis
Here are the overloads exactly as the page lays them out β line wraps and all, don't come for me:
std::pair<iterator, iterator> equal_range( const Key& key );
(1) (since C++11)
std::pair<const_iterator, const_iterator> equal_range( const Key&
(2) (since C++11)
key ) const;
template< class K >
(3) (since C++20)
std::pair<iterator, iterator> equal_range( const K& x );
template< class K >
std::pair<const_iterator, const_iterator> equal_range( const K& x
(4) (since C++20)
) const;
So what's the tea? π«
Overloads 1,2) return a range containing all elements with key key in the container. That range is defined by two iterators: the first points to the first element of the wanted range, and the second points past the last element of the range. classic iterator duo energy β¨
Overloads 3,4) return a range containing all elements in the container with key equivalent to x. This overload participates in overload resolution only if Hash::is_transparent and KeyEqual::is_transparent are valid and each denotes a type. It assumes that such a Hash is callable with both K and Key type, and that the KeyEqual is transparent, which, together, allows calling this function without constructing an instance of Key. no cap, that's the whole transparency moment π¦
β¨ Parameters
keyβ key value to compare the elements to.xβ a value of any type that can be transparently compared with a key.
π Return value
A std::pair containing a pair of iterators defining the wanted range. If there are no such elements, past-the-end (see end()) iterators are returned as both elements of the pair. so you get a little "nothing here" signal, not a whole crisis π
π₯ Complexity
Average case: linear in the number of elements with the key key. Worst case: linear in the size of the container. fr fr, know the difference π
π¦ Notes
The page drops a feature-test macro table. Here's the whole vibe:
- Feature-test macro:
__cpp_lib_generic_unordered_lookup - Value:
201811L - Std:
(C++20) - Feature: Heterogeneous comparison lookup in unordered associative containers, overloads
(3,4)
π Example
This section is incomplete. Reason: no example. π
the audacity, honestly.
π See also
findβ finds element with specific key (public member function)containsβ checks if the container contains element with specific key (C++20) (public member function)countβ returns the number of elements matching specific key (public member function)equal_rangeβ returns range of elements matching a specific key (function template)
π·οΈ Category
* Todo no example
Source/version: http://cppreference.com Β· date: 2024.06.10 Β· page vibe: std::unorde...:equal_range(3) β okay bye bestie, go get that range πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms