Function darray_filter

Function Documentation

struct darray *darray_filter(struct darray *arr, bool_t (*pred)(const void *e), uint32_t flags, void *elements)

Filter out elements into a new darray.

Iterate through the darray and find all the items that satisfy the predicate, and return a new darray containing only the items for which the predicate returned true. Matched elements are transferred from the original array to the new array, and removed from the original array. If no elements are found that fulfill the predicate, an empty darray is returned.

Parameters:
  • arr – The darray handle

  • pred – The predicate

  • flags – Initialization flags for the new darray

  • elements – Space for the elements of the new darray. Can be NULL.

Returns:

The filtered array, or NULL if an error occured.