96f8dcd6404703692c6c500cf745ee941afe5b7f934af8881765a9ec295ca1e486c26d25b9f050d7f6456b8e9f88e5a4ede4404de1ba26cee1e26a8ddc300b 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var __extends = this && this.t || function() {
  2. var extendStatics = function(t, i) {
  3. extendStatics = Object.setPrototypeOf || {
  4. __proto__: []
  5. } instanceof Array && function(t, i) {
  6. t.__proto__ = i;
  7. } || function(t, i) {
  8. for (var n in i) if (Object.prototype.hasOwnProperty.call(i, n)) t[n] = i[n];
  9. };
  10. return extendStatics(t, i);
  11. };
  12. return function(t, i) {
  13. if (typeof i !== "function" && i !== null) throw new TypeError("Class extends value " + String(i) + " is not a constructor or null");
  14. extendStatics(t, i);
  15. function __() {
  16. this.constructor = t;
  17. }
  18. t.prototype = i === null ? Object.create(i) : (__.prototype = i.prototype, new __);
  19. };
  20. }();
  21. import { Base } from "../ContainerBase";
  22. var Queue = function(t) {
  23. __extends(Queue, t);
  24. function Queue(i) {
  25. if (i === void 0) {
  26. i = [];
  27. }
  28. var n = t.call(this) || this;
  29. n.A = 0;
  30. n.tt = [];
  31. var e = n;
  32. i.forEach((function(t) {
  33. e.push(t);
  34. }));
  35. return n;
  36. }
  37. Queue.prototype.clear = function() {
  38. this.tt = [];
  39. this.M = this.A = 0;
  40. };
  41. Queue.prototype.push = function(t) {
  42. var i = this.tt.length;
  43. if (this.A / i > .5 && this.A + this.M >= i && i > 4096) {
  44. var n = this.M;
  45. for (var e = 0; e < n; ++e) {
  46. this.tt[e] = this.tt[this.A + e];
  47. }
  48. this.A = 0;
  49. this.tt[this.M] = t;
  50. } else this.tt[this.A + this.M] = t;
  51. return ++this.M;
  52. };
  53. Queue.prototype.pop = function() {
  54. if (this.M === 0) return;
  55. var t = this.tt[this.A++];
  56. this.M -= 1;
  57. return t;
  58. };
  59. Queue.prototype.front = function() {
  60. if (this.M === 0) return;
  61. return this.tt[this.A];
  62. };
  63. return Queue;
  64. }(Base);
  65. export default Queue;
  66. //# sourceMappingURL=Queue.js.map