VOOZH about

URL: https://www.geeksforgeeks.org/cpp/unordered_multiset-bucket_size-function-in-c-stl/

⇱ unordered_multiset bucket_size() function in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

unordered_multiset bucket_size() function in C++ STL

Last Updated : 2 Aug, 2018
The unordered_multiset::bucket_size() is a built-in function in C++ STL which returns the number of elements in the bucket which has the element val. It will always be lower than the bucket_count. The number of elements in a bucket influences the time it takes to access a particular element in the bucket Syntax:
unordered_multiset_name.bucket_size(val)
Parameters: The function accepts a parameter val which specifies the element whose size of the bucket is to be returned. Return Value: It returns an unsigned integral type which denotes the number of elements in the bucket which has the element val. Below programs illustrate the above function: Program 1:
Output:
The bucket size in which 14 is 1
The bucket size in which 11 is 3
The bucket size in which 11 is 3
The bucket size in which 11 is 3
The bucket size in which 12 is 1
The bucket size in which 13 is 2
The bucket size in which 13 is 2
Program 2:
Output:
The bucket size in which 1 is 3
The bucket size in which 1 is 3
The bucket size in which 1 is 3
The bucket size in which 2 is 1
The bucket size in which 3 is 2
The bucket size in which 3 is 2
The bucket size in which 4 is 1
Comment