std::unorde...imap::bucket(3)
π 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 π¦
- Returns the index of the bucket for key
key. Elements (if any) with keys equivalent tokeyare always found in this bucket. - Returns the index of the bucket for key that compares equivalent to the value
x. Elements (if any) with keys that compare equivalent toxare always found in this bucket. This overload participates in overload resolution only ifHash::is_transparentandKeyEqual::is_transparentare valid and each denotes a type. This assumes that suchHashis callable with bothKandKeytype, and that theKeyEqualis transparent, which, together, allows calling this function without constructing an instance ofKey.
Important vibe check: the returned value is valid only for instances of the container for whichbucket_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
- 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