654fc1eae94620d711cd7c35757e12e083c6f74f0536ee5eefb0cc8a42bdae57efacf7ea257dfdffd647d46a2747e4712078e288611f46d12ff06663cfb213 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. var __extends = this && this.t || function() {
  2. var extendStatics = function(t, r) {
  3. extendStatics = Object.setPrototypeOf || {
  4. __proto__: []
  5. } instanceof Array && function(t, r) {
  6. t.__proto__ = r;
  7. } || function(t, r) {
  8. for (var n in r) if (Object.prototype.hasOwnProperty.call(r, n)) t[n] = r[n];
  9. };
  10. return extendStatics(t, r);
  11. };
  12. return function(t, r) {
  13. if (typeof r !== "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
  14. extendStatics(t, r);
  15. function __() {
  16. this.constructor = t;
  17. }
  18. t.prototype = r === null ? Object.create(r) : (__.prototype = r.prototype, new __);
  19. };
  20. }();
  21. import { ContainerIterator } from "../../ContainerBase";
  22. import { throwIteratorAccessError } from "../../../utils/throwError";
  23. var RandomIterator = function(t) {
  24. __extends(RandomIterator, t);
  25. function RandomIterator(r, n) {
  26. var o = t.call(this, n) || this;
  27. o.o = r;
  28. if (o.iteratorType === 0) {
  29. o.pre = function() {
  30. if (this.o === 0) {
  31. throwIteratorAccessError();
  32. }
  33. this.o -= 1;
  34. return this;
  35. };
  36. o.next = function() {
  37. if (this.o === this.container.size()) {
  38. throwIteratorAccessError();
  39. }
  40. this.o += 1;
  41. return this;
  42. };
  43. } else {
  44. o.pre = function() {
  45. if (this.o === this.container.size() - 1) {
  46. throwIteratorAccessError();
  47. }
  48. this.o += 1;
  49. return this;
  50. };
  51. o.next = function() {
  52. if (this.o === -1) {
  53. throwIteratorAccessError();
  54. }
  55. this.o -= 1;
  56. return this;
  57. };
  58. }
  59. return o;
  60. }
  61. Object.defineProperty(RandomIterator.prototype, "pointer", {
  62. get: function() {
  63. return this.container.getElementByPos(this.o);
  64. },
  65. set: function(t) {
  66. this.container.setElementByPos(this.o, t);
  67. },
  68. enumerable: false,
  69. configurable: true
  70. });
  71. return RandomIterator;
  72. }(ContainerIterator);
  73. export { RandomIterator };
  74. //# sourceMappingURL=RandomIterator.js.map