std::unordered_set::bucket(3)
π std::unordered_set::bucket π
okay so welcome to the std::unordered_set::bucket(3) page from the C++ Standard Libary β yes bestie, that's the manual name, and we're about to make bucket indexes make sense. π«Άβ¨
πΈ NAME πΈ
std::unordered_set::bucket - std::unordered_set::bucket
It's giving βthe name section just names it twice,β and honestly? iconic. π
β¨ Synopsis β¨
okay so here's the synopsis, overloads and all:
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. π«Ά
β οΈ 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). So don't be out here storing it forever, bestie. π
π The behavior is undefined if bucket_count() is zero. That's a hard no, fr fr.
π 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. That's the whole vibe. π
β Complexity β
Constant. β‘
π§ Notes π§
The feature-test macro is giving:
__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 crying over the missing example
π See also π
bucket_sizeβ returns the number of elements in specific bucket (public member function). π
π Category π
* Todo no example
π cute sign-off: source/version http://cppreference.com, date 2024.06.10, page std::unordered_set::bucket(3) β bye bestie, go slay those buckets! πβ¨
π¦ 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