The std::unordered_map::rehash() is a built in function C++ STL which which sets the number of buckets in container to n or more.
void rehash( size_type s );
- If s is greater than the current buckets into the container then rehashed is done. The new bucket count can be greater than or equal to n.
- If s is less than current bucket count then there may or may not be any effect of function. It totally depends upon compiler
Parameters : It takes New number of buckets into the container.
Return type : Its return type is none.
Size of container : 3 Initial bucket count : 5 Size of container : 3 Now bucket count is : 31
Size of container : 4 Initial bucket count : 7 Size of container : 4 Now bucket count is : 23
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- unordered_set rehash() function in C++ STL
- unordered_multimap rehash() function in C++ STL
- unordered_multiset rehash() function in C++ STL
- std::sort() in C++ STL
- Kruskal's Minimum Spanning Tree using STL in C++
- Dijkstra’s shortest path algorithm using set in STL
- Dijkstra's Shortest Path Algorithm using priority_queue of STL
- Prim's algorithm using priority_queue in STL
- unordered_map in C++ STL
- fill() and fill_n() functions in C++ STL
- std::transform() in C++ STL (Perform an operation on all elements)
- Count number of unique Triangles using STL | Set 1 (Using set)
- Permutations of a given string using STL
- Algorithm Library | C++ Magicians STL Algorithm
- Array algorithms in C++ STL (all_of, any_of, none_of, copy_n and iota)
- Iterators in C++ STL
- accumulate() and partial_sum() in C++ STL : numeric header
- std::partition in C++ STL
- Merge operations using STL in C++ | merge(), includes(), set_union(), set_intersection(), set_difference(), ., inplace_merge,
- Heap in C++ STL | make_heap(), push_heap(), pop_heap(), sort_heap(), is_heap, is_heap_until()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.