diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-15 20:27:51 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-02-15 20:27:51 +0100 |
commit | 5dae8f8d10d506abc3c75a1f66c1dfe620c84fc1 (patch) | |
tree | 2bfb6efef0535a35bab1da811a5f69cb5203dff9 /src/app/stack.hpp | |
parent | 9147551cd21d565f9503e3ebbcd2121e284d88d5 (diff) |
refactor: improve project design
Diffstat (limited to 'src/app/stack.hpp')
-rw-r--r-- | src/app/stack.hpp | 41 |
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" |