index.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  1. var extendStatics = function(e, r) {
  2. extendStatics = Object.setPrototypeOf || {
  3. __proto__: []
  4. } instanceof Array && function(e, r) {
  5. e.__proto__ = r;
  6. } || function(e, r) {
  7. for (var t in r) if (Object.prototype.hasOwnProperty.call(r, t)) e[t] = r[t];
  8. };
  9. return extendStatics(e, r);
  10. };
  11. function __extends(e, r) {
  12. if (typeof r !== "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
  13. extendStatics(e, r);
  14. function __() {
  15. this.constructor = e;
  16. }
  17. e.prototype = r === null ? Object.create(r) : (__.prototype = r.prototype, new __);
  18. }
  19. function __generator(e, r) {
  20. var t = {
  21. label: 0,
  22. sent: function() {
  23. if (s[0] & 1) throw s[1];
  24. return s[1];
  25. },
  26. trys: [],
  27. ops: []
  28. }, i, n, s, h;
  29. return h = {
  30. next: verb(0),
  31. throw: verb(1),
  32. return: verb(2)
  33. }, typeof Symbol === "function" && (h[Symbol.iterator] = function() {
  34. return this;
  35. }), h;
  36. function verb(e) {
  37. return function(r) {
  38. return step([ e, r ]);
  39. };
  40. }
  41. function step(a) {
  42. if (i) throw new TypeError("Generator is already executing.");
  43. while (h && (h = 0, a[0] && (t = 0)), t) try {
  44. if (i = 1, n && (s = a[0] & 2 ? n["return"] : a[0] ? n["throw"] || ((s = n["return"]) && s.call(n),
  45. 0) : n.next) && !(s = s.call(n, a[1])).done) return s;
  46. if (n = 0, s) a = [ a[0] & 2, s.value ];
  47. switch (a[0]) {
  48. case 0:
  49. case 1:
  50. s = a;
  51. break;
  52. case 4:
  53. t.label++;
  54. return {
  55. value: a[1],
  56. done: false
  57. };
  58. case 5:
  59. t.label++;
  60. n = a[1];
  61. a = [ 0 ];
  62. continue;
  63. case 7:
  64. a = t.ops.pop();
  65. t.trys.pop();
  66. continue;
  67. default:
  68. if (!(s = t.trys, s = s.length > 0 && s[s.length - 1]) && (a[0] === 6 || a[0] === 2)) {
  69. t = 0;
  70. continue;
  71. }
  72. if (a[0] === 3 && (!s || a[1] > s[0] && a[1] < s[3])) {
  73. t.label = a[1];
  74. break;
  75. }
  76. if (a[0] === 6 && t.label < s[1]) {
  77. t.label = s[1];
  78. s = a;
  79. break;
  80. }
  81. if (s && t.label < s[2]) {
  82. t.label = s[2];
  83. t.ops.push(a);
  84. break;
  85. }
  86. if (s[2]) t.ops.pop();
  87. t.trys.pop();
  88. continue;
  89. }
  90. a = r.call(e, t);
  91. } catch (e) {
  92. a = [ 6, e ];
  93. n = 0;
  94. } finally {
  95. i = s = 0;
  96. }
  97. if (a[0] & 5) throw a[1];
  98. return {
  99. value: a[0] ? a[1] : void 0,
  100. done: true
  101. };
  102. }
  103. }
  104. typeof SuppressedError === "function" ? SuppressedError : function(e, r, t) {
  105. var i = new Error(t);
  106. return i.name = "SuppressedError", i.error = e, i.suppressed = r, i;
  107. };
  108. var TreeNode = function() {
  109. function TreeNode(e, r, t) {
  110. if (t === void 0) {
  111. t = 1;
  112. }
  113. this.t = undefined;
  114. this.i = undefined;
  115. this.h = undefined;
  116. this.u = e;
  117. this.o = r;
  118. this.l = t;
  119. }
  120. TreeNode.prototype.v = function() {
  121. var e = this;
  122. var r = e.h.h === e;
  123. if (r && e.l === 1) {
  124. e = e.i;
  125. } else if (e.t) {
  126. e = e.t;
  127. while (e.i) {
  128. e = e.i;
  129. }
  130. } else {
  131. if (r) {
  132. return e.h;
  133. }
  134. var t = e.h;
  135. while (t.t === e) {
  136. e = t;
  137. t = e.h;
  138. }
  139. e = t;
  140. }
  141. return e;
  142. };
  143. TreeNode.prototype.p = function() {
  144. var e = this;
  145. if (e.i) {
  146. e = e.i;
  147. while (e.t) {
  148. e = e.t;
  149. }
  150. return e;
  151. } else {
  152. var r = e.h;
  153. while (r.i === e) {
  154. e = r;
  155. r = e.h;
  156. }
  157. if (e.i !== r) {
  158. return r;
  159. } else return e;
  160. }
  161. };
  162. TreeNode.prototype.T = function() {
  163. var e = this.h;
  164. var r = this.i;
  165. var t = r.t;
  166. if (e.h === this) e.h = r; else if (e.t === this) e.t = r; else e.i = r;
  167. r.h = e;
  168. r.t = this;
  169. this.h = r;
  170. this.i = t;
  171. if (t) t.h = this;
  172. return r;
  173. };
  174. TreeNode.prototype.I = function() {
  175. var e = this.h;
  176. var r = this.t;
  177. var t = r.i;
  178. if (e.h === this) e.h = r; else if (e.t === this) e.t = r; else e.i = r;
  179. r.h = e;
  180. r.i = this;
  181. this.h = r;
  182. this.t = t;
  183. if (t) t.h = this;
  184. return r;
  185. };
  186. return TreeNode;
  187. }();
  188. var TreeNodeEnableIndex = function(e) {
  189. __extends(TreeNodeEnableIndex, e);
  190. function TreeNodeEnableIndex() {
  191. var r = e !== null && e.apply(this, arguments) || this;
  192. r.O = 1;
  193. return r;
  194. }
  195. TreeNodeEnableIndex.prototype.T = function() {
  196. var r = e.prototype.T.call(this);
  197. this.M();
  198. r.M();
  199. return r;
  200. };
  201. TreeNodeEnableIndex.prototype.I = function() {
  202. var r = e.prototype.I.call(this);
  203. this.M();
  204. r.M();
  205. return r;
  206. };
  207. TreeNodeEnableIndex.prototype.M = function() {
  208. this.O = 1;
  209. if (this.t) {
  210. this.O += this.t.O;
  211. }
  212. if (this.i) {
  213. this.O += this.i.O;
  214. }
  215. };
  216. return TreeNodeEnableIndex;
  217. }(TreeNode);
  218. var ContainerIterator = function() {
  219. function ContainerIterator(e) {
  220. if (e === void 0) {
  221. e = 0;
  222. }
  223. this.iteratorType = e;
  224. }
  225. ContainerIterator.prototype.equals = function(e) {
  226. return this.C === e.C;
  227. };
  228. return ContainerIterator;
  229. }();
  230. var Base = function() {
  231. function Base() {
  232. this._ = 0;
  233. }
  234. Object.defineProperty(Base.prototype, "length", {
  235. get: function() {
  236. return this._;
  237. },
  238. enumerable: false,
  239. configurable: true
  240. });
  241. Base.prototype.size = function() {
  242. return this._;
  243. };
  244. Base.prototype.empty = function() {
  245. return this._ === 0;
  246. };
  247. return Base;
  248. }();
  249. var Container = function(e) {
  250. __extends(Container, e);
  251. function Container() {
  252. return e !== null && e.apply(this, arguments) || this;
  253. }
  254. return Container;
  255. }(Base);
  256. function throwIteratorAccessError() {
  257. throw new RangeError("Iterator access denied!");
  258. }
  259. var TreeContainer = function(e) {
  260. __extends(TreeContainer, e);
  261. function TreeContainer(r, t) {
  262. if (r === void 0) {
  263. r = function(e, r) {
  264. if (e < r) return -1;
  265. if (e > r) return 1;
  266. return 0;
  267. };
  268. }
  269. if (t === void 0) {
  270. t = false;
  271. }
  272. var i = e.call(this) || this;
  273. i.N = undefined;
  274. i.g = r;
  275. i.enableIndex = t;
  276. i.S = t ? TreeNodeEnableIndex : TreeNode;
  277. i.A = new i.S;
  278. return i;
  279. }
  280. TreeContainer.prototype.m = function(e, r) {
  281. var t = this.A;
  282. while (e) {
  283. var i = this.g(e.u, r);
  284. if (i < 0) {
  285. e = e.i;
  286. } else if (i > 0) {
  287. t = e;
  288. e = e.t;
  289. } else return e;
  290. }
  291. return t;
  292. };
  293. TreeContainer.prototype.B = function(e, r) {
  294. var t = this.A;
  295. while (e) {
  296. var i = this.g(e.u, r);
  297. if (i <= 0) {
  298. e = e.i;
  299. } else {
  300. t = e;
  301. e = e.t;
  302. }
  303. }
  304. return t;
  305. };
  306. TreeContainer.prototype.j = function(e, r) {
  307. var t = this.A;
  308. while (e) {
  309. var i = this.g(e.u, r);
  310. if (i < 0) {
  311. t = e;
  312. e = e.i;
  313. } else if (i > 0) {
  314. e = e.t;
  315. } else return e;
  316. }
  317. return t;
  318. };
  319. TreeContainer.prototype.k = function(e, r) {
  320. var t = this.A;
  321. while (e) {
  322. var i = this.g(e.u, r);
  323. if (i < 0) {
  324. t = e;
  325. e = e.i;
  326. } else {
  327. e = e.t;
  328. }
  329. }
  330. return t;
  331. };
  332. TreeContainer.prototype.R = function(e) {
  333. while (true) {
  334. var r = e.h;
  335. if (r === this.A) return;
  336. if (e.l === 1) {
  337. e.l = 0;
  338. return;
  339. }
  340. if (e === r.t) {
  341. var t = r.i;
  342. if (t.l === 1) {
  343. t.l = 0;
  344. r.l = 1;
  345. if (r === this.N) {
  346. this.N = r.T();
  347. } else r.T();
  348. } else {
  349. if (t.i && t.i.l === 1) {
  350. t.l = r.l;
  351. r.l = 0;
  352. t.i.l = 0;
  353. if (r === this.N) {
  354. this.N = r.T();
  355. } else r.T();
  356. return;
  357. } else if (t.t && t.t.l === 1) {
  358. t.l = 1;
  359. t.t.l = 0;
  360. t.I();
  361. } else {
  362. t.l = 1;
  363. e = r;
  364. }
  365. }
  366. } else {
  367. var t = r.t;
  368. if (t.l === 1) {
  369. t.l = 0;
  370. r.l = 1;
  371. if (r === this.N) {
  372. this.N = r.I();
  373. } else r.I();
  374. } else {
  375. if (t.t && t.t.l === 1) {
  376. t.l = r.l;
  377. r.l = 0;
  378. t.t.l = 0;
  379. if (r === this.N) {
  380. this.N = r.I();
  381. } else r.I();
  382. return;
  383. } else if (t.i && t.i.l === 1) {
  384. t.l = 1;
  385. t.i.l = 0;
  386. t.T();
  387. } else {
  388. t.l = 1;
  389. e = r;
  390. }
  391. }
  392. }
  393. }
  394. };
  395. TreeContainer.prototype.G = function(e) {
  396. if (this._ === 1) {
  397. this.clear();
  398. return;
  399. }
  400. var r = e;
  401. while (r.t || r.i) {
  402. if (r.i) {
  403. r = r.i;
  404. while (r.t) r = r.t;
  405. } else {
  406. r = r.t;
  407. }
  408. var t = e.u;
  409. e.u = r.u;
  410. r.u = t;
  411. var i = e.o;
  412. e.o = r.o;
  413. r.o = i;
  414. e = r;
  415. }
  416. if (this.A.t === r) {
  417. this.A.t = r.h;
  418. } else if (this.A.i === r) {
  419. this.A.i = r.h;
  420. }
  421. this.R(r);
  422. var n = r.h;
  423. if (r === n.t) {
  424. n.t = undefined;
  425. } else n.i = undefined;
  426. this._ -= 1;
  427. this.N.l = 0;
  428. if (this.enableIndex) {
  429. while (n !== this.A) {
  430. n.O -= 1;
  431. n = n.h;
  432. }
  433. }
  434. };
  435. TreeContainer.prototype.P = function(e) {
  436. var r = typeof e === "number" ? e : undefined;
  437. var t = typeof e === "function" ? e : undefined;
  438. var i = typeof e === "undefined" ? [] : undefined;
  439. var n = 0;
  440. var s = this.N;
  441. var h = [];
  442. while (h.length || s) {
  443. if (s) {
  444. h.push(s);
  445. s = s.t;
  446. } else {
  447. s = h.pop();
  448. if (n === r) return s;
  449. i && i.push(s);
  450. t && t(s, n, this);
  451. n += 1;
  452. s = s.i;
  453. }
  454. }
  455. return i;
  456. };
  457. TreeContainer.prototype.q = function(e) {
  458. while (true) {
  459. var r = e.h;
  460. if (r.l === 0) return;
  461. var t = r.h;
  462. if (r === t.t) {
  463. var i = t.i;
  464. if (i && i.l === 1) {
  465. i.l = r.l = 0;
  466. if (t === this.N) return;
  467. t.l = 1;
  468. e = t;
  469. continue;
  470. } else if (e === r.i) {
  471. e.l = 0;
  472. if (e.t) {
  473. e.t.h = r;
  474. }
  475. if (e.i) {
  476. e.i.h = t;
  477. }
  478. r.i = e.t;
  479. t.t = e.i;
  480. e.t = r;
  481. e.i = t;
  482. if (t === this.N) {
  483. this.N = e;
  484. this.A.h = e;
  485. } else {
  486. var n = t.h;
  487. if (n.t === t) {
  488. n.t = e;
  489. } else n.i = e;
  490. }
  491. e.h = t.h;
  492. r.h = e;
  493. t.h = e;
  494. t.l = 1;
  495. } else {
  496. r.l = 0;
  497. if (t === this.N) {
  498. this.N = t.I();
  499. } else t.I();
  500. t.l = 1;
  501. return;
  502. }
  503. } else {
  504. var i = t.t;
  505. if (i && i.l === 1) {
  506. i.l = r.l = 0;
  507. if (t === this.N) return;
  508. t.l = 1;
  509. e = t;
  510. continue;
  511. } else if (e === r.t) {
  512. e.l = 0;
  513. if (e.t) {
  514. e.t.h = t;
  515. }
  516. if (e.i) {
  517. e.i.h = r;
  518. }
  519. t.i = e.t;
  520. r.t = e.i;
  521. e.t = t;
  522. e.i = r;
  523. if (t === this.N) {
  524. this.N = e;
  525. this.A.h = e;
  526. } else {
  527. var n = t.h;
  528. if (n.t === t) {
  529. n.t = e;
  530. } else n.i = e;
  531. }
  532. e.h = t.h;
  533. r.h = e;
  534. t.h = e;
  535. t.l = 1;
  536. } else {
  537. r.l = 0;
  538. if (t === this.N) {
  539. this.N = t.T();
  540. } else t.T();
  541. t.l = 1;
  542. return;
  543. }
  544. }
  545. if (this.enableIndex) {
  546. r.M();
  547. t.M();
  548. e.M();
  549. }
  550. return;
  551. }
  552. };
  553. TreeContainer.prototype.D = function(e, r, t) {
  554. if (this.N === undefined) {
  555. this._ += 1;
  556. this.N = new this.S(e, r, 0);
  557. this.N.h = this.A;
  558. this.A.h = this.A.t = this.A.i = this.N;
  559. return this._;
  560. }
  561. var i;
  562. var n = this.A.t;
  563. var s = this.g(n.u, e);
  564. if (s === 0) {
  565. n.o = r;
  566. return this._;
  567. } else if (s > 0) {
  568. n.t = new this.S(e, r);
  569. n.t.h = n;
  570. i = n.t;
  571. this.A.t = i;
  572. } else {
  573. var h = this.A.i;
  574. var a = this.g(h.u, e);
  575. if (a === 0) {
  576. h.o = r;
  577. return this._;
  578. } else if (a < 0) {
  579. h.i = new this.S(e, r);
  580. h.i.h = h;
  581. i = h.i;
  582. this.A.i = i;
  583. } else {
  584. if (t !== undefined) {
  585. var u = t.C;
  586. if (u !== this.A) {
  587. var f = this.g(u.u, e);
  588. if (f === 0) {
  589. u.o = r;
  590. return this._;
  591. } else if (f > 0) {
  592. var o = u.v();
  593. var d = this.g(o.u, e);
  594. if (d === 0) {
  595. o.o = r;
  596. return this._;
  597. } else if (d < 0) {
  598. i = new this.S(e, r);
  599. if (o.i === undefined) {
  600. o.i = i;
  601. i.h = o;
  602. } else {
  603. u.t = i;
  604. i.h = u;
  605. }
  606. }
  607. }
  608. }
  609. }
  610. if (i === undefined) {
  611. i = this.N;
  612. while (true) {
  613. var c = this.g(i.u, e);
  614. if (c > 0) {
  615. if (i.t === undefined) {
  616. i.t = new this.S(e, r);
  617. i.t.h = i;
  618. i = i.t;
  619. break;
  620. }
  621. i = i.t;
  622. } else if (c < 0) {
  623. if (i.i === undefined) {
  624. i.i = new this.S(e, r);
  625. i.i.h = i;
  626. i = i.i;
  627. break;
  628. }
  629. i = i.i;
  630. } else {
  631. i.o = r;
  632. return this._;
  633. }
  634. }
  635. }
  636. }
  637. }
  638. if (this.enableIndex) {
  639. var l = i.h;
  640. while (l !== this.A) {
  641. l.O += 1;
  642. l = l.h;
  643. }
  644. }
  645. this.q(i);
  646. this._ += 1;
  647. return this._;
  648. };
  649. TreeContainer.prototype.F = function(e, r) {
  650. while (e) {
  651. var t = this.g(e.u, r);
  652. if (t < 0) {
  653. e = e.i;
  654. } else if (t > 0) {
  655. e = e.t;
  656. } else return e;
  657. }
  658. return e || this.A;
  659. };
  660. TreeContainer.prototype.clear = function() {
  661. this._ = 0;
  662. this.N = undefined;
  663. this.A.h = undefined;
  664. this.A.t = this.A.i = undefined;
  665. };
  666. TreeContainer.prototype.updateKeyByIterator = function(e, r) {
  667. var t = e.C;
  668. if (t === this.A) {
  669. throwIteratorAccessError();
  670. }
  671. if (this._ === 1) {
  672. t.u = r;
  673. return true;
  674. }
  675. var i = t.p().u;
  676. if (t === this.A.t) {
  677. if (this.g(i, r) > 0) {
  678. t.u = r;
  679. return true;
  680. }
  681. return false;
  682. }
  683. var n = t.v().u;
  684. if (t === this.A.i) {
  685. if (this.g(n, r) < 0) {
  686. t.u = r;
  687. return true;
  688. }
  689. return false;
  690. }
  691. if (this.g(n, r) >= 0 || this.g(i, r) <= 0) return false;
  692. t.u = r;
  693. return true;
  694. };
  695. TreeContainer.prototype.eraseElementByPos = function(e) {
  696. if (e < 0 || e > this._ - 1) {
  697. throw new RangeError;
  698. }
  699. var r = this.P(e);
  700. this.G(r);
  701. return this._;
  702. };
  703. TreeContainer.prototype.eraseElementByKey = function(e) {
  704. if (this._ === 0) return false;
  705. var r = this.F(this.N, e);
  706. if (r === this.A) return false;
  707. this.G(r);
  708. return true;
  709. };
  710. TreeContainer.prototype.eraseElementByIterator = function(e) {
  711. var r = e.C;
  712. if (r === this.A) {
  713. throwIteratorAccessError();
  714. }
  715. var t = r.i === undefined;
  716. var i = e.iteratorType === 0;
  717. if (i) {
  718. if (t) e.next();
  719. } else {
  720. if (!t || r.t === undefined) e.next();
  721. }
  722. this.G(r);
  723. return e;
  724. };
  725. TreeContainer.prototype.getHeight = function() {
  726. if (this._ === 0) return 0;
  727. function traversal(e) {
  728. if (!e) return 0;
  729. return Math.max(traversal(e.t), traversal(e.i)) + 1;
  730. }
  731. return traversal(this.N);
  732. };
  733. return TreeContainer;
  734. }(Container);
  735. var TreeIterator = function(e) {
  736. __extends(TreeIterator, e);
  737. function TreeIterator(r, t, i) {
  738. var n = e.call(this, i) || this;
  739. n.C = r;
  740. n.A = t;
  741. if (n.iteratorType === 0) {
  742. n.pre = function() {
  743. if (this.C === this.A.t) {
  744. throwIteratorAccessError();
  745. }
  746. this.C = this.C.v();
  747. return this;
  748. };
  749. n.next = function() {
  750. if (this.C === this.A) {
  751. throwIteratorAccessError();
  752. }
  753. this.C = this.C.p();
  754. return this;
  755. };
  756. } else {
  757. n.pre = function() {
  758. if (this.C === this.A.i) {
  759. throwIteratorAccessError();
  760. }
  761. this.C = this.C.p();
  762. return this;
  763. };
  764. n.next = function() {
  765. if (this.C === this.A) {
  766. throwIteratorAccessError();
  767. }
  768. this.C = this.C.v();
  769. return this;
  770. };
  771. }
  772. return n;
  773. }
  774. Object.defineProperty(TreeIterator.prototype, "index", {
  775. get: function() {
  776. var e = this.C;
  777. var r = this.A.h;
  778. if (e === this.A) {
  779. if (r) {
  780. return r.O - 1;
  781. }
  782. return 0;
  783. }
  784. var t = 0;
  785. if (e.t) {
  786. t += e.t.O;
  787. }
  788. while (e !== r) {
  789. var i = e.h;
  790. if (e === i.i) {
  791. t += 1;
  792. if (i.t) {
  793. t += i.t.O;
  794. }
  795. }
  796. e = i;
  797. }
  798. return t;
  799. },
  800. enumerable: false,
  801. configurable: true
  802. });
  803. TreeIterator.prototype.isAccessible = function() {
  804. return this.C !== this.A;
  805. };
  806. return TreeIterator;
  807. }(ContainerIterator);
  808. var OrderedMapIterator = function(e) {
  809. __extends(OrderedMapIterator, e);
  810. function OrderedMapIterator(r, t, i, n) {
  811. var s = e.call(this, r, t, n) || this;
  812. s.container = i;
  813. return s;
  814. }
  815. Object.defineProperty(OrderedMapIterator.prototype, "pointer", {
  816. get: function() {
  817. if (this.C === this.A) {
  818. throwIteratorAccessError();
  819. }
  820. var e = this;
  821. return new Proxy([], {
  822. get: function(r, t) {
  823. if (t === "0") return e.C.u; else if (t === "1") return e.C.o;
  824. r[0] = e.C.u;
  825. r[1] = e.C.o;
  826. return r[t];
  827. },
  828. set: function(r, t, i) {
  829. if (t !== "1") {
  830. throw new TypeError("prop must be 1");
  831. }
  832. e.C.o = i;
  833. return true;
  834. }
  835. });
  836. },
  837. enumerable: false,
  838. configurable: true
  839. });
  840. OrderedMapIterator.prototype.copy = function() {
  841. return new OrderedMapIterator(this.C, this.A, this.container, this.iteratorType);
  842. };
  843. return OrderedMapIterator;
  844. }(TreeIterator);
  845. var OrderedMap = function(e) {
  846. __extends(OrderedMap, e);
  847. function OrderedMap(r, t, i) {
  848. if (r === void 0) {
  849. r = [];
  850. }
  851. var n = e.call(this, t, i) || this;
  852. var s = n;
  853. r.forEach((function(e) {
  854. s.setElement(e[0], e[1]);
  855. }));
  856. return n;
  857. }
  858. OrderedMap.prototype.begin = function() {
  859. return new OrderedMapIterator(this.A.t || this.A, this.A, this);
  860. };
  861. OrderedMap.prototype.end = function() {
  862. return new OrderedMapIterator(this.A, this.A, this);
  863. };
  864. OrderedMap.prototype.rBegin = function() {
  865. return new OrderedMapIterator(this.A.i || this.A, this.A, this, 1);
  866. };
  867. OrderedMap.prototype.rEnd = function() {
  868. return new OrderedMapIterator(this.A, this.A, this, 1);
  869. };
  870. OrderedMap.prototype.front = function() {
  871. if (this._ === 0) return;
  872. var e = this.A.t;
  873. return [ e.u, e.o ];
  874. };
  875. OrderedMap.prototype.back = function() {
  876. if (this._ === 0) return;
  877. var e = this.A.i;
  878. return [ e.u, e.o ];
  879. };
  880. OrderedMap.prototype.lowerBound = function(e) {
  881. var r = this.m(this.N, e);
  882. return new OrderedMapIterator(r, this.A, this);
  883. };
  884. OrderedMap.prototype.upperBound = function(e) {
  885. var r = this.B(this.N, e);
  886. return new OrderedMapIterator(r, this.A, this);
  887. };
  888. OrderedMap.prototype.reverseLowerBound = function(e) {
  889. var r = this.j(this.N, e);
  890. return new OrderedMapIterator(r, this.A, this);
  891. };
  892. OrderedMap.prototype.reverseUpperBound = function(e) {
  893. var r = this.k(this.N, e);
  894. return new OrderedMapIterator(r, this.A, this);
  895. };
  896. OrderedMap.prototype.forEach = function(e) {
  897. this.P((function(r, t, i) {
  898. e([ r.u, r.o ], t, i);
  899. }));
  900. };
  901. OrderedMap.prototype.setElement = function(e, r, t) {
  902. return this.D(e, r, t);
  903. };
  904. OrderedMap.prototype.getElementByPos = function(e) {
  905. if (e < 0 || e > this._ - 1) {
  906. throw new RangeError;
  907. }
  908. var r = this.P(e);
  909. return [ r.u, r.o ];
  910. };
  911. OrderedMap.prototype.find = function(e) {
  912. var r = this.F(this.N, e);
  913. return new OrderedMapIterator(r, this.A, this);
  914. };
  915. OrderedMap.prototype.getElementByKey = function(e) {
  916. var r = this.F(this.N, e);
  917. return r.o;
  918. };
  919. OrderedMap.prototype.union = function(e) {
  920. var r = this;
  921. e.forEach((function(e) {
  922. r.setElement(e[0], e[1]);
  923. }));
  924. return this._;
  925. };
  926. OrderedMap.prototype[Symbol.iterator] = function() {
  927. var e, r, t, i;
  928. return __generator(this, (function(n) {
  929. switch (n.label) {
  930. case 0:
  931. e = this._;
  932. r = this.P();
  933. t = 0;
  934. n.label = 1;
  935. case 1:
  936. if (!(t < e)) return [ 3, 4 ];
  937. i = r[t];
  938. return [ 4, [ i.u, i.o ] ];
  939. case 2:
  940. n.sent();
  941. n.label = 3;
  942. case 3:
  943. ++t;
  944. return [ 3, 1 ];
  945. case 4:
  946. return [ 2 ];
  947. }
  948. }));
  949. };
  950. return OrderedMap;
  951. }(TreeContainer);
  952. export { OrderedMap };
  953. //# sourceMappingURL=index.js.map