cdcontainers  0.1.1
Library of data containers and collections for C programming language.
Functions
Capacity

Functions

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...
 

Detailed Description

Function Documentation

◆ cdc_array_reserve()

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.

Parameters
[in]v- cdc_array
[in]capacity- new capacity
Returns
CDC_STATUS_OK in a successful case or other value indicating an error.

◆ cdc_array_empty()

static bool cdc_array_empty ( struct cdc_array v)
inlinestatic

Checks if the array has no elements.

Parameters
[in]v- cdc_array
Returns
true if the array is empty, false otherwise.

◆ cdc_array_size()

static size_t cdc_array_size ( struct cdc_array v)
inlinestatic

Returns the number of elements in the array.

Parameters
[in]v- cdc_array
Returns
the number of elements in the array.

◆ cdc_array_capacity()

static size_t cdc_array_capacity ( struct cdc_array v)
inlinestatic

Returns the number of elements that the container has currently allocated space for.

Parameters
[in]v- cdc_array
Returns
capacity of the currently allocated storage.

◆ cdc_array_shrink_to_fit()

enum cdc_stat cdc_array_shrink_to_fit ( struct cdc_array v)

Requests the container to reduce its capacity to fit its size.

Parameters
[in]v- cdc_array
Returns
CDC_STATUS_OK in a successful case or other value indicating an error