4#if !defined(SKIP_INCLUDES)
11 #if !defined DC_PLACEHOLDERS
20 #if !defined DC_PLACEHOLDERS
28 #define KEY_EQ DC_MEM_EQ
31#if !defined KEY_DELETE
32 #define KEY_DELETE DC_NO_DELETE
36 #define KEY_CLONE DC_COPY_CLONE
40 #define KEY_DEBUG DC_DEFAULT_DEBUG
44 #if !defined DC_PLACEHOLDERS
53#if !defined VALUE_DELETE
54 #define VALUE_DELETE DC_NO_DELETE
57#if !defined VALUE_CLONE
58 #define VALUE_CLONE DC_COPY_CLONE
61#if !defined VALUE_DEBUG
62 #define VALUE_DEBUG DC_DEFAULT_DEBUG
68#define ENTRY NS(SELF, entry_t)
84#define INVARIANT_CHECK(self) \
86 DC_ASSUME((self)->size <= CAPACITY);
99 for (
size_t index = 0; index < self->size; index++) {
100 if (
KEY_EQ(&self->entries[index].key, &key)) {
101 return &self->entries[index].value;
132 if (existing_value) {
136 self->entries[self->size].key = key;
137 self->entries[self->size].value = value;
139 return &self->entries[self->size - 1].value;
153 for (
size_t index = 0; index < self->size; index++) {
154 if (
KEY_EQ(&self->entries[index].key, &key)) {
156 *dest = self->entries[index].value;
158 for (
size_t i = index; i < self->size - 1; i++) {
159 self->entries[i] = self->entries[i + 1];
190 for (
size_t index = 0; index < self->size; index++) {
200 for (
size_t index = 0; index < self->size; index++) {
213 for (
size_t index = 0; index < self->size; index++) {
216 fprintf(
stream,
", value: ");
227#define ITER_CONST NS(SELF, iter_const)
228#define KV_PAIR_CONST NS(ITER_CONST, item)
242 return item->key == NULL &&
item->value == NULL;
247 size_t const next_index = iter->next_index;
249 if (next_index >= iter->map->size) {
256 .key = &iter->map->entries[next_index].key,
257 .value = &iter->map->entries[next_index].value,
264 return iter->next_index >= iter->map->size;
280#define ITER NS(SELF, iter)
281#define KV_PAIR NS(ITER, item)
295 return item->key == NULL &&
item->value == NULL;
300 size_t const next_index = iter->next_index;
302 if (next_index >= iter->map->size) {
303 return (
KV_PAIR){.key = NULL, .value = NULL};
309 .key = &iter->map->entries[next_index].key,
310 .value = &iter->map->entries[next_index].value,
317 return iter->next_index >= iter->map->size;
333#undef INVARIANT_CHECK
static DC_PUBLIC void debug(SELF const *self, dc_debug_fmt fmt, FILE *stream)
#define CAPACITY
A hybrid of a bump allocator on a statically allocated buffer, and any other allocator.
#define DC_STATIC_CONSTANT
static DC_PUBLIC VALUE const * try_read(SELF const *self, INDEX index)
static DC_PUBLIC VALUE * try_write(SELF *self, INDEX index)
#define INVARIANT_CHECK(self)
static DC_PUBLIC IV_PAIR next(ITER *iter)
static DC_PUBLIC INDEX insert(SELF *self, VALUE value)
static DC_PUBLIC bool empty(ITER const *iter)
static DC_PUBLIC VALUE const * read(SELF const *self, INDEX index)
static DC_PUBLIC bool try_remove(SELF *self, INDEX index, VALUE *destination)
static DC_PUBLIC VALUE * write(SELF *self, INDEX index)
static DC_PUBLIC bool empty_item(IV_PAIR const *item)
static DC_PUBLIC VALUE remove(SELF *self, INDEX index)
static DC_PUBLIC ITER get_iter(SELF *self)
static DC_PUBLIC ITER_CONST get_iter_const(SELF const *self)
static DC_PUBLIC size_t size(SELF const *self)
static DC_PUBLIC SELF clone(SELF const *self)
DC_STATIC_CONSTANT size_t max_capacity
static DC_PUBLIC void delete_entry(SELF *self, KEY key)
static DC_PUBLIC VALUE * try_insert(SELF *self, KEY key, VALUE value)
#define DC_TRAIT_MAP(SELF)
#define TEMPLATE_ERROR(...)
With the user provided name, even in nested templates.
#define DC_DEBUG(DEBUG_FN, DEBUG_PTR)
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_scope_end(dc_debug_fmt fmt)
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_scope_begin(dc_debug_fmt fmt)
static DC_PUBLIC dc_gdb_marker dc_gdb_marker_new()
static DC_PUBLIC void mutation_tracker_mutate(mutation_tracker *self)
static DC_PUBLIC void mutation_version_check(mutation_version const *self)
static DC_PUBLIC mutation_tracker mutation_tracker_new()
static DC_PUBLIC mutation_version mutation_tracker_get(mutation_tracker const *self)
#define DC_EXPAND_STRING(NAME)
#define DC_ASSERT(expr,...)
#define DC_ASSUME(expr,...)
mutation_tracker iterator_invalidation_tracker
dc_gdb_marker derive_c_map_staticlinear
Debug format helpers for debug printin data structures.
tracks a specific version of a value, so that this can be compared later to check modification For ex...
static DC_PUBLIC FILE * stream(SELF *self)