CBuild wiki
Implements dynamic array datatype. It works over structures with
specific “form”, where T is a generic type:
License: GPL-3.0-or-later. Create type for a new dynamic
array.
type type Type of elements for a new dynamic
array.Append new element to dynamic array.
cbuild_da_t*
da Dynamic array object.*typeof(da->data)
elem Element to append.Append new elements to dynamic array.
cbuild_da_t*
da Dynamic array object.typeof(da->data)
arr Elements to append.size_t arr_size Number of elements to append.Append new elements to dynamic array.
cbuild_da_t*
da Dynamic array object.*typeof(da->data)
… Elements to append.Set element in dynamic array using its index.
cbuild_da_t*
da Dynamic array object.size_t idx Element index.*typeof(da->data)
elem New element’s value.bool False on
overflow.
Get element from dynamic array using its index.
const cbuild_da_t*
da Dynamic array object.size_t idx Element index.typeof(da->data)
Pointer to an element or NULL if index
out of bounds.
Remove element dynamic array using its index.
cbuild_da_t*
da Dynamic array object.size_t idx Element index.bool False on
overflow.
Remove element dynamic array using its index.
This function has O(1) complexity but changes ordering of elements in an array. It copies last element into same index as removed one, overriding it and then just decrease size by 1.
cbuild_da_t*
da Dynamic array object.size_t idx Element index.bool False on
overflow.
Resize dynamic array.
cbuild_da_t*
da Dynamic array object.size_t new_size Resize dynamic array. If new_size
equal 0 default growth strategy will be used.Free dynamic array.
This should be used only if you want to free underlying memory, if
you just want to clear array and reuse it, setting size to
0 would be much faster.
cbuild_da_t*
da Dynamic array object.Foreach implementation for dynamic array. Same semantics as ‘for’ loop.
cbuild_da_t da Dynamic array object.name iter Name if variable that will be used as
iterator. Will have type typeof(da->data).