CK_RHS_INIT(3)
πΈ NAME πΈ
ck_rhs_init β initialize a hash set π
It's giving "welcome to the party, let's set up your hash set bestie". This is CK_RHS_INIT(3), and yeah, she's iconic.
π LIBRARY π
Concurrency Kit (libck, -lck) β the whole squad lives here π«Ά
β¨ SYNOPSIS β¨
#include <ck_rhs.h>
typedef unsigned long
ck_rhs_hash_cb_t(const void *key, unsigned long seed);
typedef bool
ck_rhs_compare_cb_t(const void *c1, const void *c2);
bool
ck_rhs_init(ck_rhs_t *hs, unsigned int mode,
ck_rhs_hash_cb_t *hash_function, ck_rhs_compare_cb_t *compare,
struct ck_malloc *allocator, unsigned long capacity,
unsigned long seed);
π DESCRIPTION π
So ck_rhs_init() initializes the hash set that hs is pointing at. That's the whole gig. Main character behaviour, honestly.
The mode argument
mode tells you two things at once: what kind of key-value pairs are getting stored, and what concurrent access model you're expecting. It's a bitfield, and it takes one of these:
CK_RHS_MODE_OBJECTβ the hash set is here to store pointers to objects. It's basically a lil hint that onlyCK_MD_VMA_BITSare needed to encode thekeyargument, and any unused pointer bits get repurposed for internal optimizations β¨CK_RHS_MODE_DIRECTβ the hash set stores key values directly, and every single bit of the key is used to encode values. No bits left behind, periodt.CK_RHS_MODE_READ_MOSTLYβ optimizes read operations over put/delete. For the girlies who mostly just look π
The concurrent access model
You pick one of these:
CK_RHS_MODE_SPMCβ the hash set should allow concurrent readers when there's a single writer. One pen, many eyeballs, love that for us.CK_RHS_MODE_MPMCβ the hash set should allow concurrent readers when there are concurrent writers. And uhhβ¦ heads up bestie: this is currently unsupported. π¨
The developer is free to specify additional workload hints. These hints are one of:
(that's it. that's the list. it just ends. we don't make the rules π)
The hash_function argument
hash_function is a mandatory pointer to a user-specified hash function β no skipping this one, fr fr. Your hash function takes two arguments:
keyβ a pointer to a key.seedβ the initial seed associated with the hash set.
That initial seed is the one the user specifies in ck_rhs_init(3). Full circle, cute.
The compare argument
compare is an optional pointer to a user-specified key comparison function. If you pass NULL here, then pointer equality is what decides key equality. Chill, low-effort, valid.
Your custom comparison function takes two arguments β pointers to the objects being compared for equality β and it's expected to return true if the keys are of equal value, and false otherwise. Yes/no, slay/not slay.
The allocator argument
allocator is a pointer to a struct holding malloc and free function pointers, which define the memory allocation and destruction functions the hash set being initialized is gonna use. Your memory, your rules π
The capacity argument
capacity is the initial number of keys the hash set is expected to contain. Important: this is just a hint β the underlying implementation is free to allocate more or less memory than necessary to hold the number of entries capacity says. So don't get attached to the exact number, bestie.
The seed argument
seed is the initial seed used by the underlying hash function. Pick whatever value you want β the user is free to choose a value of their choice. Go wild π
π RETURN VALUES π
- If it works out:
ck_rhs_init()returnstrueπ₯³ - If it does not: it returns
false, which means error. Sad girl hours π
π¨ ERRORS π¨
The behavior ofck_rhs_init()is undefined ifhsis not a pointer to ack_rhs_tobject. Not undefined-ish. Not "probably fine". Undefined. Do not test this. I'm literally begging π
π SEE ALSO π
ck_rhs_move(3), ck_rhs_destroy(3), CK_RHS_HASH(3), ck_rhs_iterator_init(3), ck_rhs_next(3), ck_rhs_get(3), ck_rhs_put(3), ck_rhs_put_unique(3), ck_rhs_set(3), ck_rhs_fas(3), ck_rhs_remove(3), ck_rhs_grow(3), ck_rhs_rebuild(3), ck_rhs_gc(3), ck_rhs_count(3), ck_rhs_reset(3), ck_rhs_reset_size(3), ck_rhs_stat(3)
Additional information available at http://concurrencykit.org/ β go read, it's giving resources π
That's the whole page, bestie β¨ This one came from the Concurrency Kit source, dated September 17, 2012, and it lives at CK_RHS_INIT(3). Go forth and initialize something gorgeous πππ¦
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- 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
- 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 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 2012-2013 Samy Al Bahra
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms