123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #ifndef MATRIXSTACK_H
- #define MATRIXSTACK_H
- #include "math/Matrix.h"
- #include "utils/ArrayList.h"
- template<int N>
- class MatrixStack final {
- ArrayList<Matrix, N> stack;
- public:
- MatrixStack() {
- stack.add(Matrix());
- }
- bool pop() {
- stack.remove(stack.getLength() - 1);
- if(stack.getLength() == 0) {
- stack.add(Matrix());
- return true;
- }
- return false;
- }
- bool push() {
- return stack.add(peek());
- }
- Matrix& peek() {
- return stack[stack.getLength() - 1];
- }
- const Matrix& peek() const {
- return stack[stack.getLength() - 1];
- }
- void clear() {
- stack.clear();
- stack.add(Matrix());
- }
- template<int L>
- void toString(StringBuffer<L>& s) const {
- s.append(stack);
- }
- };
- #endif
|