vt_remove, vt_remove_bw 3 2016-03-01 genvector manual

NAME

vt_remove - remove elements from the array

SYNPOSIS

int vt_remove(vt_t *vect, vt_size_t from_idx, vt_size_t num_elems);

int vt_remove_bw(vt_t *vect, vt_size_t to_idx, vt_size_t num_elems);

DESCRIPTION

vt_remove deletes num_elems elements starting from from_idx. The first element deleted is from_idx.

vt_remove_bw peforms the same operation with backward addressing scheme: instead of addressing the first element of the block to be deleted, the caller addresses the last (to_idx).

Indices from_idx and to_idx must be within the bounds of the vector. If num_elems spans outside of the bounds in any direction, it is automatically trimmed to match the end of the list.

Element removal is an expensive operation since elements beyond the last deleted element all need to be moved. Both of these calls are basically wrappers around memmove, plus a few checks, plus an array resize.

Note: vt_t and the vt_ prefix are type-dependant, see vt_t(7).

Arguments:
vect A vector already initialized using vt_init.
from_idx, to_idx The index of the element to first or last element to be deleted.
num_elems Total number of elements to be deleted.

RETURN VALUE

Returns 0 on success, -1 on error (e.g. from_idx or to_idx is out of range, failed to resize the array).

SEE ALSO

vt_remove, vt_remove_bw 3 2016-03-01 genvector manual