soldout_array, arr_adjust, arr_free, arr_grow, arr_init, arr_insert, arr_item, arr_newitem, arr_remove,
Contents
Description
Typesstructarray
generic linear array. Consists of the following fields:
void*base
actual array data.
intsize
size of the array.
intasize
allocated size.
size_tunit
reallocation unit size.
structparray
array of pointers. Consists of the following fields:
void**item
actual parray data.
intsize
size of the parray.
intasize
allocated size.
array_cmp_fn
comparison function for sorted arrays.
Functionsarr_adjust()
shrink the allocated memory to fit exactly the needs.
arr_free()
free the structure contents (but NOT the struct itself).
arr_grow()
increase the array size to fit the given number of elements.
arr_init()
initialize the contents of the struct.
arr_insert()
insert nb elements before the n one.
arr_item()
return a pointer to the n element.
arr_newitem()
return the index of a new element appended to the array arr.
arr_remove()
remove the n-th elements of the array.
arr_sorted_find()
O(log n) search in a sorted array, returning entry.
arr_sorted_find_i()
O(log n) search in a sorted array, returning index of the smallest element larger than the key.
parr_adjust()
shrink the allocated memory to fit exactly the needs.
parr_free()
free the structure contents (but NOT the struct itself).
parr_grow()
increase the array size to fit the given number of elements.
parr_init()
initialize the contents of the struct.
parr_insert()
insert nb elements before the n one.
parr_pop()
pop the last item of the array and return it.
parr_push()
push a pointer at the end of the array (= append).
parr_remove()
remove the idx element of the array and return it.
parr_sorted_find()
O(log n) search in a sorted array, returning entry.
parr_sorted_find_i()
O(log n) search in a sorted array, returning index of the smallest element larger than the key.
parr_top()
return the top the stack (i.e. the last element of the array).
Name
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_top — array handling functions for
soldout
Return Values
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.
See Also
soldout(3)
Synopsis
#include<array.h>int(*array_cmp_fn)(void*key, void*array_entry);
intarr_adjust(structarray*arr);
voidarr_free(structarray*arr);
intarr_grow(structarray*arr, intneed);
voidarr_init(structarray*arr, size_tunit);
intarr_insert(structarray*arr, intnb, intn);
void*arr_item(structarray*arr, intno);
intarr_newitem(structarray*arr);
voidarr_remove(structarray*arr, intidx);
void*arr_sorted_find(structarray*arr, void*key, array_cmp_fncmp);
intarr_sorted_find_i(structarray*arr, void*key, array_cmp_fncmp);
intparr_adjust(structparray*arr);
voidparr_free(structparray*arr);
intparr_grow(structparray*arr, intneed);
voidparr_init(structparray*arr);
intparr_insert(structparray*parr, intnb, intn);
void*parr_pop(structparray*arr);
intparr_push(structparray*arr, void*i);
void*parr_remove(structparray*arr, intidx);
void*parr_sorted_find(structparray*arr, void*key, array_cmp_fncmp);
intparr_sorted_find_i(structparray*arr, void*key, array_cmp_fncmp);
void*parr_top(structparray*arr);
