dynamic_array.h v0.3.1
Reference-counted dynamic arrays for C
|
Convenient type-safe macros for array operations. More...
Macros | |
#define | DA_CREATE(T, cap, retain_fn, release_fn) da_create(sizeof(T), cap, retain_fn, release_fn) |
Type-safe array creation. | |
#define | DA_PUSH_TYPED(arr, val, T) do { T _temp = (val); da_push(arr, (void*)&_temp); } while(0) |
Type-safe element append with explicit type parameter. | |
#define | DA_PUT_TYPED(arr, i, val, T) do { T _temp = (val); da_set(arr, i, (void*)&_temp); } while(0) |
Type-safe element assignment with explicit type parameter. | |
#define | DA_INSERT_TYPED(arr, i, val, T) do { T _temp = (val); da_insert(arr, i, (void*)&_temp); } while(0) |
Type-safe element insert with explicit type parameter. | |
#define | DA_PUSH(arr, val, T) DA_PUSH_TYPED(arr, val, T) |
Type-safe element append (adaptive macro) | |
#define | DA_PUT(arr, i, val, T) DA_PUT_TYPED(arr, i, val, T) |
Type-safe element assignment (adaptive macro) | |
#define | DA_INSERT(arr, i, val, T) DA_INSERT_TYPED(arr, i, val, T) |
Type-safe element insert (adaptive macro) | |
#define | DA_AT(arr, i, T) (*(T*)da_get(arr, i)) |
Type-safe element access by value. | |
#define | DA_LENGTH(arr) da_length(arr) |
Get array length (shorthand for da_length) | |
#define | DA_CAPACITY(arr) da_capacity(arr) |
Get array capacity (shorthand for da_capacity) | |
#define | DA_POP(arr, out_ptr) da_pop(arr, out_ptr) |
Pop last element (shorthand for da_pop) | |
#define | DA_CLEAR(arr) da_clear(arr) |
Clear array (shorthand for da_clear) | |
#define | DA_RESERVE(arr, cap) da_reserve(arr, cap) |
Reserve capacity (shorthand for da_reserve) | |
#define | DA_RESIZE(arr, len) da_resize(arr, len) |
Resize array (shorthand for da_resize) | |
#define | DA_REMOVE(arr, i, out_ptr) da_remove(arr, i, out_ptr) |
Remove element at index (shorthand for da_remove) | |
Convenient type-safe macros for array operations.
#define DA_AT | ( | arr, | |
i, | |||
T | |||
) | (*(T*)da_get(arr, i)) |
#define DA_CREATE | ( | T, | |
cap, | |||
retain_fn, | |||
release_fn | |||
) | da_create(sizeof(T), cap, retain_fn, release_fn) |
Type-safe array creation.
T | Element type (e.g., int, float, struct mytype) |
cap | Initial capacity |
#define DA_INSERT | ( | arr, | |
i, | |||
val, | |||
T | |||
) | DA_INSERT_TYPED(arr, i, val, T) |
Type-safe element insert (adaptive macro)
Type-safe element insert (with typeof support)
arr | Array to modify |
i | Index to insert at |
val | Value to insert |
T | Type parameter (only when DA_SUPPORT_TYPE_INFERENCE=0 or DA_NOT_USE_TYPE_GENERIC is defined) |
arr | Array to modify |
i | Index to insert at |
val | Value to insert |
#define DA_INSERT_TYPED | ( | arr, | |
i, | |||
val, | |||
T | |||
) | do { T _temp = (val); da_insert(arr, i, (void*)&_temp); } while(0) |
Type-safe element insert with explicit type parameter.
arr | Array to modify |
i | Index to insert at |
val | Value to insert |
T | Explicit type of the value |
#define DA_PUSH | ( | arr, | |
val, | |||
T | |||
) | DA_PUSH_TYPED(arr, val, T) |
Type-safe element append (adaptive macro)
arr | Array to modify |
val | Value to append |
T | Type parameter (only when DA_SUPPORT_TYPE_INFERENCE=0 or DA_NOT_USE_TYPE_GENERIC is defined) |
#define DA_PUSH_TYPED | ( | arr, | |
val, | |||
T | |||
) | do { T _temp = (val); da_push(arr, (void*)&_temp); } while(0) |
Type-safe element append with explicit type parameter.
arr | Array to modify |
val | Value to append |
T | Explicit type of the value |
#define DA_PUT | ( | arr, | |
i, | |||
val, | |||
T | |||
) | DA_PUT_TYPED(arr, i, val, T) |
Type-safe element assignment (adaptive macro)
arr | Array to modify |
i | Index to set |
val | Value to assign |
T | Type parameter (only when DA_SUPPORT_TYPE_INFERENCE=0 or DA_NOT_USE_TYPE_GENERIC is defined) |
#define DA_PUT_TYPED | ( | arr, | |
i, | |||
val, | |||
T | |||
) | do { T _temp = (val); da_set(arr, i, (void*)&_temp); } while(0) |
Type-safe element assignment with explicit type parameter.
arr | Array to modify |
i | Index to set |
val | Value to assign |
T | Explicit type of the value |
#define DA_REMOVE | ( | arr, | |
i, | |||
out_ptr | |||
) | da_remove(arr, i, out_ptr) |
Remove element at index (shorthand for da_remove)
arr | Array to modify |
i | Index to remove from |
out_ptr | Optional pointer to store removed element (can be NULL) |