libamxc  1.10.3
C Generic Data Containers
amxc_array.h File Reference

Ambiorix array API header file. More...

#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <amxc/amxc_common.h>

Go to the source code of this file.

Data Structures

struct  _amxc_array
 The array structure. More...
 
struct  _amxc_array_it
 The array iterator structure. More...
 

Typedefs

typedef struct _amxc_array amxc_array_t
 The array structure. More...
 
typedef struct _amxc_array_it amxc_array_it_t
 The array iterator structure. More...
 
typedef void(* amxc_array_it_delete_t) (amxc_array_it_t *it)
 Definition of the array item delete callback function. More...
 
typedef int(* amxc_array_it_cmp_t) (amxc_array_it_t *it1, amxc_array_it_t *it2)
 Type definition of an array iterator compare callback function. More...
 

Functions

int8_t amxc_array_new (amxc_array_t **array, const size_t items)
 Allocates an array. More...
 
void amxc_array_delete (amxc_array_t **array, const amxc_array_it_delete_t func)
 Frees the previously allocated array. More...
 
int amxc_array_init (amxc_array_t *const array, const size_t items)
 Initializes an array. More...
 
void amxc_array_clean (amxc_array_t *const array, amxc_array_it_delete_t func)
 Removes all items from the array. More...
 
int amxc_array_grow (amxc_array_t *const array, const size_t items)
 Expands the array. More...
 
int amxc_array_shrink (amxc_array_t *const array, const size_t items, amxc_array_it_delete_t func)
 Shrinks the array. More...
 
int amxc_array_shift_right (amxc_array_t *const array, const size_t items, amxc_array_it_delete_t func)
 Shift all items to the right in the array. More...
 
int amxc_array_shift_left (amxc_array_t *const array, const size_t items, amxc_array_it_delete_t func)
 Shift all items to the left in the array. More...
 
bool amxc_array_is_empty (const amxc_array_t *const array)
 Checks that the array is empty. More...
 
size_t amxc_array_size (const amxc_array_t *const array)
 Calculates the number of used items in the array. More...
 
amxc_array_it_tamxc_array_append_data (amxc_array_t *const array, void *data)
 Adds an item after the last used item in the array. More...
 
amxc_array_it_tamxc_array_prepend_data (amxc_array_t *const array, void *data)
 Adds an item before the first used item in the array. More...
 
amxc_array_it_tamxc_array_get_at (const amxc_array_t *const array, const unsigned int index)
 Gets the item iterator for the given index. More...
 
amxc_array_it_tamxc_array_set_data_at (amxc_array_t *const array, const unsigned int index, void *data)
 Sets data at the given index. More...
 
amxc_array_it_tamxc_array_get_first (const amxc_array_t *const array)
 Gets the item iterator of the first used item in the array. More...
 
amxc_array_it_tamxc_array_get_first_free (const amxc_array_t *const array)
 Gets the first free position in the array. More...
 
amxc_array_it_tamxc_array_get_last (const amxc_array_t *const array)
 Gets the item iterator of the last used item in the array. More...
 
amxc_array_it_tamxc_array_get_last_free (const amxc_array_t *const array)
 Gets the last free position in the array. More...
 
void * amxc_array_take_first_data (amxc_array_t *const array)
 Takes the data pointer from the first used item in the array. More...
 
void * amxc_array_take_last_data (amxc_array_t *const array)
 Takes the data pointer from the last used item in the array. More...
 
amxc_array_it_tamxc_array_it_get_next (const amxc_array_it_t *const reference)
 Gets the next used item in the array, starting from the provided array iterator. More...
 
amxc_array_it_tamxc_array_it_get_next_free (const amxc_array_it_t *const reference)
 Gets the next free item in the array, starting from the provided array iterator. More...
 
amxc_array_it_tamxc_array_it_get_previous (const amxc_array_it_t *const reference)
 Gets the previous used item in the array, starting from the provided array iterator. More...
 
amxc_array_it_tamxc_array_it_get_previous_free (const amxc_array_it_t *const reference)
 Gets the previous free item in the array, starting from the provided array iterator. More...
 
unsigned int amxc_array_it_index (const amxc_array_it_t *const it)
 Gets the index of the iterator in the array. More...
 
AMXC_INLINE size_t amxc_array_capacity (const amxc_array_t *const array)
 Gets the capacity of the array. More...
 
AMXC_INLINE void * amxc_array_get_data_at (const amxc_array_t *const array, const unsigned int index)
 Gets the data pointer of the item at the given index. More...
 
AMXC_INLINE void * amxc_array_it_get_data (const amxc_array_it_t *const it)
 Gets the data pointer of array iterator. More...
 
int amxc_array_it_set_data (amxc_array_it_t *const it, void *data)
 Sets the data pointer of an array iterator. More...
 
void * amxc_array_it_take_data (amxc_array_it_t *const it)
 Gets and removes a data pointer from the iterator. More...
 
int amxc_array_it_swap (amxc_array_it_t *const it1, amxc_array_it_t *const it2)
 Swaps the content of the two array iterators. More...
 
int amxc_array_sort (amxc_array_t *const array, amxc_array_it_cmp_t cmp)
 Sorts the content of the array. More...
 

Detailed Description

Ambiorix array API header file.

Definition in file amxc_array.h.