CK_HS_APPLY(3)
π ck_hs_apply β apply a function to hash set value π
okay so bestie, this is ck_hs_apply(3) from the Concurrency Kit, and it lives in libck β you link it with -lck. that's literally it. it's giving "tiny function, huge power" energy and i'm obsessed π«Ά
β¨ LIBRARY β¨
Concurrency Kit (libck, -lck) β yeah you're gonna want to pass -lck to your linker or none of this slays π
πΈ SYNOPSIS πΈ
so here's the tea, this is exactly what you write:
#include <ck_hs.h>
void *
ck_hs_apply_fn_t(void *key, void *closure);
bool
ck_hs_apply(ck_hs_t *hs, unsigned long hash, const void *key,
ck_hs_apply_fn_t *function, void *argument);
like, look at that callback signature. void * in, void * out. main character energy fr fr π
π DESCRIPTION π
okay so real talk. ck_hs_apply(3) goes and looks up the hash set slot associated with key, and then hands it straight to the function pointed to by function so it can do whatever it wants with it. like a little handoff. a relay race. passing the baton πβοΈβ¨
and here's the spicy part: that callback is allowed to remove or replace the value. how? by returning NULL (that's the removal arc, bye bestie π) or by returning a pointer to another object that has an identical key (that's the glow-up arc β¨). either way, the callback is the one making the call.
so, the arguments your function gets:
- the first argument is a pointer to the object that was found in the hash set. that's your target, your found item, your moment πΈ
- the second argument is the argument pointer that got passed into
ck_hs_apply(3). yes, it just gets forwarded straight through to you. convenient!
and one lil detail that matters a lot: if the pointer your function returns is equivalent to the first argument, then no modification is made to the hash set. nothing happens. the set stays exactly as it was. no cap, it just shrugs and moves on π
π RETURN VALUES π
- success β
ck_hs_apply(3)returnstrueπ - failure β
ck_hs_apply(3)returnsfalseπ
that's the whole vibe check. true or false, no in-between, no crumbs.
π SEE ALSO π
the whole girlies of the hash set family, go read them too:
ck_hs_init(3)ck_hs_move(3)ck_hs_destroy(3)ck_hs_fas(3)CK_HS_HASH(3)ck_hs_iterator_init(3)ck_hs_next(3)ck_hs_get(3)ck_hs_put(3)ck_hs_put_unique(3)ck_hs_remove(3)ck_hs_grow(3)ck_hs_rebuild(3)ck_hs_gc(3)ck_hs_count(3)ck_hs_reset(3)ck_hs_reset_size(3)ck_hs_stat(3)
and if you want even more, there's Additional information available at http://concurrencykit.org/ π
kisses, this page is from September 1, 2014, it's CK_HS_APPLY(3), and that's the whole manual bestie β go apply some functions πβ¨π¦
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- debian bookworm: libck-dev 0.7.1-10 Β· BSD-2-Clause
- debian trixie: libck-dev 0.7.2-6 Β· BSD-2-Clause
- epel 10: ck-devel 0.7.2-1.el10_1 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- epel 9: ck-devel 0.7.0-10.el9 Β· BSD
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- nixos 26.05: ck 0.7.2
- nixpkgs unstable: ck 0.7.2
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- ubuntu jammy: libck-dev 0.7.1-6ubuntu2 Β· BSD-2-Clause
- ubuntu noble: libck-dev 0.7.1-13build1 Β· BSD-2-Clause
- ubuntu questing: libck-dev 0.7.2-5ubuntu1
- ubuntu resolute: libck-dev 0.7.2-5ubuntu2 Β· BSD-2-Clause
- ubuntu stonking: libck-dev 0.7.2-11 Β· BSD-2-Clause
- Copyright 2014 Samy Al Bahra
- Copyright 2014 Backtrace I/O, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms