9bb207301e91181eb454174ef5ed093ef7464ed3086e183e1bd2d45ff977c6857b5f71da571538d3f41c3d92132bf2007985c1fcc37515f092dd1f36ac1c7e 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. var __extends = this && this.t || function() {
  2. var extendStatics = function(e, t) {
  3. extendStatics = Object.setPrototypeOf || {
  4. __proto__: []
  5. } instanceof Array && function(e, t) {
  6. e.__proto__ = t;
  7. } || function(e, t) {
  8. for (var r in t) if (Object.prototype.hasOwnProperty.call(t, r)) e[r] = t[r];
  9. };
  10. return extendStatics(e, t);
  11. };
  12. return function(e, t) {
  13. if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
  14. extendStatics(e, t);
  15. function __() {
  16. this.constructor = e;
  17. }
  18. e.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
  19. };
  20. }();
  21. var __generator = this && this.i || function(e, t) {
  22. var r = {
  23. label: 0,
  24. sent: function() {
  25. if (o[0] & 1) throw o[1];
  26. return o[1];
  27. },
  28. trys: [],
  29. ops: []
  30. }, n, i, o, u;
  31. return u = {
  32. next: verb(0),
  33. throw: verb(1),
  34. return: verb(2)
  35. }, typeof Symbol === "function" && (u[Symbol.iterator] = function() {
  36. return this;
  37. }), u;
  38. function verb(e) {
  39. return function(t) {
  40. return step([ e, t ]);
  41. };
  42. }
  43. function step(u) {
  44. if (n) throw new TypeError("Generator is already executing.");
  45. while (r) try {
  46. if (n = 1, i && (o = u[0] & 2 ? i["return"] : u[0] ? i["throw"] || ((o = i["return"]) && o.call(i),
  47. 0) : i.next) && !(o = o.call(i, u[1])).done) return o;
  48. if (i = 0, o) u = [ u[0] & 2, o.value ];
  49. switch (u[0]) {
  50. case 0:
  51. case 1:
  52. o = u;
  53. break;
  54. case 4:
  55. r.label++;
  56. return {
  57. value: u[1],
  58. done: false
  59. };
  60. case 5:
  61. r.label++;
  62. i = u[1];
  63. u = [ 0 ];
  64. continue;
  65. case 7:
  66. u = r.ops.pop();
  67. r.trys.pop();
  68. continue;
  69. default:
  70. if (!(o = r.trys, o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
  71. r = 0;
  72. continue;
  73. }
  74. if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
  75. r.label = u[1];
  76. break;
  77. }
  78. if (u[0] === 6 && r.label < o[1]) {
  79. r.label = o[1];
  80. o = u;
  81. break;
  82. }
  83. if (o && r.label < o[2]) {
  84. r.label = o[2];
  85. r.ops.push(u);
  86. break;
  87. }
  88. if (o[2]) r.ops.pop();
  89. r.trys.pop();
  90. continue;
  91. }
  92. u = t.call(e, r);
  93. } catch (e) {
  94. u = [ 6, e ];
  95. i = 0;
  96. } finally {
  97. n = o = 0;
  98. }
  99. if (u[0] & 5) throw u[1];
  100. return {
  101. value: u[0] ? u[1] : void 0,
  102. done: true
  103. };
  104. }
  105. };
  106. var __values = this && this.V || function(e) {
  107. var t = typeof Symbol === "function" && Symbol.iterator, r = t && e[t], n = 0;
  108. if (r) return r.call(e);
  109. if (e && typeof e.length === "number") return {
  110. next: function() {
  111. if (e && n >= e.length) e = void 0;
  112. return {
  113. value: e && e[n++],
  114. done: !e
  115. };
  116. }
  117. };
  118. throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
  119. };
  120. import TreeContainer from "./Base";
  121. import TreeIterator from "./Base/TreeIterator";
  122. import { throwIteratorAccessError } from "../../utils/throwError";
  123. var OrderedSetIterator = function(e) {
  124. __extends(OrderedSetIterator, e);
  125. function OrderedSetIterator(t, r, n, i) {
  126. var o = e.call(this, t, r, i) || this;
  127. o.container = n;
  128. return o;
  129. }
  130. Object.defineProperty(OrderedSetIterator.prototype, "pointer", {
  131. get: function() {
  132. if (this.o === this.h) {
  133. throwIteratorAccessError();
  134. }
  135. return this.o.u;
  136. },
  137. enumerable: false,
  138. configurable: true
  139. });
  140. OrderedSetIterator.prototype.copy = function() {
  141. return new OrderedSetIterator(this.o, this.h, this.container, this.iteratorType);
  142. };
  143. return OrderedSetIterator;
  144. }(TreeIterator);
  145. var OrderedSet = function(e) {
  146. __extends(OrderedSet, e);
  147. function OrderedSet(t, r, n) {
  148. if (t === void 0) {
  149. t = [];
  150. }
  151. var i = e.call(this, r, n) || this;
  152. var o = i;
  153. t.forEach((function(e) {
  154. o.insert(e);
  155. }));
  156. return i;
  157. }
  158. OrderedSet.prototype.P = function(e) {
  159. return __generator(this, (function(t) {
  160. switch (t.label) {
  161. case 0:
  162. if (e === undefined) return [ 2 ];
  163. return [ 5, __values(this.P(e.K)) ];
  164. case 1:
  165. t.sent();
  166. return [ 4, e.u ];
  167. case 2:
  168. t.sent();
  169. return [ 5, __values(this.P(e.N)) ];
  170. case 3:
  171. t.sent();
  172. return [ 2 ];
  173. }
  174. }));
  175. };
  176. OrderedSet.prototype.begin = function() {
  177. return new OrderedSetIterator(this.h.K || this.h, this.h, this);
  178. };
  179. OrderedSet.prototype.end = function() {
  180. return new OrderedSetIterator(this.h, this.h, this);
  181. };
  182. OrderedSet.prototype.rBegin = function() {
  183. return new OrderedSetIterator(this.h.N || this.h, this.h, this, 1);
  184. };
  185. OrderedSet.prototype.rEnd = function() {
  186. return new OrderedSetIterator(this.h, this.h, this, 1);
  187. };
  188. OrderedSet.prototype.front = function() {
  189. return this.h.K ? this.h.K.u : undefined;
  190. };
  191. OrderedSet.prototype.back = function() {
  192. return this.h.N ? this.h.N.u : undefined;
  193. };
  194. OrderedSet.prototype.insert = function(e, t) {
  195. return this.v(e, undefined, t);
  196. };
  197. OrderedSet.prototype.find = function(e) {
  198. var t = this.g(this.W, e);
  199. return new OrderedSetIterator(t, this.h, this);
  200. };
  201. OrderedSet.prototype.lowerBound = function(e) {
  202. var t = this.U(this.W, e);
  203. return new OrderedSetIterator(t, this.h, this);
  204. };
  205. OrderedSet.prototype.upperBound = function(e) {
  206. var t = this.X(this.W, e);
  207. return new OrderedSetIterator(t, this.h, this);
  208. };
  209. OrderedSet.prototype.reverseLowerBound = function(e) {
  210. var t = this.Y(this.W, e);
  211. return new OrderedSetIterator(t, this.h, this);
  212. };
  213. OrderedSet.prototype.reverseUpperBound = function(e) {
  214. var t = this.Z(this.W, e);
  215. return new OrderedSetIterator(t, this.h, this);
  216. };
  217. OrderedSet.prototype.union = function(e) {
  218. var t = this;
  219. e.forEach((function(e) {
  220. t.insert(e);
  221. }));
  222. return this.M;
  223. };
  224. OrderedSet.prototype[Symbol.iterator] = function() {
  225. return this.P(this.W);
  226. };
  227. return OrderedSet;
  228. }(TreeContainer);
  229. export default OrderedSet;
  230. //# sourceMappingURL=OrderedSet.js.map