diff options
Diffstat (limited to 'collections/vector/vector.adoc')
-rw-r--r-- | collections/vector/vector.adoc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/collections/vector/vector.adoc b/collections/vector/vector.adoc index ce91c71..7c4bc7f 100644 --- a/collections/vector/vector.adoc +++ b/collections/vector/vector.adoc @@ -1,7 +1,7 @@ Vector ====== Tucker Evans -v0.16, 2020-07-04 +v0.17, 2020-07-04 A basic vector, that hold pointers to your data structures. @@ -400,6 +400,24 @@ vec_truncate(vector, 1); assert(vec_size == 1); ---- +[[vec_reserve]] ++void vec_reserve(vec *self, int additional)+ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Reserves space for +additional+ items. May reserve more memory to avoid too +many reallocations. + +Examples +^^^^^^^^ +[source,c] +---- +#include "vector.h" + +vec *vector = vec_with_capacity(16); + +vec_reserve(vector, 20); +assert(vec_capacity(vector) >= 20); +---- + [[vec_clear]] +void vec_clear(vec *self)+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |