61#include "private/private_buffer.h"
118#define CCC_buffer_initialize(type_name, allocate, context_data, capacity, \
119 count, data_pointer...) \
120 CCC_private_buffer_initialize(type_name, allocate, context_data, capacity, \
168#define CCC_buffer_from(allocate, context_data, optional_capacity, \
169 compound_literal_array...) \
170 CCC_private_buffer_from(allocate, context_data, optional_capacity, \
171 compound_literal_array)
197#define CCC_buffer_with_capacity(type_name, allocate, context_data, capacity) \
198 CCC_private_buffer_with_capacity(type_name, allocate, context_data, \
220#define CCC_buffer_with_compound_literal(count, compound_literal_array...) \
221 CCC_private_buffer_with_compound_literal(count, compound_literal_array)
247#define CCC_buffer_with_context_compound_literal(context, count, \
248 compound_literal_array...) \
249 CCC_private_buffer_with_context_compound_literal(context, count, \
250 compound_literal_array)
268#define CCC_buffer_with_allocator(type_name, allocator) \
269 CCC_private_buffer_with_allocator(type_name, allocator)
295#define CCC_buffer_with_context_allocator(type_name, allocator, context) \
296 CCC_private_buffer_with_context_allocator(type_name, allocator, context)
441#define CCC_buffer_emplace_back(buffer_pointer, type_compound_literal...) \
442 CCC_private_buffer_emplace_back(buffer_pointer, type_compound_literal)
522#define CCC_buffer_as(buffer_pointer, type_name, index) \
523 ((type_name *)CCC_buffer_at(buffer_pointer, index))
544#define CCC_buffer_back_as(buffer_pointer, type_name) \
545 ((type_name *)CCC_buffer_back(buffer_pointer))
558#define CCC_buffer_front_as(buffer_pointer, type_name) \
559 ((type_name *)CCC_buffer_front(buffer_pointer))
599#define CCC_buffer_emplace(buffer_pointer, index, type_compound_literal...) \
600 CCC_private_buffer_emplace(buffer_pointer, index, type_compound_literal)
639 void const *iterator);
675 void const *iterator);
835#ifdef BUFFER_USING_NAMESPACE_CCC
837# define buffer_initialize(arguments...) CCC_buffer_initialize(arguments)
838# define buffer_with_compound_literal(arguments...) \
839 CCC_buffer_with_compound_literal(arguments)
840# define buffer_with_context_compound_literal(arguments...) \
841 CCC_buffer_with_context_compound_literal(arguments)
842# define buffer_with_allocator(arguments...) \
843 CCC_buffer_with_allocator(arguments)
844# define buffer_with_context_allocator(arguments...) \
845 CCC_buffer_with_context_allocator(arguments)
846# define buffer_with_capacity(arguments...) \
847 CCC_buffer_with_capacity(arguments)
848# define buffer_from(arguments...) CCC_buffer_from(arguments)
849# define buffer_allocate(arguments...) CCC_buffer_allocate(arguments)
850# define buffer_reserve(arguments...) CCC_buffer_reserve(arguments)
851# define buffer_copy(arguments...) CCC_buffer_copy(arguments)
852# define buffer_clear(arguments...) CCC_buffer_clear(arguments)
853# define buffer_clear_and_free(arguments...) \
854 CCC_buffer_clear_and_free(arguments)
855# define buffer_clear_and_free_reserve(arguments...) \
856 CCC_buffer_clear_and_free_reserve(arguments)
857# define buffer_count(arguments...) CCC_buffer_count(arguments)
858# define buffer_count_bytes(arguments...) CCC_buffer_count_bytes(arguments)
859# define buffer_size_plus(arguments...) CCC_buffer_size_plus(arguments)
860# define buffer_size_minus(arguments...) CCC_buffer_size_minus(arguments)
861# define buffer_size_set(arguments...) CCC_buffer_size_set(arguments)
862# define buffer_capacity(arguments...) CCC_buffer_capacity(arguments)
863# define buffer_capacity_bytes(arguments...) \
864 CCC_buffer_capacity_bytes(arguments)
865# define buffer_sizeof_type(arguments...) CCC_buffer_sizeof_type(arguments)
866# define buffer_index(arguments...) CCC_buffer_index(arguments)
867# define buffer_is_full(arguments...) CCC_buffer_is_full(arguments)
868# define buffer_is_empty(arguments...) CCC_buffer_is_empty(arguments)
869# define buffer_at(arguments...) CCC_buffer_at(arguments)
870# define buffer_as(arguments...) CCC_buffer_as(arguments)
871# define buffer_back(arguments...) CCC_buffer_back(arguments)
872# define buffer_back_as(arguments...) CCC_buffer_back_as(arguments)
873# define buffer_front(arguments...) CCC_buffer_front(arguments)
874# define buffer_front_as(arguments...) CCC_buffer_front_as(arguments)
875# define buffer_allocate_back(arguments...) \
876 CCC_buffer_allocate_back(arguments)
877# define buffer_emplace(arguments...) CCC_buffer_emplace(arguments)
878# define buffer_emplace_back(arguments...) CCC_buffer_emplace_back(arguments)
879# define buffer_push_back(arguments...) CCC_buffer_push_back(arguments)
880# define buffer_pop_back(arguments...) CCC_buffer_pop_back(arguments)
881# define buffer_pop_back_n(arguments...) CCC_buffer_pop_back_n(arguments)
882# define buffer_move(arguments...) CCC_buffer_move(arguments)
883# define buffer_swap(arguments...) CCC_buffer_swap(arguments)
884# define buffer_write(arguments...) CCC_buffer_write(arguments)
885# define buffer_erase(arguments...) CCC_buffer_erase(arguments)
886# define buffer_insert(arguments...) CCC_buffer_insert(arguments)
887# define buffer_begin(arguments...) CCC_buffer_begin(arguments)
888# define buffer_next(arguments...) CCC_buffer_next(arguments)
889# define buffer_end(arguments...) CCC_buffer_end(arguments)
890# define buffer_reverse_begin(arguments...) \
891 CCC_buffer_reverse_begin(arguments)
892# define buffer_reverse_next(arguments...) CCC_buffer_reverse_next(arguments)
893# define buffer_reverse_end(arguments...) CCC_buffer_reverse_end(arguments)
894# define buffer_capacity_end(arguments...) CCC_buffer_capacity_end(arguments)
CCC_Count CCC_buffer_count_bytes(CCC_Buffer const *buffer)
Return the bytes in the Buffer given the current count of active elements.
CCC_Result CCC_buffer_allocate(CCC_Buffer *buffer, size_t capacity, CCC_Allocator *allocate)
allocates the Buffer to the specified size according to the user defined allocation function.
void * CCC_buffer_at(CCC_Buffer const *buffer, size_t index)
return the element at slot index in buf.
CCC_Result CCC_buffer_clear_and_free(CCC_Buffer *buffer, CCC_Type_destructor *destroy)
Set size of buffer to 0 and call destroy on each element if needed. Free the underlying Buffer settin...
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_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_front(CCC_Buffer const *buffer)
return the first element in the Buffer at index 0.
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...
void * CCC_buffer_push_back(CCC_Buffer *buffer, void const *data)
return the newly pushed data into the last slot of the buffer according to size.
CCC_Count CCC_buffer_capacity(CCC_Buffer const *buffer)
Return the current capacity of total possible slots.
CCC_Tribool CCC_buffer_is_empty(CCC_Buffer const *buffer)
return true if the size of the Buffer is 0.
void * CCC_buffer_move(CCC_Buffer *buffer, size_t destination, size_t source)
Move data at index source to destination according to capacity.
void * CCC_buffer_next(CCC_Buffer const *buffer, void const *iterator)
advance the iterator to the next slot in the Buffer according to size.
CCC_Result CCC_buffer_reserve(CCC_Buffer *buffer, size_t to_add, CCC_Allocator *allocate)
Reserves space for at least to_add more elements.
void * CCC_buffer_allocate_back(CCC_Buffer *buffer)
allocates a new slot from the Buffer at the end of the contiguous array. A slot is equivalent to one ...
CCC_Result CCC_buffer_clear(CCC_Buffer *buffer, CCC_Type_destructor *destroy)
Set size of buffer to 0 and call destroy on each element if needed. O(1) if no destroy is provided,...
CCC_Count CCC_buffer_count(CCC_Buffer const *buffer)
obtain the count of Buffer active slots.
void * CCC_buffer_end(CCC_Buffer const *buffer)
return the end position of the Buffer according to size.
CCC_Result CCC_buffer_clear_and_free_reserve(CCC_Buffer *buffer, CCC_Type_destructor *destroy, CCC_Allocator *allocate)
Frees all slots in the buffer and frees the underlying Buffer that was previously dynamically reserve...
void * CCC_buffer_insert(CCC_Buffer *buffer, size_t index, void const *data)
insert data at slot index according to size of the Buffer maintaining contiguous storage of elements ...
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.
CCC_Result CCC_buffer_write(CCC_Buffer *buffer, size_t index, void const *data)
write data to Buffer at slot at index index according to capacity.
void * CCC_buffer_begin(CCC_Buffer const *buffer)
obtain the base address of the Buffer in preparation for iteration.
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_Result CCC_buffer_size_minus(CCC_Buffer *buffer, size_t count)
Subtract count from the size of the buffer.
CCC_Tribool CCC_buffer_is_full(CCC_Buffer const *buffer)
return true if the size of the Buffer equals capacity.
void * CCC_buffer_capacity_end(CCC_Buffer const *buffer)
return the end position of the Buffer according to 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_size_plus(CCC_Buffer *buffer, size_t count)
add count to the size of the buffer.
CCC_Result CCC_buffer_size_set(CCC_Buffer *buffer, size_t count)
Set the Buffer size to n.
CCC_Result CCC_buffer_swap(CCC_Buffer *buffer, void *temp, size_t index, size_t swap_index)
swap elements at index and swap_index according to capacity of the bufer.
CCC_Result CCC_buffer_copy(CCC_Buffer *destination, CCC_Buffer const *source, CCC_Allocator *allocate)
Copy the buffer from source to newly initialized destination.
Definition: private_buffer.h:34
size_t capacity
Definition: private_buffer.h:40
size_t count
Definition: private_buffer.h:38
CCC_Allocator * allocate
Definition: private_buffer.h:44
void * data
Definition: private_buffer.h:36
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:202
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:133
void CCC_Type_destructor(CCC_Type_context)
A callback function for destroying an element in the container.
Definition: types.h:376
CCC_Result
A result of actions on containers.
Definition: types.h:148
void * CCC_Allocator(CCC_Allocator_context)
An allocation function at the core of all containers.
Definition: types.h:340