CK_HS_NEXT(3)

πŸ’– CK_HS_NEXT(3) β€” ck_hs_next πŸ’–

okay bestie, gather round, we're learning about ck_hs_next from the Concurrency Kit manual, section 3 πŸ¦‹


πŸ“š LIBRARY

this lil cutie lives in Concurrency Kit, aka libck, and you link it with -lck. periodt. πŸ’…


✨ SYNOPSIS ✨

#include <ck_hs.h>

bool
ck_hs_next(ck_hs_t *hs, ck_hs_iterator_t *iterator, void **entry);

look at her. she's giving three arguments and a bool return. iconic. 🌸


πŸŽ€ DESCRIPTION πŸŽ€

so the way that ck_hs_next(3) works is: it bumps the iterator object that iterator points to, so it's now pointing at the next non-empty hash set entry. it's literally just walking you forward through the set, one living entry at a time. no cap. πŸšΆβ€β™€οΈβœ¨

and if ck_hs_next(3) returns true, then the pointer that entry points to gets initialized to the current hash set key that the iterator object is pointing at. so you get the goods. 🎁

bestie, heads up: iterator is expected to have been initialized already, either with ck_hs_iterator_init(3) or statically with CK_HS_ITERATOR_INITIALIZER. don't just roll up with a random uninitialized iterator, that's not the vibe. πŸ™ˆ

πŸ’« RETURN VALUES πŸ’«

  • if ck_hs_next(3) returns true, then the object pointed to by entry points to a valid hash set key. yay, you ate. πŸ‘‘
  • if ck_hs_next(3) returns false, then the value of the object pointed to by entry is undefined. so like… don't trust it, don't look at it, don't text it back. πŸ’€

😭 ERRORS 😭

behavior is undefined if iterator or hs are uninitialized. fr fr, undefined. not "kinda weird", not "slightly off" β€” undefined. do not pass go. 🚫

🌈 SEE ALSO 🌈

the whole friend group, all linked up:

and if you want even more lore, it's all waiting for you at http://concurrencykit.org/ 🫢


September 17, 2012 is when this queen was documented, and she's serving from CK_HS_NEXT(3) in the Concurrency Kit manual. mwah. πŸ’‹ stay iterating, bestie πŸ’–βœ¨

πŸ“¦ where this page comes from