34 #define VECTOR_INIT(N) {.data = calloc(N, sizeof(void *)), .memsize = N, \ 48 #define VECTOR_DEL(V, FN) vector_clear(&V, FN); free(V.data); 252 int (*pred)(
const void *,
const void *));
264 bool (*pred)(
const void *,
const void *));
void * vector_get(const vector_t *v, size_t index)
Retrieve the data at given index.
size_t memsize
Definition: vector.h:18
void vector_remove(vector_t *v, size_t index, void(*df)(void *))
Delete a element from the vector.
size_t count
Definition: vector.h:20
void vector_del(vector_t *v)
Delete the vector and free allocated memory. The elements of the vector will not be freed...
void vector_push(vector_t *v, void *data)
Appends a element to the vector.
vector dynamically growing array
Definition: vector.h:14
void vector_clear_del(vector_t *v, void(*df)(void *))
Remove all elements and free the vector_t.
size_t vector_len(const vector_t *v)
void vector_clear(vector_t *v, void(*df)(void *))
Remove all elements from the vector, in case that df is NULL every entry is set to 0...
void * vector_find(const vector_t *v, const void *key, bool(*pred)(const void *, const void *))
Find an element in given vector.
vector_t * vector_with_cap(size_t n)
Creates a empty vector of the size n.
void vector_pop(vector_t *v, void(*df)(void *))
Remove the last element from the vector.
vector_t * vector_new()
Creates a new empty vector of the size 8.
void vector_foreach(const vector_t *v, void(*f)(void *))
Apply the funtion f to every element in the vector.
void vector_insert(vector_t *v, size_t index, void *data)
Insert an element at given position, should the index be greater than the current vector size then th...
bool vector_contains(const vector_t *v, const void *key, int(*pred)(const void *, const void *))
Check whether a element is in the vector. for an int created on the stack: return memcmp(a...
void vector_sort(vector_t *v, int(*pred)(const void *, const void *))
Sort the vector with quicksort.
void ** data
Definition: vector.h:16
bool vector_is_empty(const vector_t *v)