From 5fa1551b4a0acc28d5c656479806511ab0c81a18 Mon Sep 17 00:00:00 2001
From: Tucker Evans <tucker@tuckerevans.com>
Date: Sat, 4 Jul 2020 22:17:27 -0400
Subject: Add reserve function to vectors

---
 collections/vector/vector.adoc | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

(limited to 'collections/vector/vector.adoc')

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)+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
cgit v1.1

