std::unorde...iset::bucket(3)

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

okay bestie, this is std::unorde...iset::bucket(3) from the C++ Standard Libary β€” yes, the manual name up top literally says β€œLibary” πŸ’…. We're about to find the bucket index for a key, and it's giving useful-member-function energy.

✨ NAME ✨

The name is literally std::unordered_multiset::bucket - std::unordered_multiset::bucket β€” yes, twice, because the manual page said so πŸ’…. That's the whole vibe.

πŸ“œ Synopsis πŸ“œ

size_type bucket( const Key& key ) const; (1) (since C++11)
template< typename K >                    (2) (since C++26)
size_type bucket( const K& x ) const;
  1. Returns the index of the bucket for key key. Elements (if any) with keys equivalent to key are always found in this bucket.
  2. Returns the index of the bucket for key that compares equivalent to the value x. Elements (if any) with keys that compare equivalent to x are always found in this bucket. This overload participates in overload resolution only if Hash::is_transparent and KeyEqual::is_transparent are valid and each denotes a type. This assumes that such 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.

Heads up, bestie: the returned value is valid only for instances of the container for which bucket_count() returns the same value (e.g., rehash() invalidates previously obtained value). Also, the behavior is undefined if bucket_count() is zero. Do not play with that, periodt.

🧸 Parameters 🧸

  • key β€” the value of the key to examine.
  • x β€” a value of any type that can be transparently compared with a key.

🎁 Return value 🎁

Bucket index for the requested key. Slay.

⚑ Complexity ⚑

Constant. Literally constant, bestie β€” no hidden drama.

πŸ“ Notes πŸ“

Feature-test macro tea β˜•:

  • Feature-test macro: __cpp_lib_associative_heterogeneous_insertion
  • Value: 202311L
  • Std: (C++26)
  • Feature: Heterogeneous overloads for the remaining member functions in ordered and unordered associative containers. (2)

πŸ§ͺ Example πŸ§ͺ

This section is incomplete. Reason: no example. 😭 Not me showing up to an example section with no example.

πŸ‘€ See also πŸ‘€

  • bucket_size returns the number of elements in specific bucket (public member function)

🏷️ Category 🏷️

Category: * Todo no example


source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::unorde...iset::bucket(3) β€” bye bestie, go find that bucket πŸ’–

πŸ“¦ where this page comes from