Simple data structures / objects in plain C Snapshot
Classes | Defines | Typedefs | Functions
array.h File Reference
#include <cutils/base.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Classes

struct  ARRAY

Defines

#define ARRAY_init_stack(arr, elmsize, numofelem)
 Macro: Allocate dynamic array on stack.

Typedefs

typedef int(* ARRAY_VISITOR )(int index, void *elm, size_t elmsize, void *context)

Functions

M_INLINE int ARRAY_init (ARRAY *arr, size_t elmsize, size_t numofelem)
M_INLINE int ARRAY_init_fixed (ARRAY *arr, size_t elmsize, void *ptr, size_t bufsize)
 Allocates a dynamic array from already allocated memory area;.
M_INLINE void ARRAY_free (ARRAY *arr)
 free all memory held by dynamic array (destructor).
M_INLINE void ARRAY_reset (ARRAY *arr)
M_INLINE size_t ARRAY_size (ARRAY *arr)
 returns number of objects that are currently held by this collection.
M_INLINE size_t ARRAY_maxsize (ARRAY *arr)
 returns maximum number of elements that can currently be held by this collection.
M_INLINE int ARRAY_resize (ARRAY *arr, size_t num_elem)
 change size of dynamic array (i.e. change size of memory allocated for array) If requested size is smaller then the current size, then all skipping elements are discarded.
M_INLINE uint8_t * ARRAY_at (ARRAY *arr, size_t index)
M_INLINE int ARRAY_copy_at (ARRAY *arr, size_t index, void *elm, size_t elmsize)
int ARRAY_insert_at (ARRAY *arr, size_t index, void *elm, size_t elmsize)
int ARRAY_set_at (ARRAY *arr, size_t index, void *elm, size_t elmsize)
M_INLINE int ARRAY_delete_at (ARRAY *arr, size_t index)
M_INLINE int ARRAY_push_back (ARRAY *arr, void *elm, size_t elmsize)
M_INLINE int ARRAY_pop_back (ARRAY *arr, void *ptr, size_t elmsize)
M_INLINE int ARRAY_stack_top (ARRAY *arr, void *ptr, size_t elmsize)
M_INLINE void ARRAY_foreach (ARRAY *arr, ARRAY_VISITOR eval, void *context)
M_INLINE int ARRAY_foreach_range (ARRAY *arr, ARRAY_VISITOR eval, void *context, int from_idx, int to_idx)
M_INLINE void ARRAY_foreach_reverse (ARRAY *arr, ARRAY_VISITOR eval, void *context)
M_INLINE int ARRAY_foreach_reverse_range (ARRAY *arr, ARRAY_VISITOR eval, void *context, int from_idx, int to_idx)
M_INLINE int ARRAY_findif (ARRAY *arr, ARRAY_VISITOR eval, void *context, uint32_t *retval)
M_INLINE int ARRAY_findif_range (ARRAY *arr, ARRAY_VISITOR eval, void *context, int from_idx, int to_idx, uint32_t *retval)
M_INLINE int ARRAY_findif_reverse (ARRAY *arr, ARRAY_VISITOR eval, void *context, uint32_t *retval)
M_INLINE int ARRAY_findif_reverse_range (ARRAY *arr, ARRAY_VISITOR eval, void *context, int from_idx, int to_idx, uint32_t *retval)