39#include "impl/impl_buffer.h"
81#define ccc_buf_init(mem_ptr, alloc_fn, aux_data, capacity, optional_size...) \
82 ccc_impl_buf_init(mem_ptr, alloc_fn, aux_data, capacity, optional_size)
391#ifdef BUFFER_USING_NAMESPACE_CCC
393# define buf_init(args...) ccc_buf_init(args)
394# define buf_alloc(args...) ccc_buf_alloc(args)
395# define buf_size(args...) ccc_buf_size(args)
396# define buf_size_plus(args...) ccc_buf_size_plus(args)
397# define buf_size_minus(args...) ccc_buf_size_minus(args)
398# define buf_size_set(args...) ccc_buf_size_set(args)
399# define buf_capacity(args...) ccc_buf_capacity(args)
400# define buf_elem_size(args...) ccc_buf_elem_size(args)
401# define buf_i(args...) ccc_buf_i(args)
402# define buf_is_full(args...) ccc_buf_is_full(args)
403# define buf_is_empty(args...) ccc_buf_is_empty(args)
404# define buf_at(args...) ccc_buf_at(args)
405# define buf_back(args...) ccc_buf_back(args)
406# define buf_front(args...) ccc_buf_front(args)
407# define buf_alloc_back(args...) ccc_buf_alloc_back(args)
408# define buf_push_back(args...) ccc_buf_push_back(args)
409# define buf_pop_back(args...) ccc_buf_pop_back(args)
410# define buf_pop_back_n(args...) ccc_buf_pop_back_n(args)
411# define buf_copy(args...) ccc_buf_copy(args)
412# define buf_swap(args...) ccc_buf_swap(args)
413# define buf_write(args...) ccc_buf_write(args)
414# define buf_erase(args...) ccc_buf_erase(args)
415# define buf_insert(args...) ccc_buf_insert(args)
416# define buf_begin(args...) ccc_buf_begin(args)
417# define buf_next(args...) ccc_buf_next(args)
418# define buf_end(args...) ccc_buf_end(args)
419# define buf_rbegin(args...) ccc_buf_rbegin(args)
420# define buf_rnext(args...) ccc_buf_rnext(args)
421# define buf_rend(args...) ccc_buf_rend(args)
422# define buf_capacity_end(args...) ccc_buf_capacity_end(args)
bool ccc_buf_is_empty(ccc_buffer const *buf)
return true if the size of the buffer is 0.
ccc_result ccc_buf_pop_back(ccc_buffer *buf)
pop the back element from the buffer according to size.
ccc_result ccc_buf_size_minus(ccc_buffer *buf, size_t n)
subtract n from the size of the buffer.
ccc_result ccc_buf_swap(ccc_buffer *buf, char tmp[], size_t i, size_t j)
swap elements at i and j according to capacity of the bufer.
void * ccc_buf_alloc_back(ccc_buffer *buf)
allocates a new slot from the buffer at the end of the contiguous array. A slot is equivalent to one ...
ccc_result ccc_buf_size_set(ccc_buffer *buf, size_t n)
set the buffer size to n.
void * ccc_buf_rend(ccc_buffer const *buf)
return the rend position of the buffer.
void * ccc_buf_capacity_end(ccc_buffer const *buf)
return the end position of the buffer according to capacity.
size_t ccc_buf_capacity(ccc_buffer const *buf)
return the current capacity of the buffer.
void * ccc_buf_at(ccc_buffer const *buf, size_t i)
return the element at slot i in buf.
void * ccc_buf_rnext(ccc_buffer const *buf, void const *iter)
advance the iter to the next slot in the buffer according to size and in reverse order.
void * ccc_buf_back(ccc_buffer const *buf)
return the final element in the buffer according the current size.
size_t ccc_buf_elem_size(ccc_buffer const *buf)
the size of the type being stored contiguously in the buffer.
void * ccc_buf_next(ccc_buffer const *buf, void const *iter)
advance the iter to the next slot in the buffer according to size.
ccc_result ccc_buf_write(ccc_buffer *buf, size_t i, void const *data)
write data to buffer at slot at index i according to capacity.
ccc_result ccc_buf_size_plus(ccc_buffer *buf, size_t n)
add n to the size of the buffer.
void * ccc_buf_rbegin(ccc_buffer const *buf)
obtain the address of the last element in the buffer in preparation for iteration according to size.
struct ccc_buf_ ccc_buffer
A contiguous block of storage for elements of the same type.
Definition: buffer.h:51
void * ccc_buf_end(ccc_buffer const *buf)
return the end position of the buffer according to size.
void * ccc_buf_copy(ccc_buffer *buf, size_t dst, size_t src)
copy data at index src to dst according to capacity.
void * ccc_buf_front(ccc_buffer const *buf)
return the first element in the buffer at index 0.
void * ccc_buf_begin(ccc_buffer const *buf)
obtain the base address of the buffer in preparation for iteration.
bool ccc_buf_is_full(ccc_buffer const *buf)
return true if the size of the buffer equals capacity.
ptrdiff_t ccc_buf_i(ccc_buffer const *buf, void const *slot)
return the index of an element known to be in the buffer.
ccc_result ccc_buf_erase(ccc_buffer *buf, size_t i)
erase element at slot i according to size of the buffer maintaining contiguous storage of elements be...
size_t ccc_buf_size(ccc_buffer const *buf)
obtain the size of the buffer.
ccc_result ccc_buf_alloc(ccc_buffer *buf, size_t capacity, ccc_alloc_fn *fn)
allocates the buffer to the specified size according to the user defined allocation function.
void * ccc_buf_insert(ccc_buffer *buf, size_t i, void const *data)
insert data at slot i according to size of the buffer maintaining contiguous storage of elements betw...
ccc_result ccc_buf_pop_back_n(ccc_buffer *buf, size_t n)
pop n elements from the back of the buffer according to size.
void * ccc_buf_push_back(ccc_buffer *buf, void const *data)
return the newly pushed data into the last slot of the buffer according to size.
The C Container Collection Fundamental Types.
ccc_result
A result of actions on containers.
Definition: types.h:65
void * ccc_alloc_fn(void *ptr, size_t size, void *aux)
An allocation function at the core of all containers.
Definition: types.h:199