diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-02 19:07:46 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-02 19:42:13 -0400 |
commit | 264857903db99135c8c09d12b3e8af93ac1c7f88 (patch) | |
tree | 9c18cdd8960ed7c5202a53657c04169d0254bbc3 /collections/vector/vector.c | |
parent | 0d09851c392829a6cbbd047f9a374b5c66eb4c98 (diff) |
Add index functionality to vectors
Diffstat (limited to 'collections/vector/vector.c')
-rw-r--r-- | collections/vector/vector.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/collections/vector/vector.c b/collections/vector/vector.c index afe99de..9d895d5 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -75,3 +75,14 @@ void *item; root->base[root->end++] = item; } + +void* vec_index(root, index) +vec *root; +int index; +{ + if (!root || index >= root->end || index < 0) { + return NULL; + } + + return root->base[index]; +} |