DOKK / manpages / debian 10 / libsoldout-dev / soldout_array.3.en
SOLDOUT_ARRAY(3) Library Functions Manual SOLDOUT_ARRAY(3)

soldout_array, arr_adjust, arr_free, arr_grow, arr_init, arr_insert, arr_item, arr_newitem, arr_remove, arr_sorted_find, arr_sorted_find_i, parr_adjust, parr_free, parr_grow, parr_init, parr_insert, parr_pop, parr_push, parr_remove, parr_sorted_find, parr_sorted_find_i, parr_toparray handling functions for soldout

#include <array.h>

int
(*array_cmp_fn)(void *key, void *array_entry);

int
arr_adjust(struct array *arr);

void
arr_free(struct array *arr);

int
arr_grow(struct array *arr, int need);

void
arr_init(struct array *arr, size_t unit);

int
arr_insert(struct array *arr, int nb, int n);

void *
arr_item(struct array *arr, int no);

int
arr_newitem(struct array *arr);

void
arr_remove(struct array *arr, int idx);

void *
arr_sorted_find(struct array *arr, void *key, array_cmp_fn cmp);

int
arr_sorted_find_i(struct array *arr, void *key, array_cmp_fn cmp);

int
parr_adjust(struct parray *arr);

void
parr_free(struct parray *arr);

int
parr_grow(struct parray *arr, int need);

void
parr_init(struct parray *arr);

int
parr_insert(struct parray *parr, int nb, int n);

void *
parr_pop(struct parray *arr);

int
parr_push(struct parray *arr, void *i);

void *
parr_remove(struct parray *arr, int idx);

void *
parr_sorted_find(struct parray *arr, void *key, array_cmp_fn cmp);

int
parr_sorted_find_i(struct parray *arr, void *key, array_cmp_fn cmp);

void *
parr_top(struct parray *arr);

struct array
generic linear array. Consists of the following fields:
void * base
actual array data.
int size
size of the array.
int asize
allocated size.
size_t unit
reallocation unit size.
struct parray
array of pointers. Consists of the following fields:
void ** item
actual parray data.
int size
size of the parray.
int asize
allocated size.
array_cmp_fn
comparison function for sorted arrays.

()
shrink the allocated memory to fit exactly the needs.
()
free the structure contents (but NOT the struct itself).
()
increase the array size to fit the given number of elements.
()
initialize the contents of the struct.
()
insert nb elements before the n one.
()
return a pointer to the n element.
()
return the index of a new element appended to the array arr.
()
remove the n-th elements of the array.
()
O(log n) search in a sorted array, returning entry.
()
O(log n) search in a sorted array, returning index of the smallest element larger than the key.
()
shrink the allocated memory to fit exactly the needs.
()
free the structure contents (but NOT the struct itself).
()
increase the array size to fit the given number of elements.
()
initialize the contents of the struct.
()
insert nb elements before the n one.
()
pop the last item of the array and return it.
()
push a pointer at the end of the array (= append).
()
remove the idx element of the array and return it.
()
O(log n) search in a sorted array, returning entry.
()
O(log n) search in a sorted array, returning index of the smallest element larger than the key.
()
return the top the stack (i.e. the last element of the array).

The arr_adjust(), arr_grow(), arr_insert(), parr_adjust(), parr_grow(), parr_insert() and parr_push() functions return on success 1; on error - 0.

The arr_free(), arr_init(), arr_remove(), parr_free() and parr_init() functions do not return a value.

The arr_item(), arr_sorted_find(), parr_pop(), parr_remove(), parr_sorted_find() and parr_top() functions return a pointer to the element on success; on error - NULL.

The arr_newitem() function returns the index on success; on error -1.

The arr_sorted_find_i() and parr_sorted_find_i() functions return an index.

soldout(3)

The soldout library was written by Natasha "Kerensikova" Porte <natacha@instinctive.eu>. Manual page was originally written by Massimo Manghi <mxmanghi@apache.org>, and rewritten to mdoc format by Svyatoslav Mishyn <juef@openmailbox.org>.

April 13, 2016 Debian