diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-02 19:16:19 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-04 22:27:59 -0400 |
commit | 98454f841b5ac87d2253c2fae0aba2525853f907 (patch) | |
tree | af9652f3e5f9ad9cf560089c91f12ce39923a17b /collections/vector/vector.adoc | |
parent | 264857903db99135c8c09d12b3e8af93ac1c7f88 (diff) |
Add pop to vectors
Diffstat (limited to 'collections/vector/vector.adoc')
-rw-r--r-- | collections/vector/vector.adoc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/collections/vector/vector.adoc b/collections/vector/vector.adoc index 1dce41b..8ec8b49 100644 --- a/collections/vector/vector.adoc +++ b/collections/vector/vector.adoc @@ -1,7 +1,7 @@ Vector ====== Tucker Evans -v0.3, 2020-07-02 +v0.4, 2020-07-02 A basic vector, that hold pointers to your data structures. @@ -101,3 +101,25 @@ vec_push(vector, str_dup(str3)); assert(str_cmp(vec_index(vector, 1), str2) == 0); ---- + ++void* vec_pop(vec *self)+ +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Pops an item off of the back of the vector +self+. + +Examples +^^^^^^^^ +[source,c] +---- +#include "vector.h" +#include <string.h> + +char *str1 = "ONE"; +char *str2 = "TWO"; + +vec *vector = vec_new(); +vec_push(vector, str_dup(str1)); +vec_push(vector, str_dup(str2)); + +assert(str_cmp(vec_pop(vector), str2) == 0); +assert(str_cmp(vec_pop(vector), str1) == 0); +---- |