#ifndef STACK_H #define STACK_H #include "data/List.h" template class Stack final { List data; public: template Stack& push(Args&&... args) { data.add(std::forward(args)...); return *this; } void clear() { data.clear(); } bool pop() { if(data.getLength() <= 0) { return true; } data.remove(data.getLength() - 1); return false; } bool isEmpty() const { return data.getLength() == 0; } T& peek() { return data[data.getLength() - 1]; } const T& peek() const { return data[data.getLength() - 1]; } template void toString(StringBuffer& s) const { s.append(data); } }; #endif