libds

simple data structures library and utility functions
git clone git://git.2f30.org/libds.git
Log | Files | Refs | LICENSE

commit a242631947101a34b1ebcd3ae742623a518ff6db
parent 4fa3b087be5d4ca311cf2b6e936bd3148da215af
Author: sin <sin@2f30.org>
Date:   Tue Apr  8 09:52:02 +0100

Add vector_walk()

Diffstat:
ds.h | 1+
vector.c | 9+++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/ds.h b/ds.h @@ -9,5 +9,6 @@ void vector_free(struct vector *); size_t vector_add(struct vector *, void *); void *vector_get(struct vector *, size_t); size_t vector_len(struct vector *); +void vector_walk(struct vector *, void (*)(struct vector *, void *)); #endif diff --git a/vector.c b/vector.c @@ -112,3 +112,12 @@ vector_len(struct vector *vector) { return vector->ne; } + +void +vector_walk(struct vector *vector, void (*cb)(struct vector *, void *)) +{ + size_t i; + + for (i = 0; i < vector->ne; i++) + cb(vector, vector->l[i / vector->sz][i % vector->sz].data); +}