17 #if !defined __clang_analyzer__
18 #error "The contained type must be defined for a deque template"
27 #define ITEM_DELETE item_delete
29 #define ITEM_CLONE item_clone
32#if !defined ITEM_DELETE
33 #define ITEM_DELETE(value)
36#if !defined ITEM_CLONE
37 #define ITEM_CLONE(value) (*(value))
40#define ITEM_VECTORS NS(NAME, item_vectors)
42#pragma push_macro("ALLOC")
43#pragma push_macro("ITEM")
44#pragma push_macro("ITEM_CLONE")
45#pragma push_macro("ITEM_DELETE")
48#define INTERNAL_NAME ITEM_VECTORS
51#pragma pop_macro("ALLOC")
52#pragma pop_macro("ITEM")
53#pragma pop_macro("ITEM_CLONE")
54#pragma pop_macro("ITEM_DELETE")
81 .alloc = other->alloc,
90 size_t total_size = front_size + back_size;
101 if (front_size > back_size + 1) {
102 source = &self->front;
103 target = &self->back;
104 source_size = front_size;
105 target_size = back_size;
108 source = &self->back;
109 target = &self->front;
110 source_size = back_size;
111 target_size = front_size;
114 size_t to_move = (source_size - target_size) / 2;
121 memmove(&target_data[to_move], target_data, target_size *
sizeof(
ITEM));
123 for (
size_t i = 0; i < to_move; i++) {
124 target_data[to_move - 1 - i] = source_data[i];
127 memmove(source_data, &source_data[to_move], (source_size - to_move) *
sizeof(
ITEM));
129 target->size += to_move;
130 source->size -= to_move;
137 if (front_size > 0) {
148 if (front_size > 0) {
225#define ITER NS(SELF, iter)
236 size_t total_size = front_size + back_size;
238 if (iter->pos < total_size) {
240 if (iter->pos < front_size) {
251static bool NS(ITER,
empty)(ITER
const* iter) {
267#define ITER_CONST NS(SELF, iter_const)
278 size_t total_size = front_size + back_size;
280 if (iter->pos < total_size) {
282 if (iter->pos < front_size) {
293static bool NS(ITER_CONST,
empty)(ITER_CONST
const* iter) {
static bool deque_rebalance_policy(size_t total_size, size_t front_size)
#define DEBUG_ASSERT(expr)
gdb_marker derive_c_deque
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 ITEM pop_back(SELF *self)
static void reserve(SELF *self, size_t new_capacity_for)
static void push_back(SELF *self, ITEM item)
static void item_delete(item_t *UNUSED(self))
static item_t item_clone(item_t const *self)
static void push_front(SELF *self, ITEM item)
static ITEM const * peek_front_read(SELF const *self)
static SELF new_with_capacity(size_t front_and_back_capacity, ALLOC *alloc)
static ITEM * peek_front_write(SELF *self)
static ITEM * peek_back_write(SELF *self)
static void rebalance(SELF *self)
static ITEM const * peek_back_read(SELF const *self)
static ITEM * push(SELF *self, ITEM item)
static ITEM pop(SELF *self)
static ITEM * data(SELF *self)