24#pragma clang final(YAVL_VEC_H)
35#ifndef YAVL_VEC_H_STRUCT
53 sizeof(
void*)+
sizeof(
size_t[3])
57#undef YAVL_VEC_H_STRUCT
62#define YAVL_VEC_T_ALLOCATOR ((yavl_vec_t){})
yavl_vec_errorable_t yavl_vec_pop(yavl_vec_t *const vec)
Pops last elements out of vector. Doesn't free memory yet.
yavl_vec_errorable_t yavl_vec_ref(yavl_vec_t *const vec)
Get reference to dynamic vector array.
yavl_vec_res_t yavl_vec_set(yavl_vec_t *const vec, size_t offset, const void *const data)
Sets offset -th element of vector to data.
yavl_vec_res_t yavl_vec_init(yavl_vec_t *const memory, size_t data_align, size_t data_reserv)
Initializes a new vector. Frees memory if it is already allocated.
yavl_vec_res_t yavl_vec_push(yavl_vec_t *const vec, const void *const data)
Pushes data to vector.
yavl_vec_res_t yavl_vec_free(yavl_vec_t *const vec)
Frees heap in vector and zeroes the entire object.
yavl_vec_res_t
Operation result codes.
Definition vec.h:65
yavl_vec_errorable_t yavl_vec_flush(yavl_vec_t *const vec)
Finalizes vector, to result it in statically-sized array. This allows you to drop vector metadata.
yavl_vec_res_t yavl_vec_fit(yavl_vec_t *const vec)
Resizes vector space to the current size.
bool yavl_vec_chkptr(const yavl_vec_t *const vec, const void *const ptr)
Try to validate if the ptr pointer is in bounds of vec vector. This might be useful to ensure freshne...
yavl_vec_res_t yavl_vec_get(yavl_vec_t *const vec, size_t offset, void *const out)
Gets element at offset and stores it in out memory.
@ YAVL_VEC_RES_FAIL
Generic operation failure.
Definition vec.h:73
@ YAVL_VEC_RES_OOM
Out-of-memory, allocator failures.
Definition vec.h:67
@ YAVL_VEC_RES_NULL
Null pointer exception.
Definition vec.h:69
@ YAVL_VEC_RES_OK
Operation success.
Definition vec.h:71
A return package which contains both result code and data.
Definition vec.h:80
void *const mem
Data pointer, might be NULL on fatal failures.
Definition vec.h:84
yavl_vec_res_t status
Operation status (error code).
Definition vec.h:82
Type-agnostic vector definition.
Definition vec.h:50