Lucas De Marchi | e8fd8fe | 2012-07-18 10:19:48 -0300 | [diff] [blame] | 1 | #pragma once |
Lucas De Marchi | 6670c63 | 2011-12-28 12:53:37 -0200 | [diff] [blame] | 2 | |
Lucas De Marchi | 74d1df6 | 2014-10-03 00:22:36 -0300 | [diff] [blame] | 3 | #include <stddef.h> |
| 4 | |
Lucas De Marchi | 6670c63 | 2011-12-28 12:53:37 -0200 | [diff] [blame] | 5 | /* |
| 6 | * Declaration of struct array is in header because we may want to embed the |
| 7 | * structure into another, so we need to know its size |
| 8 | */ |
| 9 | struct array { |
| 10 | void **array; |
| 11 | size_t count; |
| 12 | size_t total; |
| 13 | size_t step; |
| 14 | }; |
| 15 | |
| 16 | void array_init(struct array *array, size_t step); |
| 17 | int array_append(struct array *array, const void *element); |
| 18 | int array_append_unique(struct array *array, const void *element); |
| 19 | void array_pop(struct array *array); |
| 20 | void array_free_array(struct array *array); |
| 21 | void array_sort(struct array *array, int (*cmp)(const void *a, const void *b)); |
Gustavo Sverzut Barbieri | 79b656f | 2012-01-03 15:58:24 -0200 | [diff] [blame] | 22 | int array_remove_at(struct array *array, unsigned int pos); |