diff options
-rw-r--r-- | examples/gevector.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/gevector.c b/examples/gevector.c index 15adbad..df6212e 100644 --- a/examples/gevector.c +++ b/examples/gevector.c @@ -3,23 +3,25 @@ #include <gevector.h> -GEVECTOR_API(int, ivec) -GEVECTOR_IMPL(int, ivec) +GEVECTOR_DEF(int, ivec) int main(void) { - struct ivec *vec = malloc(sizeof(struct ivec)); + ivec_t *vec = malloc(sizeof(ivec_t)); ivec_new(vec, 2, 0); - ivec_append(vec, 42); - ivec_append(vec, 69); - ivec_append(vec, 420); + ivec_push(vec, 42); + ivec_push(vec, 69); + ivec_push(vec, 420); ivec_insert(vec, 1337, 2); - for (size_t i = 0; i < vec->size; i++) - printf("%d\n", vec->items[i]); + GEVECTOR_FOREACH(int, num, *vec) + printf("%d\n", num); + + GEVECTOR_ENUMERATE(int, i, num, *vec) + printf("vec->data[%zu] == %d\n", i, num); - free(vec->items); + free(vec->data); free(vec); } |