89 #define ucx_array_util_set(array, capacity, elmsize, idx, data) \ 90 ucx_array_util_set_a(ucx_default_allocator(), (void**)(array), capacity, \ 113 size_t elmsize,
size_t idx,
void* data);
131 #define ucx_array_util_setptr(array, capacity, idx, ptr) \ 132 ucx_array_util_setptr_a(ucx_default_allocator(), (void**)(array), \ 154 size_t idx,
void* ptr);
int ucx_array_append_from(UcxArray *array, void *data, size_t count)
Inserts elements at the end of the array.
Definition: array.c:206
int ucx_array_prepend_from(UcxArray *array, void *data, size_t count)
Inserts elements at the beginning of the array.
Definition: array.c:221
int ucx_array_grow(UcxArray *array, size_t count)
Resizes the capacity, if the specified number of elements would not fit.
Definition: array.c:465
int(* cmp_func)(const void *, const void *, void *)
Function pointer to a compare function.
Definition: ucx.h:84
int ucx_array_shrink(UcxArray *array)
Shrinks the memory to exactly fit the contents.
Definition: array.c:418
int ucx_array_concat(UcxArray *array1, const UcxArray *array2)
Concatenates two arrays.
Definition: array.c:259
Main UCX Header providing most common definitions.
size_t capacity
The current capacity of the array.
Definition: array.h:53
int ucx_array_util_set_a(UcxAllocator *alloc, void **array, size_t *capacity, size_t elmsize, size_t idx, void *data)
Sets an element in an arbitrary user defined array.
Definition: array.c:72
int ucx_array_equals(UcxArray const *array1, UcxArray const *array2, cmp_func cmpfnc, void *data)
Compares two UCX arrays element-wise by using a compare function.
Definition: array.c:166
void ucx_array_init_a(UcxArray *array, size_t capacity, size_t elemsize, UcxAllocator *allocator)
Initializes a UCX array structure using the specified allocator.
Definition: array.c:136
void ucx_array_sort(UcxArray *array, cmp_func cmpfnc, void *data)
Sorts a UcxArray with the best available sort algorithm.
Definition: array.c:395
void * data
A pointer to the data.
Definition: array.h:65
UcxArray * ucx_array_new(size_t capacity, size_t elemsize)
Creates a new UCX array with the given capacity and element size.
Definition: array.c:119
void ucx_array_remove(UcxArray *array, size_t index)
Removes an element from the array.
Definition: array.c:400
UcxAllocator * allocator
The allocator used for the data.
Definition: array.h:69
int ucx_array_set_from(UcxArray *array, size_t index, void *data, size_t count)
Sets elements starting at the specified index.
Definition: array.c:240
void ucx_array_remove_fast(UcxArray *array, size_t index)
Removes an element from the array.
Definition: array.c:409
UCX allocator data structure containing memory management functions.
Definition: allocator.h:88
int ucx_array_contains(UcxArray const *array, void *elem, cmp_func cmpfnc, void *data)
Checks, if an array contains a specific element.
Definition: array.c:309
size_t ucx_array_find(UcxArray const *array, void *elem, cmp_func cmpfnc, void *data)
Returns the index of an element containing the specified data.
Definition: array.c:286
UCX array type.
Definition: array.h:49
size_t size
The actual number of elements in the array.
Definition: array.h:57
void ucx_array_destroy(UcxArray *array)
Destroys the array.
Definition: array.c:194
int ucx_array_util_setptr_a(UcxAllocator *alloc, void **array, size_t *capacity, size_t idx, void *ptr)
Stores a pointer in an arbitrary user defined array.
Definition: array.c:112
Allocator for custom memory management.
void ucx_array_free(UcxArray *array)
Destroys and frees the array.
Definition: array.c:201
int ucx_array_clone(UcxArray *dest, UcxArray const *src)
Creates an shallow copy of an array.
Definition: array.c:151
void * ucx_array_at(UcxArray const *array, size_t index)
Returns a pointer to the array element at the specified index.
Definition: array.c:280
int ucx_array_resize(UcxArray *array, size_t capacity)
Sets the capacity of the array.
Definition: array.c:430
void ucx_array_init(UcxArray *array, size_t capacity, size_t elemsize)
Initializes a UCX array structure with the given capacity and element size.
Definition: array.c:132
size_t elemsize
The size of an individual element in bytes.
Definition: array.h:61
int ucx_array_reserve(UcxArray *array, size_t capacity)
Resizes the array only, if the capacity is insufficient.
Definition: array.c:449
UcxArray * ucx_array_new_a(size_t capacity, size_t elemsize, UcxAllocator *allocator)
Creates a new UCX array using the specified allocator.
Definition: array.c:123