3c12b87c0edab071bb529edb491be9945aa746f2ac4318d333edf26a597dbdc94d7f5cdf121d791b4c765f76568ed907e11c8777bff2ab5ceaf1f74c30cca6 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 e in r) if (Object.prototype.hasOwnProperty.call(r, e)) t[e] = r[e];
  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. var __generator = this && this.i || function(t, r) {
  22. var e = {
  23. label: 0,
  24. sent: function() {
  25. if (s[0] & 1) throw s[1];
  26. return s[1];
  27. },
  28. trys: [],
  29. ops: []
  30. }, n, i, s, a;
  31. return a = {
  32. next: verb(0),
  33. throw: verb(1),
  34. return: verb(2)
  35. }, typeof Symbol === "function" && (a[Symbol.iterator] = function() {
  36. return this;
  37. }), a;
  38. function verb(t) {
  39. return function(r) {
  40. return step([ t, r ]);
  41. };
  42. }
  43. function step(a) {
  44. if (n) throw new TypeError("Generator is already executing.");
  45. while (e) try {
  46. if (n = 1, i && (s = a[0] & 2 ? i["return"] : a[0] ? i["throw"] || ((s = i["return"]) && s.call(i),
  47. 0) : i.next) && !(s = s.call(i, a[1])).done) return s;
  48. if (i = 0, s) a = [ a[0] & 2, s.value ];
  49. switch (a[0]) {
  50. case 0:
  51. case 1:
  52. s = a;
  53. break;
  54. case 4:
  55. e.label++;
  56. return {
  57. value: a[1],
  58. done: false
  59. };
  60. case 5:
  61. e.label++;
  62. i = a[1];
  63. a = [ 0 ];
  64. continue;
  65. case 7:
  66. a = e.ops.pop();
  67. e.trys.pop();
  68. continue;
  69. default:
  70. if (!(s = e.trys, s = s.length > 0 && s[s.length - 1]) && (a[0] === 6 || a[0] === 2)) {
  71. e = 0;
  72. continue;
  73. }
  74. if (a[0] === 3 && (!s || a[1] > s[0] && a[1] < s[3])) {
  75. e.label = a[1];
  76. break;
  77. }
  78. if (a[0] === 6 && e.label < s[1]) {
  79. e.label = s[1];
  80. s = a;
  81. break;
  82. }
  83. if (s && e.label < s[2]) {
  84. e.label = s[2];
  85. e.ops.push(a);
  86. break;
  87. }
  88. if (s[2]) e.ops.pop();
  89. e.trys.pop();
  90. continue;
  91. }
  92. a = r.call(t, e);
  93. } catch (t) {
  94. a = [ 6, t ];
  95. i = 0;
  96. } finally {
  97. n = s = 0;
  98. }
  99. if (a[0] & 5) throw a[1];
  100. return {
  101. value: a[0] ? a[1] : void 0,
  102. done: true
  103. };
  104. }
  105. };
  106. import { HashContainer, HashContainerIterator } from "./Base";
  107. import { throwIteratorAccessError } from "../../utils/throwError";
  108. var HashSetIterator = function(t) {
  109. __extends(HashSetIterator, t);
  110. function HashSetIterator(r, e, n, i) {
  111. var s = t.call(this, r, e, i) || this;
  112. s.container = n;
  113. return s;
  114. }
  115. Object.defineProperty(HashSetIterator.prototype, "pointer", {
  116. get: function() {
  117. if (this.o === this.h) {
  118. throwIteratorAccessError();
  119. }
  120. return this.o.u;
  121. },
  122. enumerable: false,
  123. configurable: true
  124. });
  125. HashSetIterator.prototype.copy = function() {
  126. return new HashSetIterator(this.o, this.h, this.container, this.iteratorType);
  127. };
  128. return HashSetIterator;
  129. }(HashContainerIterator);
  130. var HashSet = function(t) {
  131. __extends(HashSet, t);
  132. function HashSet(r) {
  133. if (r === void 0) {
  134. r = [];
  135. }
  136. var e = t.call(this) || this;
  137. var n = e;
  138. r.forEach((function(t) {
  139. n.insert(t);
  140. }));
  141. return e;
  142. }
  143. HashSet.prototype.begin = function() {
  144. return new HashSetIterator(this.H, this.h, this);
  145. };
  146. HashSet.prototype.end = function() {
  147. return new HashSetIterator(this.h, this.h, this);
  148. };
  149. HashSet.prototype.rBegin = function() {
  150. return new HashSetIterator(this.l, this.h, this, 1);
  151. };
  152. HashSet.prototype.rEnd = function() {
  153. return new HashSetIterator(this.h, this.h, this, 1);
  154. };
  155. HashSet.prototype.front = function() {
  156. return this.H.u;
  157. };
  158. HashSet.prototype.back = function() {
  159. return this.l.u;
  160. };
  161. HashSet.prototype.insert = function(t, r) {
  162. return this.v(t, undefined, r);
  163. };
  164. HashSet.prototype.getElementByPos = function(t) {
  165. if (t < 0 || t > this.M - 1) {
  166. throw new RangeError;
  167. }
  168. var r = this.H;
  169. while (t--) {
  170. r = r.m;
  171. }
  172. return r.u;
  173. };
  174. HashSet.prototype.find = function(t, r) {
  175. var e = this.g(t, r);
  176. return new HashSetIterator(e, this.h, this);
  177. };
  178. HashSet.prototype.forEach = function(t) {
  179. var r = 0;
  180. var e = this.H;
  181. while (e !== this.h) {
  182. t(e.u, r++, this);
  183. e = e.m;
  184. }
  185. };
  186. HashSet.prototype[Symbol.iterator] = function() {
  187. return function() {
  188. var t;
  189. return __generator(this, (function(r) {
  190. switch (r.label) {
  191. case 0:
  192. t = this.H;
  193. r.label = 1;
  194. case 1:
  195. if (!(t !== this.h)) return [ 3, 3 ];
  196. return [ 4, t.u ];
  197. case 2:
  198. r.sent();
  199. t = t.m;
  200. return [ 3, 1 ];
  201. case 3:
  202. return [ 2 ];
  203. }
  204. }));
  205. }.bind(this)();
  206. };
  207. return HashSet;
  208. }(HashContainer);
  209. export default HashSet;
  210. //# sourceMappingURL=HashSet.js.map