From 5dae8f8d10d506abc3c75a1f66c1dfe620c84fc1 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 15 Feb 2022 20:27:51 +0100 Subject: refactor: improve project design --- src/app/stack.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/app/stack.hpp (limited to 'src/app/stack.hpp') 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 +#include + +/** + * A stack data structure. + */ +template +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 _items; +}; + +#include "stack.tpp" -- cgit v1.2.3-18-g5258