CK_BITMAP_NEXT(3)

πŸ’– CK_BITMAP_NEXT β€” iterate to the next set bit in bitmap πŸ’–

okay bestie, welcome to the ck_bitmap_next(3) page, she's a lil function from Concurrency Kit and she's here to walk you through your bits one at a time. no cap, this is genuinely one of the most useful lil guys in the whole bitmap family.


πŸ“š LIBRARY

Concurrency Kit β€” link with libck, so slap a -lck on that compile line and you're golden. 🫢


✨ SYNOPSIS ✨

#include <ck_bitmap.h>

bool
ck_bitmap_next(ck_bitmap_t *bitmap, ck_bitmap_iterator_t iterator,
    unsigned int *bit);

that's the whole vibe. one include, one call, endless possibilities. πŸ’…


🌸 DESCRIPTION 🌸

okay so here's the tea. ck_bitmap_next() takes the iterator object that iterator points to and increments it so it points at the next set bit in the bitmap. she's literally just scooting your iterator along to the next 1. ✨

and if ck_bitmap_next() returns true? then the pointer that bit points to gets initialized to the number of the current set bit that the iterator object is now pointing at. so you get told which bit, not just that there is one. iconic behaviour honestly. πŸ‘‘

🚨 IMPORTANT SIS: it is expected that iterator has already been initialized using the ck_bitmap_iterator_init(3) function. do not come in here with a raw uninitialized iterator, she will not be nice about it.

πŸŽ€ RETURN VALUES πŸŽ€

  • if ck_bitmap_next() returns true β€” the object pointed to by bit contains a set bit. you got one, bestie! πŸŽ‰
  • if ck_bitmap_next() returns false β€” the value of the object pointed to by bit is undefined. like, genuinely undefined. don't look at it, don't touch it, don't make it your whole personality. πŸ’€

πŸ™ˆ ERRORS

behavior is undefined if iterator or bitmap are uninitialized.

that's it, that's the error section. no error codes, no graceful fallback, just vibes and chaos. init your stuff fr fr. 😭

πŸ‘€ SEE ALSO

your whole bitmap bestie squad, go read them all:

more info also lives at http://concurrencykit.org/ 🌈


and that's a wrap on this lil cutie. she was documented on April 27, 2012 β€” a true vintage queen β€” and the footer of this page lowkey calls her CK_BITMAP_TEST(3) which is a whole different function name, but we don't gatekeep, we just note it and move on. πŸ’œ mwah, go iterate something. πŸ¦‹

πŸ“¦ where this page comes from