From 80d98a39a6bc4b71c74f240df617495e816b98b9 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Thu, 2 Jul 2020 20:21:28 -0400 Subject: Add printing functions for vectors --- collections/vector/vector.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'collections/vector/vector.c') diff --git a/collections/vector/vector.c b/collections/vector/vector.c index 9544917..b3751dd 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -118,3 +118,29 @@ vec *root; root->end = 0; } +void vec_print(root, to_string) +vec *root; +char* to_string(void*); +{ + int i; + + printf("["); + for(i = 0; i < root->end; i++) { + printf("%s", to_string(vec_index(root, i))); + } + printf("\b]\n"); + +} + +void vec_debug_print(root) +vec *root; +{ + int i; + + fprintf(stderr, "VEC[base: %p, end: %p, limit:%p]:\n\t ", + root->base, root->end, root->limit); + for (i=0; i < root->end; i++){ + fprintf(stderr, "[%p]", vec_index(root,i)); + } + fprintf(stderr, "\n"); +} -- cgit v1.1