summaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
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);