CK_RHS_PUT(3)

πŸ’– CK_RHS_PUT(3) πŸ’–

okay bestie, welcome to the CK_RHS_PUT(3) page, aka the "put ONE unique key in the hash set and do not be weird about it" function πŸ’…


✨ NAME ✨

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

πŸ“š LIBRARY πŸ“š

Concurrency Kit, aka libck, and you link it with -lck πŸ”₯

🧚 SYNOPSIS 🧚

#include <ck_rhs.h>

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

🌸 DESCRIPTION 🌸

so the way that ck_rhs_put(3) works is: it stores the key you hand it in the key argument into the hash set that hs points at πŸ’–

and here's the thing, the key you pass in is expected to already have the hash value you're passing as the hash argument. and where did that hash come from? you generated it earlier with the CK_RHS_HASH(3) macro. no cap. πŸ‘‘

if the call to ck_rhs_put(3) went through successfully, then yep, your key is now living in the hash set pointed to by hs ✨

but it WILL fail if a key with an equivalent value to key is already chillin' in the hash set. it's a unique key situation, bestie, the set is not accepting duplicates πŸ™ˆ

want replacement semantics instead? like, overwrite the old one? that's a whole different function, go look at ck_rhs_set(3) 🫢

⭐ RETURN VALUES ⭐

  • on success, ck_rhs_put(3) returns true πŸ’–
  • otherwise it returns false, which is the failure case 😭

πŸ’€ ERRORS πŸ’€

behavior is undefined if key or hs are uninitialized. like, unhinged behavior. do not do this. 🚨

the function will also return false if the hash set could not be enlarged to accommodate the insertion of key. sometimes the set just can't grow, and it's not you, it's the allocation πŸ’”

πŸ‘‘ SEE ALSO πŸ‘‘

more info? it's literally at http://concurrencykit.org/ 🌈


sign-off time πŸŽ€ this page came out of the Concurrency Kit (libck) era, dated September 17, 2012, and it's CK_RHS_PUT(3) β€” go forth and store those unique keys, bestie, iykyk πŸ’œ

πŸ“¦ where this page comes from