std::unordered_map::rehash(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… std::unordered_map::rehash(3) β€” C++ Standard Libary bestie page ✨

okay so we're in the C++ Standard Libary manual, and this page is literally all about std::unordered_map::rehash(3). it's giving member-function main character energy, no cap 🫢

🌸 NAME 🌸

std::unordered_map::rehash β€” std::unordered_map::rehash πŸ’…

✨ Synopsis ✨

void rehash( size_type count );  (since C++11)

Changes the number of buckets to a value n that is not less than count and satisfies n >= size() / max_load_factor(), then rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed. periodt πŸ’–

πŸŽ€ Parameters πŸŽ€

  • count β€” lower bound for the new number of buckets. that's the whole assignment bestie πŸŽ€

πŸ¦‹ Return value πŸ¦‹

(none) β€” literally none, it's giving void energy πŸ’€

πŸ”₯ Complexity πŸ”₯

  • Average case: linear in the size of the container.
  • Worst case: quadratic. 😭

🌈 Notes 🌈

rehash(0) may be used to force an unconditional rehash, such as after suspension of automatic rehashing by temporarily increasing max_load_factor(). iconic little trick, iykyk 🌈

πŸ‘‘ See also πŸ‘‘

  • reserve β€” reserves space for at least the specified number of elements and regenerates the hash table (public member function). slay πŸ‘‘

mwah πŸ’– this page is from source/version http://cppreference.com, dated 2024.06.10 β€” byeee bestie, go rehash responsibly 🌸

πŸ“¦ where this page comes from