15#define ITEM_HASH DC_DEFAULT_HASH
21 DC_SCOPED(int_set)
set = int_set_new(stdalloc_get_ref());
23 for (
int i = 0; i < 10; i++) {
46 const char* name_ptr = self->
name;
48 int32_t value = (int32_t)self->
value;
55 fprintf(
stream,
"complex_data@%p {\n", (
void*)self);
64#define ITEM struct complex_data
65#define ITEM_HASH complex_data_hash
66#define ITEM_EQ complex_data_eq
67#define ITEM_DELETE complex_data_delete
68#define ITEM_DEBUG complex_data_debug
69#define NAME complex_set
74 DC_SCOPED(complex_set)
set = complex_set_new(stdalloc_get_ref());
76 struct complex_data item1 = {.flag =
true, .name = strdup(
"first"), .value = 42};
77 struct complex_data item2 = {.flag =
false, .name = strdup(
"second"), .value = 100};
79 complex_set_add(&
set, item1);
80 complex_set_add(&
set, item2);
82 struct complex_data lookup = {.flag =
true, .name = strdup(
"first"), .value = 42};
static DC_PUBLIC size_t dc_hash_combine(size_t seed, size_t h)
static DC_PUBLIC void set(SELF *self, INDEX_TYPE index, bool value)
static DC_PUBLIC void dc_debug_fmt_print(dc_debug_fmt fmt, FILE *stream, const char *format,...)
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_new()
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_scope_end(dc_debug_fmt fmt)
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_scope_begin(dc_debug_fmt fmt)
static DC_PUBLIC uint64_t dc_fnv1a_str_const(const char *const *s)
#define DC_FOR_CONST(TYPE, INSTANCE, ITER, ITEM)
#define DC_ASSERT(expr,...)
#define DC_SCOPED(type,...)
RAII in C. Call the destructor when the variable goes out of scope.
static void example_complex_set()
static size_t complex_data_hash(struct complex_data const *self)
static void example_integer_set()
static void complex_data_debug(struct complex_data const *self, dc_debug_fmt fmt, FILE *stream)
static bool complex_data_eq(struct complex_data const *a, struct complex_data const *b)
static void complex_data_delete(struct complex_data *self)
Debug format helpers for debug printin data structures.
static DC_PUBLIC FILE * stream(SELF *self)