Przejdź do głównej zawartości

std::unordered_multimap max_bucket_count() method

// Const version only
size_type max_bucket_count() const;

Returns the maximum number of buckets the container is able to hold due to system or library implementation limitations.

Parameters

(none)

Return value

Maximum number of buckets.

Complexity

Constant - O(1).

Exceptions

(none)

Example

#include <iostream>
#include <unordered_map>

int main()
{
struct Ha { std::size_t operator()(long x) const { return std::hash<long>{}(x); }; };

auto c1 = std::unordered_multimap<char, long>{};
auto c2 = std::unordered_multimap<long, long>{};
auto c3 = std::unordered_multimap<long, long, std::hash<int>>{};
auto c4 = std::unordered_multimap<long, 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
This article originates from this CppReference page. It was likely altered for improvements or editors' preference. Click "Edit this page" to see all changes made to this document.
Hover to see the original license.

std::unordered_multimap max_bucket_count() method

// Const version only
size_type max_bucket_count() const;

Returns the maximum number of buckets the container is able to hold due to system or library implementation limitations.

Parameters

(none)

Return value

Maximum number of buckets.

Complexity

Constant - O(1).

Exceptions

(none)

Example

#include <iostream>
#include <unordered_map>

int main()
{
struct Ha { std::size_t operator()(long x) const { return std::hash<long>{}(x); }; };

auto c1 = std::unordered_multimap<char, long>{};
auto c2 = std::unordered_multimap<long, long>{};
auto c3 = std::unordered_multimap<long, long, std::hash<int>>{};
auto c4 = std::unordered_multimap<long, 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
This article originates from this CppReference page. It was likely altered for improvements or editors' preference. Click "Edit this page" to see all changes made to this document.
Hover to see the original license.