std::unorde...ucket_count(3)

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

πŸŽ€ 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