Always useful.
Make a new PARRAY of initial size size. The array will grow and shrink as necessary, each time by the number of elements given by grow_by.
Close the parray, releasing any memory it was using. The second function applies the provided fun to each element in the array prior to closing it.
Adds the given data to the array. Returns the number of items in the array afterwards, -1 if something went wrong.
Remove the element at index idx. The data stored at idx is returned on success, NULL otherwise (most likely because the index was smaller than 0, or larger than the number of items in the array).
Returns the first element found in the array. If the array contains no elements, NULL is returned. Upon success the currency is set to the first element.
void* paLast(PARRAY pa)
Returns the last element found in the array. If the array is empty, NULL is returned. Upon success, the currency is set to the last element.
void* paNext(PARRAY pa)
Returns the next element in the array. Next is defined as the element after the current element. If there's no current element, this function is equivalent to paFirst().
void* paPrev(PARRAY pa)
Returns the previous element in the array. Previous is the element before the current one. If there's no current element, the function is equivalent to paLast().
void* paCurrent(PARRAY pa)
Returns the current element in the array, or NULL if there's no current element.
void* paElementAt(PARRAY pa,int idx)
Returns the element at index idx in the array. If idx is out of the array's bounds, NULL is returned. This is the most arrayish of all functions here.
Returns the number of elements currently in the array.
Returns 1 if the array contains the given element elem. The function cmpfun() that performs element comparisons must be defined by the caller. If the given element is not found, the return value is NULL.
void paSetCurrent(PARRAY pa,int idx)
Sets the currency to the element found at index idx in the array. If idx is out of bounds, the currency is left unchanged.