From 349c75c16a3713ee6f3ffd701f1c88ce31ecd8de Mon Sep 17 00:00:00 2001
From: Tucker Evans <tucker@tuckerevans.com>
Date: Thu, 11 Jun 2020 14:42:06 -0400
Subject: Add reserve function for double ended queue.

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

(limited to 'collections/double_ended_queue.adoc')

diff --git a/collections/double_ended_queue.adoc b/collections/double_ended_queue.adoc
index 70cbbaf..9ecf9cb 100644
--- a/collections/double_ended_queue.adoc
+++ b/collections/double_ended_queue.adoc
@@ -1,7 +1,7 @@
 Double Ended Queue
 ==================
 Tucker Evans
-v0.2, 2020-06-10
+v0.3, 2020-06-10
 
 A double ended queue implemented in a circular buffer.
 
@@ -440,6 +440,23 @@ deq_truncate(queue, 1);
 assert(deq_size == 1);
 ----
 
++void deq_reserve(deq *self, int additional)+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Reserves space for +additional+ items. May reserve more memory to avoid too
+many reallocations.
+
+Examples
+^^^^^^^^
+[source,c]
+----
+#include "double_ended_queue.h"
+
+deq *queue = deq_with_capacity(16);
+
+deq_reserve(queue, 20);
+assert(deq_capacity(queue) >= 20);
+----
+
 +void deq_remove(deq *self, int index)+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Element at position +index+ of +self+ is removed from queue and the remaining
-- 
cgit v1.1

