aboutsummaryrefslogtreecommitdiff
path: root/collections/vector/vector.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'collections/vector/vector.adoc')
-rw-r--r--collections/vector/vector.adoc26
1 files changed, 25 insertions, 1 deletions
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);
+----