CK_RHS_APPLY(3)

πŸ’– CK_RHS_APPLY(3) πŸ’–

okay bestie, welcome to the ck_rhs_apply(3) page β€” this is the Concurrency Kit one, and honestly? it's giving "let me just casually reach into a hash set and do a lil something to a value" ✨

🌸 NAME 🌸

ck_rhs_apply β€” apply a function to hash set value πŸ’…

πŸ“š LIBRARY πŸ“š

Concurrency Kit (libck, -lck) 🫢


✨ SYNOPSIS ✨

#include <ck_rhs.h>

void *
ck_rhs_apply_fn_t(void *key, void *closure);

bool
ck_rhs_apply(ck_rhs_t *hs, unsigned long hash, const void *key,
    ck_rhs_apply_fn_t *function, void *argument);

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea β˜• β€” ck_rhs_apply(3) goes and looks up the hash set slot that's associated with key, and then it hands that slot over to the function pointed to by function so it can do its lil thing πŸ”₯

and like, this callback is lowkey powerful: it can remove or replace the value. how? by returning NULL to remove it, or by returning a pointer to another object that has an identical key to replace it. iconic behaviour, no cap πŸ‘‘

the first argument that gets passed to function is a pointer to the object that was found in the hash set, and the second argument is the argument pointer that you passed in to ck_rhs_apply(3) itself. cute, right? πŸŽ€

and if the pointer that function returns is equivalent to that first argument? then literally nothing happens β€” no modification is made to the hash set. it's giving "we're good, no changes needed" πŸ™ˆ


🌈 RETURN VALUES 🌈

  • if it all goes well, ck_rhs_apply(3) returns true πŸ’–
  • otherwise it returns false on failure 😭

πŸ¦‹ SEE ALSO πŸ¦‹

go read these next bestie, they're all part of the same friend group:

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


and that's a wrap, babes πŸ’… this page is from September 1, 2014, and it's CK_RHS_APPLY(3) β€” slay, periodt βœ¨πŸŽ€πŸ’–

πŸ“¦ where this page comes from