名稱空間
變體
操作

std::unordered_multimap<Key,T,Hash,KeyEqual,Allocator>::max_bucket_count

來自 cppreference.com
 
 
 
 
size_type max_bucket_count() const;
(C++11 起)

返回容器由於系統或庫實現限制而能夠容納的最大桶數。

目錄

[編輯] 引數

(無)

[編輯] 返回值

最大桶數。

[編輯] 複雜度

常數時間。

[編輯] 示例

#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'
        ;
}

可能的輸出

Max bucket count of
c1: 0xfffffffffffffff
c2: 0xfffffffffffffff
c3: 0xfffffffffffffff
c4: 0xaaaaaaaaaaaaaaa

[編輯] 參閱

返回桶的數量
(public member function) [編輯]