std::unorde...ucket_count(3)
π NAME π
Hii bestie π this is the std::unorde...ucket_count(3) page from the C++ Standard Libary manual. The name section is doing that thing where it says it twice, so here it is, both times, untouched:
std::unordered_set::max_bucket_count-std::unordered_set::max_bucket_count
β¨ Synopsis β¨
Okay so the whole signature flex is:
size_type max_bucket_count() const; (since C++11)
It returns the maximum number of buckets the container is able to hold due to system or library implementation limitations. No cap, just implementation limits. π
πΈ Parameters πΈ
(none) β literally none, bestie. No arguments, no extra homework. π«Ά
π¦ Return value π¦
Maximum number of buckets. That's the whole return value. β¨
β Complexity β
Constant. Literally constant. It's giving very stable energy. π§
π₯ Example π₯
The page says // Run this code, so run it:
#include <iostream>
#include <unordered_set>
int main()
{
struct Ha { std::size_t operator()(long x) const { return
std::hash<long>{}(x); }; };
auto c1 = std::unordered_set<char>{};
auto c2 = std::unordered_set<long>{};
auto c3 = std::unordered_set<long, std::hash<int>>{};
auto c4 = std::unordered_set<long, Ha>{};
std::cout
<< "Max bucket count of\n" << std::hex << std::showbase
<< "c1: " << c1.max_bucket_count() << '\n'
<< "c2: " << c2.max_bucket_count() << '\n'
<< "c3: " << c3.max_bucket_count() << '\n'
<< "c4: " << c4.max_bucket_count() << '\n'
;
}
π Possible output π
Max bucket count of
c1: 0xfffffffffffffff
c2: 0xfffffffffffffff
c3: 0xfffffffffffffff
c4: 0xaaaaaaaaaaaaaaa
π See also π
bucket_countβ returns the number of buckets (public member function)
Bye bestie π«Ά β source/version: http://cppreference.com, date: 2024.06.10. π
π¦ 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