From 8d5b381b540fe1d780311e4f4059dce014a6cb91 Mon Sep 17 00:00:00 2001
From: Tucker Evans <tucker@tuckerevans.com>
Date: Fri, 3 Jul 2020 00:13:04 -0400
Subject: Add copy function for vector

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

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

diff --git a/collections/vector/vector.adoc b/collections/vector/vector.adoc
index fbb0b32..4920893 100644
--- a/collections/vector/vector.adoc
+++ b/collections/vector/vector.adoc
@@ -1,7 +1,7 @@
 Vector
 ======
 Tucker Evans
-v0.6, 2020-07-02
+v0.7, 2020-07-03
 
 A basic vector, that hold pointers to your data structures.
 
@@ -212,3 +212,27 @@ Output:
 VEC_CONTENTS:
 	[ONE,TWO,THREE]
 ----
+
+[[vec_cp]]
++vec* vec_cp(vec *self)+
+~~~~~~~~~~~~~~~~~~~~~~~~
+Returns a copy of the vector +self+. All elements are kept in the same order.
+
+Examples
+^^^^^^^^
+[source,c]
+----
+#include "vector.h"
+#include <string.h>
+
+char *str1 = "ONE";
+char *str2 = "TWO";
+
+vec *vector = vec_with_capacity(16);
+vec_push_back(vector, str_dup(str1));
+vec_push_back(vector, str_dup(str2));
+
+vec *new = vec_cp(vector);
+assert(strcmp(vec_pop_back, str2) == 0);
+assert(strcmp(vec_pop_back, str1) == 0);
+----
-- 
cgit v1.1

