libcstl
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
vector.h File Reference

Go to the source code of this file.

Data Structures

struct  cstl_vector
 Vector object. More...
 

Macros

#define CSTL_VECTOR_INITIALIZER(TYPE)
 Constant initialization of a vector object.
 
#define DECLARE_CSTL_VECTOR(NAME, TYPE)    struct cstl_vector NAME = CSTL_VECTOR_INITIALIZER(TYPE)
 (Statically) declare and initialize a vector
 

Typedefs

typedef struct cstl_vector cstl_vector_t
 Vector object.
 

Functions

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 void cstl_vector_init (struct cstl_vector *const v, const size_t sz)
 Initialize a vector object.
 
static size_t cstl_vector_size (const struct cstl_vector *const v)
 Get the number of elements in the vector.
 
static size_t cstl_vector_capacity (const struct cstl_vector *const v)
 Get the number of elements the vector can hold.
 
static void * cstl_vector_data (struct cstl_vector *const v)
 Get a pointer to the start of the vector data.
 
void * cstl_vector_at (struct cstl_vector *v, size_t i)
 Get a pointer to an element in 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_reserve (struct cstl_vector *v, size_t sz)
 Request to increase the capacity of the vector.
 
void cstl_vector_shrink_to_fit (struct cstl_vector *v)
 Request to decrease the capacity of the vector.
 
void cstl_vector_resize (struct cstl_vector *v, size_t sz)
 Change the number of valid elements in the vector.
 
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.
 
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.
 
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.
 
static void cstl_vector_reverse (struct cstl_vector *const v)
 Reverse the current order of the elements.
 
void cstl_vector_swap (struct cstl_vector *a, struct cstl_vector *b)
 Swap the vector objects at the two given locations.
 
void cstl_vector_clear (struct cstl_vector *v)
 Return a vector to its initialized state.