std::unorde...iset::bucket(3)
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;
- 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.
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_sizereturns 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
- 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