54f18408e72ad63bf5a613aa2b80be5747dd915dbde2fa7a8b3270bbe12f4d768b5973c0c15d4745dcc0e2cdeef4b8cf27c8cee4fb6042dcb59ba810e3679b 7.9 KB

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