aboutsummaryrefslogtreecommitdiff
path: root/src/app/stack.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/stack.hpp')
-rw-r--r--src/app/stack.hpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/app/stack.hpp b/src/app/stack.hpp
new file mode 100644
index 0000000..11f7405
--- /dev/null
+++ b/src/app/stack.hpp
@@ -0,0 +1,41 @@
+#pragma once
+
+#include <cstdint>
+#include <vector>
+
+/**
+ * A stack data structure.
+ */
+template <typename Item>
+class Stack
+{
+public:
+ /**
+ * Creates a stack.
+ *
+ * @param capacity The capacity of the stack
+ */
+ explicit Stack(uint64_t capacity);
+
+ /**
+ * Pushes a item onto the stack.
+ */
+ void push(Item item);
+
+ /**
+ * Pops the topmost item from the stack.
+ */
+ void pop();
+
+ /**
+ * Peeks into the stack.
+ *
+ * @returns The topmost stack item.
+ */
+ Item peek();
+
+private:
+ std::vector<Item> _items;
+};
+
+#include "stack.tpp"