Derive-C
Loading...
Searching...
No Matches
container/bitset.c

Examples for using bitset containers.

Examples for using bitset containers.

#include <stdio.h>
#define EXCLUSIVE_END_INDEX 128
#define NAME bitset
static void example_basic() {
DC_SCOPED(bitset) bs = bitset_new();
bitset_set(&bs, 0, true);
bitset_set(&bs, 5, true);
bitset_debug(&bs, dc_debug_fmt_new(), stdout);
for (bitset_index_t i = 0; i < 128; i++) {
if (bitset_get(&bs, i)) {
printf("Bit at index %u is set\n", i);
}
}
DC_FOR_CONST(bitset, &bs, iter, index) { printf("Iterated index: %u\n", index); }
}
int main() {
return 0;
}
int main()
Definition alloc.c:109
static void example_basic()
Definition bitset.c:12
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_new()
Definition fmt.h:15
#define DC_FOR_CONST(TYPE, INSTANCE, ITER, ITEM)
Definition for.h:14
#define DC_SCOPED(type,...)
RAII in C. Call the destructor when the variable goes out of scope.
Definition scope.h:5
#define DC_DEBUG_TRACE
Definition debug.h:17