5#if !defined(SKIP_INCLUDES)
19 #if !defined DC_PLACEHOLDERS
26 #define ITEM_DELETE item_delete
28 #define ITEM_CLONE item_clone
30 #define ITEM_DEBUG item_debug
34#if !defined ITEM_DELETE
35 #define ITEM_DELETE DC_NO_DELETE
38#if !defined ITEM_CLONE
39 #define ITEM_CLONE DC_COPY_CLONE
42#if !defined ITEM_DEBUG
43 #define ITEM_DEBUG DC_DEFAULT_DEBUG
47 #if !defined DC_PLACEHOLDERS
55 #define INDEX_TYPE uint8_t
56#elif CAPACITY <= 65535
57 #define INDEX_TYPE uint16_t
60 #define INDEX_TYPE size_t
73#define INVARIANT_CHECK(self) \
75 DC_ASSUME((self->size) <= CAPACITY);
90 new_self.
size = self->size;
92 for (INDEX_TYPE i = 0; i < self->size; i++) {
102 return &self->data[index];
109 DC_ASSERT(value,
"Cannot read, index out of bounds {index=%lu, size=%lu}", (
size_t)index,
117 return &self->data[index];
124 DC_ASSERT(value,
"Cannot write, index out of bounds {index=%lu, size=%lu}", (
size_t)index,
133 ITEM* slot = &self->data[self->size];
145 DC_ASSERT(at <= self->
size,
"Cannot insert at, index out of bounds {at=%lu, size=%lu}",
146 (
size_t)at, (
size_t)self->size);
149 if (self->size + count >
CAPACITY) {
157 memmove(&self->data[at + count], &self->data[at], (self->size - at) *
sizeof(
ITEM));
158 memcpy(&self->data[at], items, count *
sizeof(
ITEM));
160 return &self->data[at];
166 "Cannot remove at, index out of bounds {at=%lu, count=%lu, size=%lu}", (
size_t)at,
167 (
size_t)count, (
size_t)self->size);
173 for (INDEX_TYPE i = at; i < at + count; i++) {
177 memmove(&self->data[at], &self->data[at + count], (self->size - (at + count)) *
sizeof(
ITEM));
183 DC_ASSERT(slot,
"Cannot push, already at max capacity {capacity=%d, item=%s}",
CAPACITY,
193 *destination = self->data[self->size];
213 for (INDEX_TYPE i = 0; i < self->size; i++) {
218#define ITER NS(SELF, iter)
232 if (iter->pos < iter->vec->size) {
233 ITEM*
item = &iter->vec->data[iter->pos];
249 return iter->pos >= iter->vec->size;
254 return (
ITER){.vec = self,
261#define ITER_CONST NS(SELF, iter_const)
275 if (iter->pos < iter->vec->size) {
276 ITEM const*
item = &iter->vec->data[iter->pos];
292 return iter->pos >= iter->vec->size;
326#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 bool empty(ITER const *iter)
static DC_PUBLIC VALUE const * read(SELF const *self, INDEX index)
static DC_PUBLIC VALUE * write(SELF *self, INDEX index)
static DC_PUBLIC bool empty_item(IV_PAIR const *item)
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)
static DC_PUBLIC ITEM * try_push(SELF *self, ITEM item)
DC_STATIC_CONSTANT size_t max_size
static DC_PUBLIC bool try_pop(SELF *self, ITEM *destination)
static DC_PUBLIC ITEM * try_insert_at(SELF *self, size_t at, ITEM const *items, size_t count)
static DC_PUBLIC void remove_at(SELF *self, size_t at, size_t count)
static DC_PUBLIC ITEM * push(SELF *self, ITEM item)
static DC_PUBLIC DC_INLINE size_t position(ITER const *DC_RESTRICT iter)
static DC_PUBLIC ITEM pop(SELF *self)
#define DC_TRAIT_VECTOR(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 void dc_debug_fmt_print_indents(dc_debug_fmt fmt, FILE *stream)
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_staticvec
Debug format helpers for debug printin data structures.
A queue comprised of an extendable circular buffer.
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)