CK_RHS_GROW(3)

πŸ’– CK_RHS_GROW πŸ’–

okay bestie, you found the page for ck_rhs_grow, living in the Concurrency Kit (that's libck, link it with -lck 🫢). It's literally the glow-up button for your hash set's capacity. no cap.


✨ NAME ✨

ck_rhs_grow β€” enlarge hash set capacity πŸ’…

πŸ“š LIBRARY πŸ“š

Concurrency Kit (libck, -lck) β€” she's iconic, she's threaded, she's giving concurrency realness ✨

🌸 SYNOPSIS 🌸

#include <ck_rhs.h>

bool
ck_rhs_grow(ck_rhs_t *hs, unsigned long capacity);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the ck_rhs_grow(3) function resizes the hash set so it can hold at least the number of entries you passed in as capacity... at a load factor of one. yes, one. one whole. not a vibe, a number πŸ’€

the default hash set load factor is 0.5. that's the default, that's the norm, that's just how she lives.

now if you're a planner (main character energy, honestly πŸ‘‘) and you wanna minimize the likelihood of memory allocations for a hash set that's meant to store n entries β€” then specify a capacity of 2n. do the math, queen.

and one more lil thing: the default behavior of ck_rhs is to round capacity up to the next power of two if it's not already a power of two. it's a rounding girly, she simply must. πŸ”₯

πŸ’« RETURN VALUES πŸ’«

  • on success? ck_rhs_grow(3) returns true. slay. βœ…
  • otherwise? false on failure. 😭

πŸ’€ ERRORS πŸ’€

behavior is undefined if hs is uninitialized. i'm so serious. do not do that. that's not a vibe, that's a crash waiting to happen, periodt.

this function will only return false if there are internal memory allocation failures. that's the only reason. if you see false, blame the allocator, not her. πŸ™ˆ

πŸ‘€ SEE ALSO πŸ‘€

additional info available at http://concurrencykit.org/ 🌈


and that's the whole page, bestie β€” the Concurrency Kit source/version line and that September 17, 2012 date are the lil footer at the very bottom, so consider this your cute sign-off: she's been serving since 2012 and she's still got it. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from