16 #if !defined __clang_analyzer__
17 #error "The contained type must be defined for a vector template"
24 #define ITEM_DELETE item_delete
26 #define ITEM_CLONE item_clone
29#if !defined ITEM_DELETE
30 #define ITEM_DELETE(value)
33#if !defined ITEM_CLONE
34 #define ITEM_CLONE(value) (*(value))
57 return NS(
SELF,
new)(alloc);
74 data[0] = default_item;
75 for (
size_t i = 1; i <
size; i++) {
90 if (new_capacity > self->capacity) {
94 self->data = new_data;
95 self->capacity = new_capacity;
103 for (
size_t index = 0; index < self->size; index++) {
108 .capacity = self->capacity,
110 .alloc = self->alloc,
117 return &self->data[index];
131 return &self->data[index];
153 memmove(&self->data[at + count], &self->data[at], (self->size - at) *
sizeof(
ITEM));
154 memcpy(&self->data[at], items, count *
sizeof(
ITEM));
166 for (
size_t i = at; i < at + count; i++) {
170 memmove(&self->data[at], &self->data[at + count], (self->size - (at + count)) *
sizeof(
ITEM));
176 if (self->size == self->capacity) {
179 if (self->data == NULL) {
191 new_capacity = self->capacity * 2;
196 self->capacity = new_capacity;
197 self->data = new_data;
199 ITEM* entry = &self->data[self->size];
207 if (
LIKELY(self->size > 0)) {
209 *destination = self->data[self->size];
229 ITEM entry = self->data[0];
230 memmove(&self->data[0], &self->data[1], (self->size - 1) *
sizeof(
ITEM));
243 for (
size_t i = 0; i < self->size; i++) {
250#define ITER NS(SELF, iter)
259 if (iter->pos < iter->vec->size) {
260 ITEM* item = &iter->vec->data[iter->pos];
272static bool NS(ITER,
empty)(ITER
const* iter) {
274 return iter->pos >= iter->vec->size;
286#define ITER_CONST NS(SELF, iter_const)
295 if (iter->pos < iter->vec->size) {
296 ITEM const* item = &iter->vec->data[iter->pos];
303static size_t NS(ITER_CONST,
position)(ITER_CONST
const* iter) {
308static bool NS(ITER_CONST,
empty)(ITER_CONST
const* iter) {
310 return iter->pos >= iter->vec->size;
static void free(SELF *self, void *ptr)
static void * realloc(SELF *self, void *ptr, size_t size)
static void * malloc(SELF *self, size_t size)
#define DEBUG_ASSERT(expr)
gdb_marker derive_c_vector
A queue comprised of an extendable circular buffer.
static ITER_CONST get_iter_const(SELF const *self)
static bool empty(ITER const *iter)
static ITER get_iter(SELF *self)
static INDEX_TYPE size(SELF const *self)
static IV_PAIR const * next(ITER *iter)
static VALUE * try_write(SELF *self, INDEX index)
static VALUE const * read(SELF const *self, INDEX index)
static VALUE * write(SELF *self, INDEX index)
static SELF clone(SELF const *self)
static VALUE const * try_read(SELF const *self, INDEX index)
static ITEM pop_front(SELF *self)
static void reserve(SELF *self, size_t new_capacity_for)
static void item_delete(item_t *UNUSED(self))
static item_t item_clone(item_t const *self)
static SELF new_with_capacity(size_t front_and_back_capacity, ALLOC *alloc)
static void remove_at(SELF *self, size_t at, size_t count)
static ITEM * push(SELF *self, ITEM item)
static bool try_pop(SELF *self, ITEM *destination)
static ITEM pop(SELF *self)
static size_t position(ITER const *iter)
static void insert_at(SELF *self, size_t at, ITEM const *items, size_t count)
static SELF new_with_defaults(size_t size, ITEM default_item, ALLOC *alloc)
static ITEM * data(SELF *self)