std::unorde...set::reserve(3)

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

πŸ’– NAME πŸ’–

std::unordered_set::reserve β€” std::unordered_set::reserve

okay so this is the <pink>C++ Standard Libary</pink> manual page for std::unordered_set::reserve(3), and it's literally giving bucket-management main character energy. πŸ’…βœ¨


✨ Synopsis ✨

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

It sets the number of buckets to the number needed to accommodate at least count elements without exceeding the maximum load factor, then rehashes the container β€” aka it puts the elements into appropriate buckets considering that the total number of buckets has changed. 🫢

Effectively calls rehash(std::ceil(count / max_load_factor())). No cap. πŸ’«

πŸŽ€ Parameters πŸŽ€

  • count β€” new capacity of the container. that's the whole parameter, bestie πŸŽ€

πŸ’… Return value πŸ’…

(none) β€” no return value, she just does the thing and dips πŸ™ˆ

πŸ”₯ Complexity πŸ”₯

  • Average case: linear in the size of the container πŸ”₯
  • Worst case: quadratic πŸ’€

πŸ¦‹ See also πŸ¦‹

  • rehash β€” reserves at least the specified number of buckets and regenerates the hash table (public member function) πŸ¦‹

that's the whole page, bestie πŸ’– source: http://cppreference.com Β· version/date: 2024.06.10 Β· std::unordered_set::reserve(3) outtieee 🫢✨

πŸ“¦ where this page comes from