Derive-C
Loading...
Searching...
No Matches
bitset.c File Reference

Go to the source code of this file.

Macros

#define EXCLUSIVE_END_INDEX   128
#define NAME   bitset

Functions

static void example_basic (DC_LOGGER *parent)
int main ()

Macro Definition Documentation

◆ EXCLUSIVE_END_INDEX

#define EXCLUSIVE_END_INDEX   128

Definition at line 7 of file bitset.c.

◆ NAME

#define NAME   bitset

Definition at line 8 of file bitset.c.

Function Documentation

◆ example_basic()

void example_basic ( DC_LOGGER * parent)
static
Examples
container/bitset.c, container/map.c, container/vector.c, and utils/string_builder.c.

Definition at line 11 of file bitset.c.

11 {
12 DC_SCOPED(DC_LOGGER) log = DC_LOGGER_NEW(parent, "%s", __func__);
13 DC_SCOPED(bitset) bs = bitset_new();
14
15 DC_LOG(log, DC_INFO, "setting bits at index 0 and 5");
16 bitset_set(&bs, 0, true);
17 bitset_set(&bs, 5, true);
18
19 DC_LOG(log, DC_INFO, "bitset: %s", DC_DEBUG(bitset_debug, &bs));
20
21 for (bitset_index_t i = 0; i < 128; i++) {
22 if (bitset_get(&bs, i)) {
23 DC_LOG(log, DC_INFO, "bit at index %u is set", i);
24 }
25 }
26
27 DC_FOR_CONST(bitset, &bs, iter, index) { DC_LOG(log, DC_INFO, "iterated index: %u", index); }
28}
#define DC_DEBUG(DEBUG_FN, DEBUG_PTR)
Definition dump.h:92
#define DC_LOGGER
Definition file.h:168
#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_LOGGER_NEW(...)
Definition prelude.h:21
#define DC_LOG(...)
Definition prelude.h:20
@ DC_INFO
Definition trait.h:8

◆ main()

int main ( )

Definition at line 30 of file bitset.c.

30 {
32 root = NS(DC_LOGGER,
33 new_global)((NS(DC_LOGGER, global_config)){.stream = stdout, .ansi_colours = true},
34 (dc_log_id){"bitset"});
35
36 example_basic(&root);
37 return 0;
38}
static void example_basic(DC_LOGGER *parent)
Definition bitset.c:11
#define NS(pre, post)
Definition namespace.h:14