9ce4a3648b10b1bebe61a7b5e2e3348bfcd8de6ea9526ac11bd3adef76788e483bd674082ec5b764b9598ba2351854d62f903120cd3ae47822b4726f38bf4e 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. Object.defineProperty(exports, "t", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _ContainerBase = require("../ContainerBase");
  7. class Queue extends _ContainerBase.Base {
  8. constructor(t = []) {
  9. super();
  10. this.j = 0;
  11. this.q = [];
  12. const s = this;
  13. t.forEach((function(t) {
  14. s.push(t);
  15. }));
  16. }
  17. clear() {
  18. this.q = [];
  19. this.i = this.j = 0;
  20. }
  21. push(t) {
  22. const s = this.q.length;
  23. if (this.j / s > .5 && this.j + this.i >= s && s > 4096) {
  24. const s = this.i;
  25. for (let t = 0; t < s; ++t) {
  26. this.q[t] = this.q[this.j + t];
  27. }
  28. this.j = 0;
  29. this.q[this.i] = t;
  30. } else this.q[this.j + this.i] = t;
  31. return ++this.i;
  32. }
  33. pop() {
  34. if (this.i === 0) return;
  35. const t = this.q[this.j++];
  36. this.i -= 1;
  37. return t;
  38. }
  39. front() {
  40. if (this.i === 0) return;
  41. return this.q[this.j];
  42. }
  43. }
  44. var _default = Queue;
  45. exports.default = _default;
  46. //# sourceMappingURL=Queue.js.map