From 0453b8f50dc4d40083e02cc3d09b4bcaa33f1700 Mon Sep 17 00:00:00 2001 From: talha <-> Date: Thu, 15 Aug 2024 10:46:43 +0500 Subject: Added functionality, updated c to cpp: - Added entity arrays - Added memory arenas - moved c files to cpp - refactored files to work with lsp (still unity build) but more painful --- src/array.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/array.h (limited to 'src/array.h') diff --git a/src/array.h b/src/array.h new file mode 100644 index 0000000..035e1ee --- /dev/null +++ b/src/array.h @@ -0,0 +1,34 @@ +#pragma once +#include "memory/memory.h" +#include "entity.h" + +struct EntityArr { + struct Entity *buffer; + unsigned int capacity; + unsigned int size; // used for mantaining a stack and queue +}; + +typedef EntityArr EntityArrayList; + +struct EntityArr entity_arr_init(struct Arena *arena, unsigned int size); + +// -- basic insert remove operations -- +void entity_arr_insert(struct EntityArr *arr, struct Entity to_insert, unsigned int index); +struct Entity entity_arr_remove(struct EntityArr *arr, struct Entity to_remove, unsigned int index); + +void entity_arr_push_head(struct EntityArr *arr, struct Entity value); +void entity_arr_push_tail(struct EntityArr *arr, struct Entity value); + +struct Entity entity_arr_pop_head(struct EntityArr *arr); +struct Entity entity_arr_pop_tail(struct EntityArr *arr); + +typedef EntityArr EntityQueue; +void entity_qpush(EntityQueue *queue, struct Entity value); +struct Entity entity_qpop(EntityQueue *queue); + +typedef EntityArr EntityStack; +void entity_spush(EntityStack *stack, struct Entity value); +struct Entity entity_spop(EntityStack *stack, struct Entity value); + +// -- operations on values -- +int entity_arr_find(struct EntityArr *arr, struct Entity value); -- cgit v1.2.3