11058042e3c4968c260d89a39175123f16c37a809a0207667456f88a7fd7f843e10bb69ad9c7cb11708d6bad60ff223c0c5573eb15cdeff86b78de3e2bb61c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. Object.defineProperty(exports, "t", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _Base = require("./Base");
  7. var _throwError = require("../../utils/throwError");
  8. class HashSetIterator extends _Base.HashContainerIterator {
  9. constructor(t, e, r, s) {
  10. super(t, e, s);
  11. this.container = r;
  12. }
  13. get pointer() {
  14. if (this.o === this.h) {
  15. (0, _throwError.throwIteratorAccessError)();
  16. }
  17. return this.o.u;
  18. }
  19. copy() {
  20. return new HashSetIterator(this.o, this.h, this.container, this.iteratorType);
  21. }
  22. }
  23. class HashSet extends _Base.HashContainer {
  24. constructor(t = []) {
  25. super();
  26. const e = this;
  27. t.forEach((function(t) {
  28. e.insert(t);
  29. }));
  30. }
  31. begin() {
  32. return new HashSetIterator(this.p, this.h, this);
  33. }
  34. end() {
  35. return new HashSetIterator(this.h, this.h, this);
  36. }
  37. rBegin() {
  38. return new HashSetIterator(this._, this.h, this, 1);
  39. }
  40. rEnd() {
  41. return new HashSetIterator(this.h, this.h, this, 1);
  42. }
  43. front() {
  44. return this.p.u;
  45. }
  46. back() {
  47. return this._.u;
  48. }
  49. insert(t, e) {
  50. return this.M(t, undefined, e);
  51. }
  52. getElementByPos(t) {
  53. if (t < 0 || t > this.i - 1) {
  54. throw new RangeError;
  55. }
  56. let e = this.p;
  57. while (t--) {
  58. e = e.B;
  59. }
  60. return e.u;
  61. }
  62. find(t, e) {
  63. const r = this.I(t, e);
  64. return new HashSetIterator(r, this.h, this);
  65. }
  66. forEach(t) {
  67. let e = 0;
  68. let r = this.p;
  69. while (r !== this.h) {
  70. t(r.u, e++, this);
  71. r = r.B;
  72. }
  73. }
  74. [Symbol.iterator]() {
  75. return function*() {
  76. let t = this.p;
  77. while (t !== this.h) {
  78. yield t.u;
  79. t = t.B;
  80. }
  81. }.bind(this)();
  82. }
  83. }
  84. var _default = HashSet;
  85. exports.default = _default;
  86. //# sourceMappingURL=HashSet.js.map