O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
into_array.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7/* */
14/* ************************************************************************** */
15
16#include "o2s/array.h"
17#include "o2s/deque.h"
18
19#include <iso646.h> // not
20
24bool deque_pop_front_into_array(deque_t* self, struct array* destination, size_t count)
25{
26#ifndef NDEBUG
27 if (self->type_size != destination->type_size)
28 return false;
29#endif
30 if (not array_reserve(destination, count))
31 return false;
32 if (not deque_pop_front_n(self, array_end(destination), count))
33 return false;
34 destination->count += count;
35 return true;
36}
void * array_end(const array_t *self)
One-past-the-end pointer of the array.
Definition getters.c:25
Dynamic arrays.
bool deque_pop_front_n(deque_t *self, void *destination, size_t count)
Pops the count first elements of the queue.
Definition pop.c:45
Realtime double-ended queues.
bool deque_pop_front_into_array(deque_t *self, struct array *destination, size_t count)
Move the count first elements at the back of destination.
Definition into_array.c:24
bool array_reserve(array_t *self, size_t count)
Ensures the array has enough capacity to fit count new elements, reallocating if needed.
Definition memory.c:47
Double-ended queue.
Definition deque.h:27
size_t type_size
Size in bytes of a single element.
Definition deque.h:33