Stack.js 619 B

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. Object.defineProperty(exports, "t", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _ContainerBase = require("../ContainerBase");
  7. class Stack extends _ContainerBase.Base {
  8. constructor(t = []) {
  9. super();
  10. this.C = [];
  11. t.forEach((t => this.push(t)));
  12. }
  13. clear() {
  14. this.o = 0;
  15. this.C.length = 0;
  16. }
  17. push(t) {
  18. this.C.push(t);
  19. this.o += 1;
  20. }
  21. pop() {
  22. this.C.pop();
  23. if (this.o > 0) this.o -= 1;
  24. }
  25. top() {
  26. return this.C[this.o - 1];
  27. }
  28. }
  29. var _default = Stack;
  30. exports.default = _default;