std::unorde...:equal_range(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– 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