aboutsummaryrefslogtreecommitdiff
path: root/src/stack.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stack.hpp')
-rw-r--r--src/stack.hpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/stack.hpp b/src/stack.hpp
new file mode 100644
index 0000000..b156242
--- /dev/null
+++ b/src/stack.hpp
@@ -0,0 +1,43 @@
+#ifndef STACK_HPP
+#define STACK_HPP
+
+#include <vector>
+
+/**
+ * A stack data structure.
+ */
+template <typename Item>
+class Stack
+{
+public:
+ /**
+ * Creates a stack.
+ *
+ * @param capacity The capacity of the stack
+ */
+ Stack(int 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"
+
+#endif