From 09925a143f29c390e0c539006b38bdca4955643a Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 31 Dec 2022 01:01:23 +0100 Subject: Update gevector example --- examples/gevector.c | 20 +++++++++++--------- 1 file 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_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); } -- cgit v1.2.3