summaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
authortalha <->2024-08-15 10:46:43 +0500
committertalha <->2024-08-15 10:46:43 +0500
commit0453b8f50dc4d40083e02cc3d09b4bcaa33f1700 (patch)
treedc9956d8b3be69d76cd03dd4d9b1e0d16dae0a14 /src/array.h
parent0cb9fa1c023033c250fd0bf33c2cee49fc85f178 (diff)
Added functionality, updated c to cpp:HEADmain
- Added entity arrays - Added memory arenas - moved c files to cpp - refactored files to work with lsp (still unity build) but more painful
Diffstat (limited to 'src/array.h')
-rw-r--r--src/array.h34
1 files changed, 34 insertions, 0 deletions
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);