cdcontainers
0.1.1
Library of data containers and collections for C programming language.
|
The cdc_array is a struct and functions that provide a dynamic array. More...
#include <cdcontainers/common.h>
#include <cdcontainers/status.h>
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | cdc_array |
The cdc_array is service struct. More... | |
Functions | |
enum cdc_stat | cdc_array_ctor (struct cdc_array **v, struct cdc_data_info *info) |
Constructs an empty array. More... | |
enum cdc_stat | cdc_array_ctorl (struct cdc_array **v, struct cdc_data_info *info,...) |
Constructs an array, initialized by an variable number of pointers. The last pointer must be CDC_END. More... | |
enum cdc_stat | cdc_array_ctorv (struct cdc_array **v, struct cdc_data_info *info, va_list args) |
Constructs an array, initialized by args. The last pointer must be CDC_END. More... | |
void | cdc_array_dtor (struct cdc_array *v) |
Destroys the array. More... | |
static void * | cdc_array_get (struct cdc_array *v, size_t index) |
Returns an element at index position in the array. More... | |
enum cdc_stat | cdc_array_at (struct cdc_array *v, size_t index, void **elem) |
Writes to pointer an element from specified position in the array. Bounds checking is performed. More... | |
static void * | cdc_array_front (struct cdc_array *v) |
Returns a first element in the array. More... | |
static void * | cdc_array_back (struct cdc_array *v) |
Returns a last element in the array. More... | |
static void ** | cdc_array_data (struct cdc_array *v) |
Returns a pointer to the data stored in the array. More... | |
enum cdc_stat | cdc_array_reserve (struct cdc_array *v, size_t capacity) |
Attempts to allocate memory for at least size elements. If you know in advance how large the array will be, you should call this function to prevent reallocations and memory fragmentation. More... | |
static bool | cdc_array_empty (struct cdc_array *v) |
Checks if the array has no elements. More... | |
static size_t | cdc_array_size (struct cdc_array *v) |
Returns the number of elements in the array. More... | |
static size_t | cdc_array_capacity (struct cdc_array *v) |
Returns the number of elements that the container has currently allocated space for. More... | |
enum cdc_stat | cdc_array_shrink_to_fit (struct cdc_array *v) |
Requests the container to reduce its capacity to fit its size. More... | |
static void | cdc_array_set (struct cdc_array *v, size_t index, void *value) |
Sets an element at index position to the value. The function is not called to free memory. More... | |
enum cdc_stat | cdc_array_insert (struct cdc_array *v, size_t index, void *value) |
Inserts value at |index| position in the array. If index is 0, the value is prepended to the array. If index is cdc_array_size(), the value is appended to the array. More... | |
void | cdc_array_erase (struct cdc_array *v, size_t index) |
Removes an element at index position in the arrray. More... | |
void | cdc_array_clear (struct cdc_array *v) |
Removes all the elements from the array. More... | |
enum cdc_stat | cdc_array_push_back (struct cdc_array *v, void *value) |
Inserts an element at the end of the array. More... | |
static void | cdc_array_pop_back (struct cdc_array *v) |
Removes a last element in the array. More... | |
enum cdc_stat | cdc_array_append (struct cdc_array *v, void **data, size_t len) |
Appends elements at the end of array. More... | |
enum cdc_stat | cdc_array_append_move (struct cdc_array *v, struct cdc_array *other) |
Appends one array to the end of other array. More... | |
void | cdc_array_swap (struct cdc_array *a, struct cdc_array *b) |
Swaps arrays. This operation is very fast and never fails. More... | |
The cdc_array is a struct and functions that provide a dynamic array.
Example usage array: