From 65ddeea23e1303d0b2d9656601b90df138d19e6c Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 1 Jul 2020 16:19:16 -0400 Subject: Add start to vector --- collections/vector/vector.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 collections/vector/vector.h (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h new file mode 100644 index 0000000..5465108 --- /dev/null +++ b/collections/vector/vector.h @@ -0,0 +1,9 @@ +#ifndef VECTOR_H +#define VECTOR_H + +typedef struct vector vec; + +vec* vec_new(); +vec* vec_with_capacity(int); +int vec_size(vec*); +#endif -- cgit v1.1 From 0d09851c392829a6cbbd047f9a374b5c66eb4c98 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Thu, 2 Jul 2020 17:32:56 -0400 Subject: Add push for vector --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 5465108..b84217a 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -6,4 +6,5 @@ typedef struct vector vec; vec* vec_new(); vec* vec_with_capacity(int); int vec_size(vec*); +void vec_push(vec*, void*); #endif -- cgit v1.1 From 264857903db99135c8c09d12b3e8af93ac1c7f88 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Thu, 2 Jul 2020 19:07:46 -0400 Subject: Add index functionality to vectors --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index b84217a..63151ac 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -7,4 +7,5 @@ vec* vec_new(); vec* vec_with_capacity(int); int vec_size(vec*); void vec_push(vec*, void*); +void* vec_index(vec*, int); #endif -- cgit v1.1 From 98454f841b5ac87d2253c2fae0aba2525853f907 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Thu, 2 Jul 2020 19:16:19 -0400 Subject: Add pop to vectors --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 63151ac..81eea22 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -8,4 +8,5 @@ vec* vec_with_capacity(int); int vec_size(vec*); void vec_push(vec*, void*); void* vec_index(vec*, int); +void* vec_pop(vec*); #endif -- cgit v1.1 From e4ea23a6c23acdec86e5b5fcd34c653118f6898e Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Thu, 2 Jul 2020 19:20:05 -0400 Subject: Adds free & clear functions to vectors --- collections/vector/vector.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 81eea22..3996030 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -9,4 +9,6 @@ int vec_size(vec*); void vec_push(vec*, void*); void* vec_index(vec*, int); void* vec_pop(vec*); +void vec_free(vec*); +void vec_clear(vec*); #endif -- cgit v1.1 From 80d98a39a6bc4b71c74f240df617495e816b98b9 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Thu, 2 Jul 2020 20:21:28 -0400 Subject: Add printing functions for vectors --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 3996030..54e40a7 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -11,4 +11,5 @@ void* vec_index(vec*, int); void* vec_pop(vec*); void vec_free(vec*); void vec_clear(vec*); +void vec_print(vec*, char* (void*)); #endif -- cgit v1.1 From 8d5b381b540fe1d780311e4f4059dce014a6cb91 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 00:13:04 -0400 Subject: Add copy function for vector --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 54e40a7..229b4b0 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -12,4 +12,5 @@ void* vec_pop(vec*); void vec_free(vec*); void vec_clear(vec*); void vec_print(vec*, char* (void*)); +vec* vec_cp(vec*); #endif -- cgit v1.1 From aeee67bdda0e0f8834cbd3f65da99e3c79f69f65 Mon Sep 17 00:00:00 2001 From: Tucker Evans 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.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 229b4b0..5ab3dc3 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -3,14 +3,22 @@ typedef struct vector vec; +/*constructors*/ vec* vec_new(); vec* vec_with_capacity(int); + +/*management*/ int vec_size(vec*); +vec* vec_cp(vec*); +void vec_print(vec*, char* (void*)); + +/*data*/ void vec_push(vec*, void*); -void* vec_index(vec*, int); void* vec_pop(vec*); -void vec_free(vec*); + +void* vec_index(vec*, int); + +/*memory*/ void vec_clear(vec*); -void vec_print(vec*, char* (void*)); -vec* vec_cp(vec*); +void vec_free(vec*); #endif -- cgit v1.1 From 4832ab4b43a2e9fb72b1814b32421de1dba1edcb Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 00:40:50 -0400 Subject: Add function to get capacity of a vector --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 5ab3dc3..4bcb620 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -9,6 +9,7 @@ vec* vec_with_capacity(int); /*management*/ int vec_size(vec*); +int vec_capacity(vec*); vec* vec_cp(vec*); void vec_print(vec*, char* (void*)); -- cgit v1.1 From f900066b813fac2f34798c39f16dacda9a878610 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 00:52:26 -0400 Subject: Add back function to vectors back() returns the element in the last position without removing it. --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 4bcb620..f1eea64 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -16,6 +16,7 @@ void vec_print(vec*, char* (void*)); /*data*/ void vec_push(vec*, void*); void* vec_pop(vec*); +void* vec_back(vec*); void* vec_index(vec*, int); -- cgit v1.1 From b253b373ea74539a0f29a88ac2be728aa8158d2a Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 00:57:58 -0400 Subject: Add set index function for vectors --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index f1eea64..7d38694 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -18,6 +18,7 @@ void vec_push(vec*, void*); void* vec_pop(vec*); void* vec_back(vec*); +void vec_set(vec*, int, void*); void* vec_index(vec*, int); /*memory*/ -- cgit v1.1 From 72cb2e77024970509ff403670f9e4245bcefebd6 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 01:05:09 -0400 Subject: Add swap function to vectors --- collections/vector/vector.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 7d38694..2b1e8e9 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -21,6 +21,9 @@ void* vec_back(vec*); void vec_set(vec*, int, void*); void* vec_index(vec*, int); +void vec_swap(vec*, int, int); + + /*memory*/ void vec_clear(vec*); void vec_free(vec*); -- cgit v1.1 From 1a41fe605ab6bde15f622e72abb7aee846531fcf Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 01:18:17 -0400 Subject: Add swap_pop function for vectors --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 2b1e8e9..55e9481 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -22,6 +22,7 @@ void vec_set(vec*, int, void*); void* vec_index(vec*, int); void vec_swap(vec*, int, int); +void* vec_swap_pop(vec*, int); /*memory*/ -- cgit v1.1 From e6af2f70ec910ee8cb3813fa1e5b1c7d6e3ead60 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 23:49:15 -0400 Subject: Add insert function for vectors --- collections/vector/vector.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 55e9481..1b47642 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -21,6 +21,8 @@ void* vec_back(vec*); void vec_set(vec*, int, void*); void* vec_index(vec*, int); +void vec_insert(vec*, int, void*); + void vec_swap(vec*, int, int); void* vec_swap_pop(vec*, int); -- cgit v1.1 From a1d4279c40612e6f98564db43192929b41c59d40 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Fri, 3 Jul 2020 23:57:45 -0400 Subject: Add remove function for vectors Removes element at an index. --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 1b47642..083a1d0 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -22,6 +22,7 @@ void vec_set(vec*, int, void*); void* vec_index(vec*, int); void vec_insert(vec*, int, void*); +void* vec_remove(vec*, int); void vec_swap(vec*, int, int); void* vec_swap_pop(vec*, int); -- cgit v1.1 From 8874cf97227139ed10e75fe13108988b45492172 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Sat, 4 Jul 2020 22:06:49 -0400 Subject: Add truncate to vectors --- collections/vector/vector.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index 083a1d0..b997b46 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -29,6 +29,8 @@ void* vec_swap_pop(vec*, int); /*memory*/ +void vec_truncate(vec*, int); + void vec_clear(vec*); void vec_free(vec*); #endif -- cgit v1.1 From 5fa1551b4a0acc28d5c656479806511ab0c81a18 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Sat, 4 Jul 2020 22:17:27 -0400 Subject: Add reserve function to vectors --- collections/vector/vector.h | 1 + 1 file changed, 1 insertion(+) (limited to 'collections/vector/vector.h') diff --git a/collections/vector/vector.h b/collections/vector/vector.h index b997b46..4d6d04c 100644 --- a/collections/vector/vector.h +++ b/collections/vector/vector.h @@ -30,6 +30,7 @@ void* vec_swap_pop(vec*, int); /*memory*/ void vec_truncate(vec*, int); +void vec_reserve(vec*, int); void vec_clear(vec*); void vec_free(vec*); -- cgit v1.1