diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-03 01:18:17 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-04 23:11:41 -0400 |
commit | 1a41fe605ab6bde15f622e72abb7aee846531fcf (patch) | |
tree | eaffdc8276bc59989d13e32b4a572b8a6c2b1afb /collections/vector/vector.c | |
parent | 72cb2e77024970509ff403670f9e4245bcefebd6 (diff) |
Add swap_pop function for vectors
Diffstat (limited to 'collections/vector/vector.c')
-rw-r--r-- | collections/vector/vector.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/collections/vector/vector.c b/collections/vector/vector.c index a7e0845..9ae30c7 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -190,6 +190,20 @@ int i,j; return; } +void* vec_swap_pop(root, i) +vec *root; +int i; +{ + void *tmp; + int j; + + if (!root || i >= root->end || i < 0 || root->end <= 0) + return NULL; + + vec_swap(root, i, root->end - 1); + return vec_pop(root); +} + void vec_clear(root) vec *root; { |