From b253b373ea74539a0f29a88ac2be728aa8158d2a Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 00:57:58 -0400 Subject: Add set index function for vectors --- collections/vector/vector.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'collections/vector/vector.c') diff --git a/collections/vector/vector.c b/collections/vector/vector.c index 0b816b7..5cb56ef 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -152,6 +152,17 @@ vec *root; return root->base[root->end - 1]; } +void vec_set(root, index, item) +vec *root; +int index; +void *item; +{ + if (!root || index >= root->end || index < 0) + return; + + root->base[index] = item; +} + void* vec_index(root, index) vec *root; int index; -- cgit v1.1