VOOZH about

URL: https://www.geeksforgeeks.org/cpp/unordered_multimap-bucket_count-function-in-c-stl/

⇱ unordered_multimap bucket_count() function in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

unordered_multimap bucket_count() function in C++ STL

Last Updated : 8 Aug, 2018
The unordered_multimap::bucket_count() is a built-in function in C++ STL which returns the total number of buckets in the unordered_multimap container. A bucket is a slot in the container's internal hash table to which elements are assigned based on their hash value. Syntax:
unordered_multimap_name.bucket_count()
Parameters: The function does not accept any parameter. Return Value: It returns an unsigned integral type which denotes the total count of buckets. Below programs illustrate the above function: Program 1:
Output:
The total count of buckets: 7
Bucket 0: empty
Bucket 1: {15, 150}, 
Bucket 2: {30, 300}, 
Bucket 3: {10, 100}, {10, 100}, 
Bucket 4: empty
Bucket 5: empty
Bucket 6: {20, 200},
Program 2:
Output:
The total count of buckets: 7
Bucket 0: {b, c}, 
Bucket 1: {c, b}, 
Bucket 2: {r, a}, 
Bucket 3: empty
Bucket 4: empty
Bucket 5: empty
Bucket 6: {a, b}, {a, b},
Comment