Struct darray

Struct Documentation

struct darray

Dynamic array data structure.

It follows the dynamic table resizing algorithm from _Introduction_to_Algorithms, in order to provide O(1) amortized insertions and deletions. You can also resize the darray to whatever size you want at any time.

Public Members

uint8_t *elements

The array that holds the actual data

struct ds_iterator iter
size_t current

Next item in the darray will be inserted here (also # of elements in darray).

size_t capacity

Current capacity of array in # slots

size_t elt_size

Size in bytes of an element

bool_t sorted

Is the array is currently sorted?

int max_elts

Maximum number of elements allowed in the array (-1 for no limit)

uint32_t flags

Run-time configuration flags.

Valid flags are:

All other flags are ignored.

int (*cmpe)(const void *const e1, const void *const e2)

For comparing elements for <,=,>. Can be NULL. If NULL, certain darray operations aren’t allowed (like sorting).

void (*printe)(const void *e)

For printing an element (can be NULL)