unordered_set bucket_count() in C++

bucket_count(): This function is available in the File: unordered_set.h

Syntax:

std::size_t std::unordered_set<int>::bucket_count() const.

This function returns the number of buckets of the unordered_set.

File: unordered_set.h

For Example:

st = {9,4}

st.bucket_count() = > It returns 3.

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    unordered_set<intst;
    st.insert(9);
    st.insert(4);

    cout << st.bucket_count() << "\n";

    return 0;
}

Output;

3

No comments:

Post a Comment