aboutsummaryrefslogtreecommitdiff
path: root/collections/vector/vector.c
diff options
context:
space:
mode:
Diffstat (limited to 'collections/vector/vector.c')
-rw-r--r--collections/vector/vector.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/collections/vector/vector.c b/collections/vector/vector.c
index 79e31a4..2ae748f 100644
--- a/collections/vector/vector.c
+++ b/collections/vector/vector.c
@@ -174,6 +174,23 @@ int index;
return root->base[index];
}
+void vec_insert(root, index, item)
+vec *root;
+int index;
+void *item;
+{
+ if (!root || index > root->end || index < 0)
+ return;
+
+ if (root->end >= root->limit)
+ vec_resize(root);
+
+ memmove(root->base + index + 1, root->base + index,
+ (root->end++ - index) * sizeof(void*));
+
+ root->base[index] = item;
+}
+
void vec_swap(root, i, j)
vec *root;
int i,j;