54#define CSTL_VECTOR_INITIALIZER(TYPE) \
58 .size = sizeof(TYPE), \
74#define DECLARE_CSTL_VECTOR(NAME, TYPE) \
75 struct cstl_vector NAME = CSTL_VECTOR_INITIALIZER(TYPE)
110 v->elem.xtor.cons = cons;
111 v->elem.xtor.dest = dest;
112 v->elem.xtor.priv = priv;
cstl_sort_algorithm_t
Enumeration indicating the desired sort algorithm.
@ CSTL_SORT_ALGORITHM_DEFAULT
Unspecified default algorithm.
static void cstl_swap(void *const x, void *const y, void *const t, const size_t sz)
Swap values at two memory locations via use of a third.
void cstl_xtor_func_t(void *obj, void *priv)
Type for functions called to construct, clear, or destroy an object.
void cstl_swap_func_t(void *a, void *b, void *t, size_t len)
Type of function called to swap two objects.
int cstl_compare_func_t(const void *obj1, const void *obj2, void *priv)
Function type for comparing (in)equality of two objects.
void cstl_vector_resize(struct cstl_vector *v, size_t sz)
Change the number of valid elements in the vector.
void cstl_vector_reserve(struct cstl_vector *v, size_t sz)
Request to increase the capacity of the vector.
void * cstl_vector_at(struct cstl_vector *v, size_t i)
Get a pointer to an element in the vector.
struct cstl_vector cstl_vector_t
Vector object.
static size_t cstl_vector_size(const struct cstl_vector *const v)
Get the number of elements in the vector.
static void cstl_vector_init_complex(struct cstl_vector *const v, const size_t sz, cstl_xtor_func_t *const cons, cstl_xtor_func_t *const dest, void *const priv)
Initialize a vector object.
static size_t cstl_vector_capacity(const struct cstl_vector *const v)
Get the number of elements the vector can hold.
void cstl_vector_swap(struct cstl_vector *a, struct cstl_vector *b)
Swap the vector objects at the two given locations.
static void * cstl_vector_data(struct cstl_vector *const v)
Get a pointer to the start of the vector data.
static void cstl_vector_init(struct cstl_vector *const v, const size_t sz)
Initialize a vector object.
void cstl_vector_shrink_to_fit(struct cstl_vector *v)
Request to decrease the capacity of the vector.
static void cstl_vector_sort(struct cstl_vector *const v, cstl_compare_func_t *const cmp, void *const priv)
Sort the elements in the vector.
ssize_t cstl_vector_search(const struct cstl_vector *v, const void *e, cstl_compare_func_t *cmp, void *priv)
Perform a binary search of the vector.
const void * cstl_vector_at_const(const struct cstl_vector *v, size_t i)
Get a const pointer to an element from a const vector.
void cstl_vector_clear(struct cstl_vector *v)
Return a vector to its initialized state.
static void cstl_vector_reverse(struct cstl_vector *const v)
Reverse the current order of the elements.
ssize_t cstl_vector_find(const struct cstl_vector *v, const void *e, cstl_compare_func_t *cmp, void *priv)
Perform a linear search of the vector.
void __cstl_vector_reverse(struct cstl_vector *v, cstl_swap_func_t *swap)
Reverse the current order of the elements.
void __cstl_vector_sort(struct cstl_vector *v, cstl_compare_func_t *cmp, void *priv, cstl_swap_func_t *swap, cstl_sort_algorithm_t algo)
Sort the elements in the vector.