diff options
author | HampusM <hampus@hampusmat.com> | 2022-01-09 21:47:23 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-01-09 21:47:23 +0100 |
commit | 8ceb79db1d0687bba005cef4a77bb889bf7ec3c3 (patch) | |
tree | b7c13359f652506d60c8556ea386ae8d50bfc5bc /src/stack.hpp | |
parent | 097aa95c1f0cb159e7d9d0a3edf9284c421ee298 (diff) |
refactor: rewrite to c++
Diffstat (limited to 'src/stack.hpp')
-rw-r--r-- | src/stack.hpp | 43 |
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 |