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

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

🌸 NAME 🌸

okay so bestie, we're in the C++ Standard Libary manual (yes, that's the spelling on the page, iconic) and the header is std::unorde...ap::reserve(3). This function is std::unordered_multimap::reserve, and it's giving "make room for my elements" energy. πŸ’…

πŸ¦‹ Synopsis πŸ¦‹

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

bestie, what it does: sets the number of buckets to the number needed to accommodate at least count elements without exceeding maximum load factor and rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed. Effectively calls rehash(std::ceil(count / max_load_factor())).

πŸŽ€ Parameters πŸŽ€

  • count β€” new capacity of the container. That's the glow-up size, okay? ✨

✨ Return value ✨

(none) β€” literally nothing, no cap. It's a void function, so don't go looking for a return value, bestie. 🫢

πŸ”₯ Complexity πŸ”₯

Average case linear in the size of the container, worst case quadratic. So usually a smooth little linear slay, but worst case? quadratic, and we respect the warning. 😭

πŸ‘‘ See also πŸ‘‘

  • rehash β€” public member function that reserves at least the specified number of buckets and regenerates the hash table. The way it eats and leaves no crumbs. πŸ“

big kiss and a sparkle from the cppreference.com girlies β€” source http://cppreference.com, version/date 2024.06.10, and that's the whole footer vibe, periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from