61#include "private/private_buffer.h"
93#define CCC_buffer_default(type_name) CCC_private_buffer_default(type_name)
125#define CCC_buffer_for(type_name, capacity, count, data_pointer...) \
126 CCC_private_buffer_for(type_name, capacity, count, data_pointer)
181#define CCC_buffer_from( \
182 allocator, optional_capacity, compound_literal_array... \
184 CCC_private_buffer_from( \
185 allocator, optional_capacity, compound_literal_array \
216#define CCC_buffer_with_capacity(type_name, allocator, capacity) \
217 CCC_private_buffer_with_capacity(type_name, allocator, capacity)
238#define CCC_buffer_with_storage(count, compound_literal_array...) \
239 CCC_private_buffer_with_storage(count, compound_literal_array)
357#define CCC_buffer_emplace_back( \
358 buffer_pointer, allocator_pointer, type_compound_literal... \
360 CCC_private_buffer_emplace_back( \
361 buffer_pointer, allocator_pointer, type_compound_literal \
447#define CCC_buffer_as(buffer_pointer, type_name, index) \
448 ((type_name *)CCC_buffer_at(buffer_pointer, index))
469#define CCC_buffer_back_as(buffer_pointer, type_name) \
470 ((type_name *)CCC_buffer_back(buffer_pointer))
483#define CCC_buffer_front_as(buffer_pointer, type_name) \
484 ((type_name *)CCC_buffer_front(buffer_pointer))
526#define CCC_buffer_emplace(buffer_pointer, index, type_compound_literal...) \
527 CCC_private_buffer_emplace(buffer_pointer, index, type_compound_literal)
545 CCC_Buffer const *buffer,
void *temp,
size_t index,
size_t swap_index
736#ifdef BUFFER_USING_NAMESPACE_CCC
739# define buffer_default(argument) CCC_buffer_default(argument)
740# define buffer_for(arguments...) CCC_buffer_for(arguments)
741# define buffer_with_storage(arguments...) CCC_buffer_with_storage(arguments)
742# define buffer_with_allocator(arguments...) \
743 CCC_buffer_with_allocator(arguments)
744# define buffer_with_capacity(arguments...) \
745 CCC_buffer_with_capacity(arguments)
746# define buffer_from(arguments...) CCC_buffer_from(arguments)
747# define buffer_allocate(arguments...) CCC_buffer_allocate(arguments)
748# define buffer_reserve(arguments...) CCC_buffer_reserve(arguments)
749# define buffer_copy(arguments...) CCC_buffer_copy(arguments)
750# define buffer_clear(arguments...) CCC_buffer_clear(arguments)
751# define buffer_clear_and_free(arguments...) \
752 CCC_buffer_clear_and_free(arguments)
753# define buffer_count(arguments...) CCC_buffer_count(arguments)
754# define buffer_count_bytes(arguments...) CCC_buffer_count_bytes(arguments)
755# define buffer_count_plus(arguments...) CCC_buffer_count_plus(arguments)
756# define buffer_count_minus(arguments...) CCC_buffer_count_minus(arguments)
757# define buffer_count_set(arguments...) CCC_buffer_count_set(arguments)
758# define buffer_capacity(arguments...) CCC_buffer_capacity(arguments)
759# define buffer_capacity_bytes(arguments...) \
760 CCC_buffer_capacity_bytes(arguments)
761# define buffer_sizeof_type(arguments...) CCC_buffer_sizeof_type(arguments)
762# define buffer_index(arguments...) CCC_buffer_index(arguments)
763# define buffer_is_full(arguments...) CCC_buffer_is_full(arguments)
764# define buffer_is_empty(arguments...) CCC_buffer_is_empty(arguments)
765# define buffer_at(arguments...) CCC_buffer_at(arguments)
766# define buffer_as(arguments...) CCC_buffer_as(arguments)
767# define buffer_back(arguments...) CCC_buffer_back(arguments)
768# define buffer_back_as(arguments...) CCC_buffer_back_as(arguments)
769# define buffer_front(arguments...) CCC_buffer_front(arguments)
770# define buffer_front_as(arguments...) CCC_buffer_front_as(arguments)
771# define buffer_allocate_back(arguments...) \
772 CCC_buffer_allocate_back(arguments)
773# define buffer_emplace(arguments...) CCC_buffer_emplace(arguments)
774# define buffer_emplace_back(arguments...) CCC_buffer_emplace_back(arguments)
775# define buffer_push_back(arguments...) CCC_buffer_push_back(arguments)
776# define buffer_pop_back(arguments...) CCC_buffer_pop_back(arguments)
777# define buffer_pop_back_n(arguments...) CCC_buffer_pop_back_n(arguments)
778# define buffer_move(arguments...) CCC_buffer_move(arguments)
779# define buffer_swap(arguments...) CCC_buffer_swap(arguments)
780# define buffer_write(arguments...) CCC_buffer_write(arguments)
781# define buffer_erase(arguments...) CCC_buffer_erase(arguments)
782# define buffer_insert(arguments...) CCC_buffer_insert(arguments)
783# define buffer_begin(arguments...) CCC_buffer_begin(arguments)
784# define buffer_next(arguments...) CCC_buffer_next(arguments)
785# define buffer_end(arguments...) CCC_buffer_end(arguments)
786# define buffer_reverse_begin(arguments...) \
787 CCC_buffer_reverse_begin(arguments)
788# define buffer_reverse_next(arguments...) CCC_buffer_reverse_next(arguments)
789# define buffer_reverse_end(arguments...) CCC_buffer_reverse_end(arguments)
790# define buffer_data(arguments...) CCC_buffer_data(arguments)
CCC_Result CCC_buffer_count_plus(CCC_Buffer *buffer, size_t count)
add count to the size of the buffer.
CCC_Result CCC_buffer_clear(CCC_Buffer *buffer, CCC_Destructor const *destructor)
Set size of buffer to 0 and call destroy on each element if needed. O(1) if no destroy is provided,...
CCC_Result CCC_buffer_copy(CCC_Buffer *destination, CCC_Buffer const *source, CCC_Allocator const *allocator)
Copy the buffer from source to newly initialized destination.
void * CCC_buffer_allocate_back(CCC_Buffer *buffer, CCC_Allocator const *allocator)
allocates a new slot from the Buffer at the end of the contiguous array. A slot is equivalent to one ...
CCC_Count CCC_buffer_count_bytes(CCC_Buffer const *buffer)
Return the bytes in the Buffer given the current count of active elements.
void * CCC_buffer_at(CCC_Buffer const *buffer, size_t index)
return the element at slot index in buf.
void * CCC_buffer_data(CCC_Buffer const *buffer)
return a reference to the underlying data of the buffer.
void * CCC_buffer_reverse_begin(CCC_Buffer const *buffer)
obtain the address of the last element in the Buffer in preparation for iteration according to size.
CCC_Result CCC_buffer_count_set(CCC_Buffer *buffer, size_t count)
Set the Buffer size to n.
CCC_Count CCC_buffer_index(CCC_Buffer const *buffer, void const *slot)
return the index of an element known to be in the buffer.
CCC_Result CCC_buffer_pop_back(CCC_Buffer *buffer)
pop the back element from the Buffer according to size.
void * CCC_buffer_push_back(CCC_Buffer *buffer, void const *data, CCC_Allocator const *allocator)
return the newly pushed data into the last slot of the buffer according to size.
CCC_Result CCC_buffer_reserve(CCC_Buffer *buffer, size_t to_add, CCC_Allocator const *allocator)
Reserves space for at least to_add more elements.
void * CCC_buffer_front(CCC_Buffer const *buffer)
return the first element in the Buffer at index 0.
void * CCC_buffer_move(CCC_Buffer const *buffer, size_t destination, size_t source)
Move data at index source to destination according to capacity.
CCC_Result CCC_buffer_erase(CCC_Buffer *buffer, size_t index)
erase element at slot index according to size of the Buffer maintaining contiguous storage of element...
CCC_Count CCC_buffer_capacity(CCC_Buffer const *buffer)
Return the current capacity of total possible slots.
CCC_Result CCC_buffer_count_minus(CCC_Buffer *buffer, size_t count)
Subtract count from the size of the buffer.
CCC_Tribool CCC_buffer_is_empty(CCC_Buffer const *buffer)
return true if the size of the Buffer is 0.
void * CCC_buffer_next(CCC_Buffer const *buffer, void const *iterator)
advance the iterator to the next slot in the Buffer according to size.
void * CCC_buffer_insert(CCC_Buffer *buffer, size_t index, void const *data, CCC_Allocator const *allocator)
insert data at slot index according to size of the Buffer maintaining contiguous storage of elements ...
CCC_Result CCC_buffer_swap(CCC_Buffer const *buffer, void *temp, size_t index, size_t swap_index)
swap elements at index and swap_index according to capacity of the bufer.
CCC_Count CCC_buffer_count(CCC_Buffer const *buffer)
obtain the count of Buffer active slots.
CCC_Result CCC_buffer_clear_and_free(CCC_Buffer *buffer, CCC_Destructor const *destructor, CCC_Allocator const *allocator)
Set size of buffer to 0 and call destroy on each element if needed. Free the underlying Buffer settin...
void * CCC_buffer_end(CCC_Buffer const *buffer)
return the end position of the Buffer according to size.
void * CCC_buffer_reverse_next(CCC_Buffer const *buffer, void const *iterator)
advance the iterator to the next slot in the Buffer according to size and in reverse order.
CCC_Count CCC_buffer_sizeof_type(CCC_Buffer const *buffer)
The size of the type being stored contiguously in the buffer.
void * CCC_buffer_begin(CCC_Buffer const *buffer)
obtain the base address of the Buffer in preparation for iteration.
CCC_Result CCC_buffer_write(CCC_Buffer const *buffer, size_t index, void const *data)
write data to Buffer at slot at index index according to capacity.
CCC_Count CCC_buffer_capacity_bytes(CCC_Buffer const *buffer)
Return the bytes in the Buffer given the current capacity elements.
CCC_Result CCC_buffer_pop_back_n(CCC_Buffer *buffer, size_t count)
pop count elements from the back of the Buffer according to size.
CCC_Tribool CCC_buffer_is_full(CCC_Buffer const *buffer)
return true if the size of the Buffer equals capacity.
void * CCC_buffer_back(CCC_Buffer const *buffer)
return the final element in the Buffer according the current size.
void * CCC_buffer_reverse_end(CCC_Buffer const *buffer)
return the reverse_end position of the buffer.
CCC_Result CCC_buffer_allocate(CCC_Buffer *buffer, size_t capacity, CCC_Allocator const *allocator)
allocates the Buffer to the specified size according to the user defined allocation function.
The type passed by reference to any container function that may need to allocate memory....
Definition: types.h:376
Definition: private_buffer.h:32
size_t capacity
Definition: private_buffer.h:38
size_t count
Definition: private_buffer.h:36
void * data
Definition: private_buffer.h:34
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:244
The type passed by reference to any container function that may need to destroy elements....
Definition: types.h:464
The C Container Collection Fundamental Types.
CCC_Tribool
A three state boolean to allow for an error state. Error is -1, False is 0, and True is 1.
Definition: types.h:178
CCC_Result
A result of actions on containers.
Definition: types.h:192