aboutsummaryrefslogtreecommitdiff
path: root/stack.h
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-03-14 12:13:01 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-03-14 12:13:01 +0300
commit365f1baabae9b2ccb3df1b4a4821bff58611f2de (patch)
treeffe39de1013bab314f2bb64f68d0e368a3fe3493 /stack.h
parent90f365e0ff8cff6bc426d08a04a0ede63379fc3b (diff)
implement a PositionStack
Diffstat (limited to 'stack.h')
-rw-r--r--stack.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/stack.h b/stack.h
index 48fea92..a83a135 100644
--- a/stack.h
+++ b/stack.h
@@ -1,6 +1,22 @@
#ifndef STACK_H_
#define STACK_H_
-// TODO: implement a stack
+#include "structs.h"
+
+/* So, the implementation of the stack is array-based, for hyperspeed.
+ * For bigger maps we have to increase the STACK_SIZE, but it should
+ * work fine most of the time. I guess */
+#define STACK_SIZE 4096
+
+struct PositionStack_s {
+ Position arr[STACK_SIZE]; /* The array with all the values */
+ size_t top; /* Shows where the top of the stack is */
+};
+typedef struct PositionStack_s PositionStack;
+
+PositionStack ps_new(void); /* Returns an empty position stack */
+int ps_push(PositionStack ps, Position pos); /* Returns -1 if overflow */
+Position ps_pop(PositionStack ps);
+Position ps_peek(PositionStack ps);
#endif /* STACK_H_ */