The unordered_set::bucket() method is a builtin function in C++ STL which returns the bucket number of a specific element. That is, this function returns the bucket number where a specific element is stored in the unordered_set container.
The bucket is a slot in the unordered_set’s internal hash table where elements are stored.
Note: Buckets in unordered_set are numbered from 0 to n-1, where n is the total number of buckets.
Parameter: This is a mandatory parameter and specifies the value of the element whose bucket number is needed to know in the unordered_set container.
Return Value: This function returns the bucket number of the bucket in the unordered_set container where the element with value element is stored.
Below programs illustrate the unordered_set::bucket() function:
The Element 25 is present in the bucket: 3 The Element 5 is present in the bucket: 5 The Element 10 is present in the bucket: 10 The Element 15 is present in the bucket: 4 The Element 20 is present in the bucket: 9
- unordered_multiset bucket() function in C++ STL
- unordered_multimap bucket() function in C++ STL
- unordered_map bucket() in C++ STL
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- What happens when a virtual function is called inside a non-virtual function in C++
- Difference between Virtual function and Pure virtual function in C++
- exp() function C++
- log() function in C++
- div() function in C++
- fma() function in C++
- bit_and function in C++
- mbsinit() Function in C/C++
- lldiv() function in C++ STL
- iswctype() function in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.