/** * @file fl_stack.h * @brief Fixed-length stack * * @date Jul 9, 2014 * @author Andrey Belomutskiy, (c) 2012-2014 */ #ifndef FL_STACK_H_ #define FL_STACK_H_ template class FLStack { public: FLStack(); void push(T value); void reset(); T pop(); int size(); bool isEmpty(); private: int index; T values[MAXSIZE]; }; template FLStack::FLStack() { reset(); } template bool FLStack::isEmpty() { return index == 0; } template void FLStack::reset() { index = 0; } template void FLStack::push(T value) { values[index++] = value; } template T FLStack::pop() { return values[--index]; } template int FLStack::size() { return index; } #endif /* FL_STACK_H_ */