Function darray_insert

Function Documentation

status_t darray_insert(struct darray *arr, const void *e, size_t index)

Insert an item into an darray.

Inserts an item into the given position in the darray. If the array currently full, it will be extended to accomodate the new element, unless doing so would cause the max_elts for the darray to be exceeded. If RCSW_DS_SORTED was passed during initialization, the darray is resorted after insertion.

If the array was initialized with an unlimited maximum # of elements, then the array is extended to twice its current size (for amortized O(1) insertions).

Parameters:
  • arr – The darray handle

  • e – The element to insert

  • index – The index to insert at. If so, this function behaves as a prepend function (very inefficient, but allowable). If equal to darray_size(), behaves as append function (efficient—use this).

Returns:

status_t