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

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

πŸ’– NAME πŸ’–

okay so this page is std::unordered_multimap::bucket β€” the header shows it as std::unorde...imap::bucket(3), and it's from the C++ Standard Libary manual. bestie, we're checking which bucket a key lands in, and the vibes are very C++. πŸ’…


✨ 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;

Overload (1) is the classic since C++11. Overload (2) is the newer template one since C++26. πŸŽ€

πŸ¦‹ DESCRIPTION πŸ¦‹

  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.
Important vibe check: 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).
fr fr undefined behavior alert: the behavior is undefined if bucket_count() is zero. do not.

🌸 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. periodt. ✨

πŸ’œ Complexity πŸ’œ

Constant. no cap, constant.

πŸ‘‘ 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.
  • This note is for overload (2).

πŸ“ Example πŸ“

This section is incomplete
Reason: no example

bestie the example section is literally incomplete 😭

🌈 See also 🌈

  • bucket_size β€” returns the number of elements in specific bucket (public member function).

Category: * Todo no example


okay that's the whole page, ily πŸ’– source: http://cppreference.com β€” date: 2024.06.10 β€” page: std::unorde...imap::bucket(3).

πŸ“¦ where this page comes from