CK_HS_PUT(3)

✨ ck_hs_put(3) ✨

okay so bestie, welcome to CK_HS_PUT(3), the manual page for ck_hs_put β€” literally the "put this key in the hash set, but only if it's not already there" function πŸ’– it lives in the Concurrency Kit (that's libck, link it with -lck) and it's about to be your new fave, no cap.


🌸 NAME 🌸

ck_hs_put β€” store unique key into a hash set πŸŽ€


πŸ¦‹ LIBRARY πŸ¦‹

Concurrency Kit (that's libck, and you link it with -lck) πŸ’…


✨ SYNOPSIS ✨

#include <ck_hs.h>

bool
ck_hs_put(ck_hs_t *hs, unsigned long hash, const void *key);

πŸ’– DESCRIPTION πŸ’–

so the ck_hs_put(3) function is gonna store the key that you pass in as the key argument into the hash set that hs points at, periodt. and the key you hand over is expected to have the hash value you passed as the hash argument β€” which btw you should have already generated earlier with the CK_HS_HASH(3) macro. like, that's the whole vibe. πŸ”‘

if the call to ck_hs_put(3) went well, then congrats, the key you specified in key is now successfully chillin' inside the hash set that hs points to 🫢.

but bestie, listen β€” the function will fail if a key with a value equivalent to key is already present in the hash set. it does not replace, it does not overwrite, it simply says no 😭 if what you actually wanted was replacement semantics, go look at the ck_hs_set(3) function instead, iykyk.

⭐ RETURN VALUES ⭐

upon successful completion, ck_hs_put(3) returns true πŸ’… and otherwise it returns false on failure πŸ’€


🌈 ERRORS 🌈

behavior is undefined if key or hs are uninitialized πŸ™ˆ (like, not "it'll be fine" undefined, actually undefined, so don't).

the function will also return false if the hash set could not be enlarged to accomodate the key insertion 😭 (yes, "accomodate", that's how the original spells it and we respect the original's choices).


πŸ‘‘ SEE ALSO πŸ‘‘

additional information is available at http://concurrencykit.org/ 🌐


and that's the whole page, bestie!! this one's from the Concurrency Kit source, dated September 17, 2012, and it's filed under CK_HS_PUT(3) πŸŽ€ go put some unique keys in a hash set, you absolute icon πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from