diff options
Diffstat (limited to 'collections/double_ended_queue.adoc')
-rw-r--r-- | collections/double_ended_queue.adoc | 19 |
1 files changed, 18 insertions, 1 deletions
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 |