From aeee67bdda0e0f8834cbd3f65da99e3c79f69f65 Mon Sep 17 00:00:00 2001
From: Tucker Evans <tucker@tuckerevans.com>
Date: Fri, 3 Jul 2020 00:28:23 -0400
Subject: Fix organize function order in vector docs and src

Functions now ordered roughly to what they do/deal with.
---
 collections/vector/vector.adoc | 158 ++++++++++++++++++++---------------------
 1 file changed, 79 insertions(+), 79 deletions(-)

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

diff --git a/collections/vector/vector.adoc b/collections/vector/vector.adoc
index 63cdd78..76c0f7a 100644
--- a/collections/vector/vector.adoc
+++ b/collections/vector/vector.adoc
@@ -1,7 +1,7 @@
 Vector
 ======
 Tucker Evans
-v0.7.1, 2020-07-03
+v0.7.2, 2020-07-03
 
 A basic vector, that hold pointers to your data structures.
 
@@ -65,26 +65,37 @@ vec_push_back(vector, NULL);
 assert(vec_size(vector) == 1);
 ----
 
-[[vec_push]]
-+void vec_push(vec *self, void *item)+
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Pushes +item+ into back of +self+. This may cause a resize of the internal buffer.
+[[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>
 
-vec *vector = vec_new();
-vec_push(vector, NULL);
-assert(vec_size(vector) == 1);
+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);
 ----
 
-[[vec_index]]
-+void* vec_index(vec *self, int index)+
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Returns the element at position +index+ of +self+.
+[[vec_print]]
++void vec_print(vec *self, (char* to_string(void*)))+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Prints out the contents of the vector +self+ to +stdout+ (surounded by square
+brackets and separated by commas ','). +to_string+ is a function that takes a
+pointer to the type of elements stored in +self+ and returns a string
+representation.
 
 Examples
 ^^^^^^^^
@@ -93,6 +104,14 @@ Examples
 #include "vector.h"
 #include <string.h>
 
+char* to_string(str)
+void *str;
+{
+	return str;
+}
+
+int main()
+{
 char *str1 = "ONE";
 char *str2 = "TWO";
 char *str3 = "THREE";
@@ -102,7 +121,31 @@ vec_push(vector, str_dup(str1));
 vec_push(vector, str_dup(str2));
 vec_push(vector, str_dup(str3));
 
-assert(str_cmp(vec_index(vector, 1), str2) == 0);
+printf("VEC CONTENTS:\n\t")
+vec_print(vector, to_string)
+}
+----
+
+Output:
+----
+VEC_CONTENTS:
+	[ONE,TWO,THREE]
+----
+
+[[vec_push]]
++void vec_push(vec *self, void *item)+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Pushes +item+ into back of +self+. This may cause a resize of the internal buffer.
+
+Examples
+^^^^^^^^
+[source,c]
+----
+#include "vector.h"
+
+vec *vector = vec_new();
+vec_push(vector, NULL);
+assert(vec_size(vector) == 1);
 ----
 
 [[vec_pop]]
@@ -128,23 +171,28 @@ assert(str_cmp(vec_pop(vector), str2) == 0);
 assert(str_cmp(vec_pop(vector), str1) == 0);
 ----
 
-[[vec_free]]
-+void vec_free(vec *self)+
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-Frees all internal memory and +self+.
-
-NOTE: All item pointers are still valid after a call to
-<<vec_free,+vec_free()+>>, <<vec_clear,+vec_clear()+>> should be called before
-if they are no longer needed to avoid memory leaks.
+[[vec_index]]
++void* vec_index(vec *self, int index)+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Returns the element at position +index+ of +self+.
 
 Examples
 ^^^^^^^^
 [source,c]
 ----
 #include "vector.h"
+#include <string.h>
+
+char *str1 = "ONE";
+char *str2 = "TWO";
+char *str3 = "THREE";
 
 vec *vector = vec_new();
-vec_free(vector);
+vec_push(vector, str_dup(str1));
+vec_push(vector, str_dup(str2));
+vec_push(vector, str_dup(str3));
+
+assert(str_cmp(vec_index(vector, 1), str2) == 0);
 ----
 
 [[vec_clear]]
@@ -174,69 +222,21 @@ assert(vec_size(vector) == 0);
 vec_free(vector);
 ----
 
-[[vec_print]]
-+void vec_print(vec *self, (char* to_string(void*)))+
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Prints out the contents of the vector +self+ to +stdout+ (surounded by square
-brackets and separated by commas ','). +to_string+ is a function that takes a
-pointer to the type of elements stored in +self+ and returns a string
-representation.
-
-Examples
-^^^^^^^^
-[source,c]
-----
-#include "vector.h"
-#include <string.h>
-
-char* to_string(str)
-void *str;
-{
-	return str;
-}
-
-int main()
-{
-char *str1 = "ONE";
-char *str2 = "TWO";
-char *str3 = "THREE";
-
-vec *vector = vec_new();
-vec_push(vector, str_dup(str1));
-vec_push(vector, str_dup(str2));
-vec_push(vector, str_dup(str3));
-
-printf("VEC CONTENTS:\n\t")
-vec_print(vector, to_string)
-}
-----
-
-Output:
-----
-VEC_CONTENTS:
-	[ONE,TWO,THREE]
-----
+[[vec_free]]
++void vec_free(vec *self)+
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+Frees all internal memory and +self+.
 
-[[vec_cp]]
-+vec* vec_cp(vec *self)+
-~~~~~~~~~~~~~~~~~~~~~~~~
-Returns a copy of the vector +self+. All elements are kept in the same order.
+NOTE: All item pointers are still valid after a call to
+<<vec_free,+vec_free()+>>, <<vec_clear,+vec_clear()+>> should be called before
+if they are no longer needed to avoid memory leaks.
 
 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);
+vec *vector = vec_new();
+vec_free(vector);
 ----
-- 
cgit v1.1

