CK_RHS_PUT_UNIQUE(3)

πŸ’– ck_rhs_put_unique β€” the "no dupes allowed" hash set baddie πŸ’–

ok bestie, welcome to ck_rhs_put_unique(3) β€” it's giving main character energy from the Concurrency Kit (that's libck, and you link it with -lck, iykyk). This one stores a key in a hash set and it is unconditionally doing it, no thoughts, no checking, no chill. πŸ¦‹


✨ SYNOPSIS ✨

#include <ck_rhs.h>

bool
ck_rhs_put_unique(ck_rhs_t *hs, unsigned long hash, const void *key);

🌸 DESCRIPTION 🌸

so the way that ck_rhs_put_unique(3) works is: it stores the key you pass in key into the hash set that hs is pointing at. periodt. πŸ’…

and listen β€” the key you hand over is expected to have the hash value you passed as hash. That hash? You already generated it earlier with the CK_RHS_HASH(3) macro. Don't skip that step bestie, it's literally the whole vibe. πŸŽ€

If the call to ck_rhs_put(3) succeeded, then yes β€” your key is officially in the hash set pointed to by hs, slay. 🫢

⚠️ BUT. If a key with an equivalent value is already in the hash set, this function causes undefined behavior. Not a vibe. Not a warning. Just chaos. πŸ’€

If you wanted replacement semantics β€” like, swap the old one out, new one in β€” that's a whole different girl, go look at ck_rhs_set(3) instead. πŸ™ˆ


πŸ”₯ RETURN VALUES πŸ”₯


πŸ’€ ERRORS πŸ’€

  • If key or hs are uninitialized β†’ undefined behavior. Please initialize your stuff, I am begging. πŸ₯Ί
  • The function will also return false if the hash set could not be enlarged to accommodate the insertion of key. (yes, it tried to grow for you, it's an icon, it just couldn't)
  • If you call this for a key value that's already been inserted β†’ undefined behavior. again. it's giving "I warned you." πŸ’…

🌈 SEE ALSO 🌈

the whole friend group, go say hi:

and if you want even more lore, the info is available at http://concurrencykit.org/ ⭐


ok that's the whole page bestie, you ate that πŸ“ this was CK_RHS_PUT_UNIQUE(3), dated December 7, 2013, brought to you by the Concurrency Kit girlies. go forth and store those unique keys, but fr fr β€” no duplicates. mwah. πŸ’–βœ¨πŸ§š

πŸ“¦ where this page comes from