diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-05-01 03:59:46 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-05-01 03:59:46 -0400 |
commit | aab7fe08faf2aec394174b2ee9782988bfc7fa30 (patch) | |
tree | aa4e6cbe1fb53e908c4e9f135fb45d47107b4f1a /include/osm | |
parent | feccf0adf3e6861b11a7768669a63c327f77ec10 (diff) |
Finish vector code
Diffstat (limited to 'include/osm')
-rw-r--r-- | include/osm/utils.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/include/osm/utils.h b/include/osm/utils.h index 5a53f41..441cce2 100644 --- a/include/osm/utils.h +++ b/include/osm/utils.h @@ -1,6 +1,8 @@ #ifndef OSM_UTILS_H #define OSM_UTILS_H +#include <stdbool.h> + // Vector utilities /** @@ -11,27 +13,30 @@ typedef struct { void *data; } Vector; +/** + * Get an initialized vector struct + */ Vector vect_init(unsigned int elsz); /** * Add an element to an arbitrary index in the vector */ -void vect_add(Vector *vec, unsigned int index); +bool vect_add(Vector *vec, unsigned int index, void *el); /** * Remove an element from an arbitrary index in the vector */ -void vect_remove(Vector *vec, unsigned int index); +bool vect_remove(Vector *vec, unsigned int index); /** * Push an element to the end of the vector */ -void vect_push(Vector *vec, void *el); +bool vect_push(Vector *vec, void *el); /** * Pop an element from the end of the vector */ -void vect_pop(Vector *vec); +bool vect_pop(Vector *vec); /** * Get an element from the vector @@ -41,7 +46,12 @@ void *vect_get(Vector *vec, unsigned int index); /** * Set an element inside the vector */ -void *vect_set(Vector *vec, unsigned int index, void *el); +bool vect_set(Vector *vec, unsigned int index, void *el); + +/** + * Clear all data in a vector + */ +void vect_clear(Vector *vec); /** * Remove all associated data from the vector |