Socket
Socket
Sign inDemoInstall

js-sdsl

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-sdsl - npm Package Compare versions

Comparing version 4.1.5-beta.0 to 4.1.5-beta.1

6

CHANGELOG.md

@@ -7,2 +7,8 @@ # Change Log

## [4.1.5-beta.1] - 2022.09.23
### Fixed
- Get wrong tree index when size is 0.
## [4.1.5-beta.0] - 2022.09.23

@@ -9,0 +15,0 @@

25

dist/cjs/container/TreeContainer/Base/TreeIterator.js

@@ -50,23 +50,24 @@ "use strict";

let t = this.I;
const e = this.L.parent;
if (t === this.L) {
if (this.L.parent) {
return this.L.parent.subTreeSize - 1;
if (e) {
return e.subTreeSize - 1;
}
return 0;
}
let e = 0;
let r = 0;
if (t.left) {
e += t.left.subTreeSize;
r += t.left.subTreeSize;
}
while (t !== this.L) {
const r = t.parent;
if (t === r.right) {
e += 1;
if (r.left) {
e += r.left.subTreeSize;
while (t !== e) {
const e = t.parent;
if (t === e.right) {
r += 1;
if (e.left) {
r += e.left.subTreeSize;
}
}
t = r;
t = e;
}
return e;
return r;
}

@@ -73,0 +74,0 @@ equals(t) {

@@ -26,8 +26,8 @@ var __extends = this && this.t || function() {

__extends(TreeIterator, t);
function TreeIterator(r, e, i) {
var n = t.call(this, i) || this;
n.D = r;
n.L = e;
if (n.iteratorType === 0) {
n.pre = function() {
function TreeIterator(r, e, n) {
var i = t.call(this, n) || this;
i.D = r;
i.L = e;
if (i.iteratorType === 0) {
i.pre = function() {
if (this.D === this.L.left) {

@@ -39,3 +39,3 @@ throw new RangeError("Tree iterator access denied!");

};
n.next = function() {
i.next = function() {
if (this.D === this.L) {

@@ -48,3 +48,3 @@ throw new RangeError("Tree iterator access denied!");

} else {
n.pre = function() {
i.pre = function() {
if (this.D === this.L.right) {

@@ -56,3 +56,3 @@ throw new RangeError("Tree iterator access denied!");

};
n.next = function() {
i.next = function() {
if (this.D === this.L) {

@@ -65,3 +65,3 @@ throw new RangeError("Tree iterator access denied!");

}
return n;
return i;
}

@@ -71,23 +71,24 @@ Object.defineProperty(TreeIterator.prototype, "index", {

var t = this.D;
var r = this.L.parent;
if (t === this.L) {
if (this.L.parent) {
return this.L.parent.subTreeSize - 1;
if (r) {
return r.subTreeSize - 1;
}
return 0;
}
var r = 0;
var e = 0;
if (t.left) {
r += t.left.subTreeSize;
e += t.left.subTreeSize;
}
while (t !== this.L) {
var e = t.parent;
if (t === e.right) {
r += 1;
if (e.left) {
r += e.left.subTreeSize;
while (t !== r) {
var n = t.parent;
if (t === n.right) {
e += 1;
if (n.left) {
e += n.left.subTreeSize;
}
}
t = e;
t = n;
}
return r;
return e;
},

@@ -94,0 +95,0 @@ enumerable: false,

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("sdsl",["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var I=function(t,e){return(I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}I(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function f(i,n){var o,s,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(r){return function(t){var e=[r,t];if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,s&&(h=2&e[0]?s.return:e[0]?s.throw||((h=s.return)&&h.call(s),0):s.next)&&!(h=h.call(s,e[1])).done)return h;switch(s=0,(e=h?[2&e[0],h.value]:e)[0]){case 0:case 1:h=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,s=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!h||e[1]>h[0]&&e[1]<h[3]))u.label=e[1];else if(6===e[0]&&u.label<h[1])u.label=h[1],h=e;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(e)}}e=n.call(i,u)}catch(t){e=[6,t],s=0}finally{o=h=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function p(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&i>=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function l(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||((i=i||Array.prototype.slice.call(e,0,n))[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function D(t){this.iteratorType=t=void 0===t?0:t}N.prototype.size=function(){return this.t},N.prototype.empty=function(){return 0===this.t};var r=N;function N(){this.t=0}e(j,_=r);var _,i=j;function j(){return null!==_&&_.apply(this,arguments)||this}e(n,A=r),n.prototype.clear=function(){this.t=0,this.i.length=0},n.prototype.push=function(t){this.i.push(t),this.t+=1},n.prototype.pop=function(){this.i.pop(),0<this.t&&--this.t},n.prototype.top=function(){return this.i[this.t-1]};var A,F=n;function n(t){void 0===t&&(t=[]);var e=A.call(this)||this;return e.i=[],t.forEach(function(t){return e.push(t)}),e}e($,K=i);var K,o=$;function $(){return null!==K&&K.apply(this,arguments)||this}e(s,Y=D),Object.defineProperty(s.prototype,"pointer",{get:function(){return this.o(this.h)},set:function(t){this.v(this.h,t)},enumerable:!1,configurable:!0}),s.prototype.equals=function(t){return this.h===t.h};var Y,H=s;function s(t,e,r,i,n){n=Y.call(this,n)||this;return n.h=t,n.u=e,n.o=r,n.v=i,0===n.iteratorType?(n.pre=function(){if(0===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this},n.next=function(){if(this.h===this.u())throw new RangeError("Random Iterator access denied!");return this.h+=1,this}):(n.pre=function(){if(this.h===this.u()-1)throw new RangeError("Random iterator access denied!");return this.h+=1,this},n.next=function(){if(-1===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this}),n}e(X,U=H),X.prototype.copy=function(){return new X(this.h,this.u,this.o,this.v,this.iteratorType)};var U,h=X;function X(){return null!==U&&U.apply(this,arguments)||this}e(u,G=o),u.prototype.I=function(){for(var t=[],e=Math.max(this.O>>1,1),r=0;r<e;++r)t[r]=new Array(this.S);for(r=this.l;r<this.O;++r)t[t.length]=this.k[r];for(r=0;r<this.L;++r)t[t.length]=this.k[r];t[t.length]=l([],c(this.k[this.L]),!1),this.l=e,this.L=t.length-1;for(r=0;r<e;++r)t[t.length]=new Array(this.S);this.k=t,this.O=t.length},u.prototype.g=function(t){var t=this._+t+1,e=t%this.S,r=e-1,t=this.l+(t-e)/this.S;return 0==e&&--t,t%=this.O,r<0&&(r+=this.S),{curNodeBucketIndex:t,curNodePointerIndex:r}},u.prototype.clear=function(){this.k=[[]],this.O=1,this.l=this.L=this.t=0,this._=this.p=this.S>>1},u.prototype.front=function(){return this.k[this.l][this._]},u.prototype.back=function(){return this.k[this.L][this.p]},u.prototype.begin=function(){return new h(0,this.size,this.getElementByPos,this.setElementByPos)},u.prototype.end=function(){return new h(this.t,this.size,this.getElementByPos,this.setElementByPos)},u.prototype.rBegin=function(){return new h(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},u.prototype.rEnd=function(){return new h(-1,this.size,this.getElementByPos,this.setElementByPos,1)},u.prototype.pushBack=function(t){this.t&&(this.p<this.S-1?this.p+=1:(this.L<this.O-1?this.L+=1:this.L=0,this.p=0),this.L===this.l&&this.p===this._&&this.I()),this.t+=1,this.k[this.L][this.p]=t},u.prototype.popBack=function(){this.t&&(this.k[this.L][this.p]=void 0,1!==this.t&&(0<this.p?--this.p:(0<this.L?--this.L:this.L=this.O-1,this.p=this.S-1)),--this.t)},u.prototype.pushFront=function(t){this.t&&(0<this._?--this._:(0<this.l?--this.l:this.l=this.O-1,this._=this.S-1),this.l===this.L&&this._===this.p&&this.I()),this.t+=1,this.k[this.l][this._]=t},u.prototype.popFront=function(){this.t&&(this.k[this.l][this._]=void 0,1!==this.t&&(this._<this.S-1?this._+=1:(this.l<this.O-1?this.l+=1:this.l=0,this._=0)),--this.t)},u.prototype.forEach=function(t){for(var e=0;e<this.t;++e)t(this.getElementByPos(e),e)},u.prototype.getElementByPos=function(t){var t=this.g(t),e=t.curNodeBucketIndex,t=t.curNodePointerIndex;return this.k[e][t]},u.prototype.setElementByPos=function(t,e){var t=this.g(t),r=t.curNodeBucketIndex,t=t.curNodePointerIndex;this.k[r][t]=e},u.prototype.insert=function(t,e,r){if(void 0===r&&(r=1),0===t)for(;r--;)this.pushFront(e);else if(t===this.t)for(;r--;)this.pushBack(e);else{for(var i=[],n=t;n<this.t;++n)i.push(this.getElementByPos(n));this.cut(t-1);for(n=0;n<r;++n)this.pushBack(e);for(n=0;n<i.length;++n)this.pushBack(i[n])}},u.prototype.cut=function(t){var e,r;t<0?this.clear():(e=(r=this.g(t)).curNodeBucketIndex,r=r.curNodePointerIndex,this.L=e,this.p=r,this.t=t+1)},u.prototype.eraseElementByPos=function(t){var e=this;if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var r=[],i=t+1;i<this.t;++i)r.push(this.getElementByPos(i));this.cut(t),this.popBack(),r.forEach(function(t){return e.pushBack(t)})}},u.prototype.eraseElementByValue=function(t){if(this.t){for(var e=[],r=0;r<this.t;++r){var i=this.getElementByPos(r);i!==t&&e.push(i)}for(var n=e.length,r=0;r<n;++r)this.setElementByPos(r,e[r]);this.cut(n-1)}},u.prototype.eraseElementByIterator=function(t){var e=t.h;return this.eraseElementByPos(e),t=t.next()},u.prototype.find=function(t){for(var e=0;e<this.t;++e)if(this.getElementByPos(e)===t)return new h(e,this.size,this.getElementByPos,this.setElementByPos);return this.end()},u.prototype.reverse=function(){for(var t=0,e=this.t-1;t<e;){var r=this.getElementByPos(t);this.setElementByPos(t,this.getElementByPos(e)),this.setElementByPos(e,r),t+=1,--e}},u.prototype.unique=function(){if(!(this.t<=1)){for(var t=1,e=this.getElementByPos(0),r=1;r<this.t;++r){var i=this.getElementByPos(r);i!==e&&this.setElementByPos(t++,e=i)}for(;this.t>t;)this.popBack()}},u.prototype.sort=function(t){for(var e=[],r=0;r<this.t;++r)e.push(this.getElementByPos(r));e.sort(t);for(r=0;r<this.t;++r)this.setElementByPos(r,e[r])},u.prototype.shrinkToFit=function(){if(this.t){var e=[];this.forEach(function(t){return e.push(t)}),this.O=Math.max(Math.ceil(this.t/this.S),1),this.t=this.l=this.L=this._=this.p=0,this.k=[];for(var t=0;t<this.O;++t)this.k.push(new Array(this.S));for(t=0;t<e.length;++t)this.pushBack(e[t])}},u.prototype[Symbol.iterator]=function(){return function(){var e;return f(this,function(t){switch(t.label){case 0:e=0,t.label=1;case 1:return e<this.t?[4,this.getElementByPos(e)]:[3,4];case 2:t.sent(),t.label=3;case 3:return++e,[3,1];case 4:return[2]}})}.bind(this)()};var G,J=u;function u(t,e){void 0===t&&(t=[]),void 0===e&&(e=4096);var r,i=G.call(this)||this;if(i.l=0,i._=0,i.L=0,i.p=0,i.O=0,i.k=[],"size"in t)r="number"==typeof t.size?t.size:t.size();else{if(!("length"in t))throw new RangeError("Can't get container's size!");r=t.length}i.S=e,i.O=Math.max(Math.ceil(r/i.S),1);for(var n=0;n<i.O;++n)i.k.push(new Array(i.S));e=Math.ceil(r/i.S);return i.l=i.L=(i.O>>1)-(e>>1),i._=i.p=i.S-r%i.S>>1,t.forEach(function(t){return i.pushBack(t)}),i.size=i.size.bind(i),i.getElementByPos=i.getElementByPos.bind(i),i.setElementByPos=i.setElementByPos.bind(i),i}e(a,Q=r),a.prototype.clear=function(){this.T.clear(),this.t=0},a.prototype.push=function(t){this.T.pushBack(t),this.t+=1},a.prototype.pop=function(){this.T.popFront(),this.t&&--this.t},a.prototype.front=function(){return this.T.front()};var Q,W=a;function a(t){void 0===t&&(t=[]);var e=Q.call(this)||this;return e.T=new J(t),e.t=e.T.size(),e}e(y,Z=r),y.prototype.clear=function(){this.t=0,this.q.length=0},y.prototype.push=function(t){var e=this.t;for(this.t+=1,this.q.push(t);0<e;){var r=e-1>>1,i=this.q[r];if(this.M(i,t)<=0)break;this.q[e]=i,e=r}this.q[e]=t},y.prototype.pop=function(){if(this.t){var t=this.q.pop();if(--this.t,this.t){for(var e=0,r=this.t>>1;e<r;){var i=e<<1|1,n=i+1,o=this.q[i],s=this.q[n];if(n<this.t&&0<this.M(o,s)&&(i=n,o=s),0<=this.M(o,t))break;this.q[e]=o,e=i}this.q[e]=t}}},y.prototype.top=function(){return this.q[0]};var Z,tt=y;function y(t,e,r){void 0===t&&(t=[]),void 0===e&&(e=function(t,e){return e<t?-1:t<e?1:0}),void 0===r&&(r=!0);for(var i=Z.call(this)||this,n=(i.M=e,Array.isArray(t)?i.q=r?l([],c(t),!1):t:(i.q=[],t.forEach(function(t){return i.q.push(t)})),i.t=i.q.length,i.t>>1),o=i.t-1>>1;0<=o;--o){for(var s=o,h=i.q[s];s<n;){var u=s<<1|1,a=u+1,f=i.q[u];if(a<i.t&&0<i.M(f,i.q[a])&&(f=i.q[u=a]),0<=i.M(f,h))break;i.q[s]=f,s=u}i.q[s]=h}return i}e(rt,et=H),rt.prototype.copy=function(){return new rt(this.h,this.u,this.o,this.v,this.iteratorType)};var et,v=rt;function rt(){return null!==et&&et.apply(this,arguments)||this}e(m,it=o),m.prototype.clear=function(){this.t=0,this.D.length=0},m.prototype.begin=function(){return new v(0,this.size,this.getElementByPos,this.setElementByPos)},m.prototype.end=function(){return new v(this.t,this.size,this.getElementByPos,this.setElementByPos)},m.prototype.rBegin=function(){return new v(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},m.prototype.rEnd=function(){return new v(-1,this.size,this.getElementByPos,this.setElementByPos,1)},m.prototype.front=function(){return this.D[0]},m.prototype.back=function(){return this.D[this.t-1]},m.prototype.forEach=function(t){for(var e=0;e<this.t;++e)t(this.D[e],e)},m.prototype.getElementByPos=function(t){return this.D[t]},m.prototype.eraseElementByPos=function(t){this.D.splice(t,1),--this.t},m.prototype.eraseElementByValue=function(t){for(var e=0,r=0;r<this.t;++r)this.D[r]!==t&&(this.D[e++]=this.D[r]);this.t=this.D.length=e},m.prototype.eraseElementByIterator=function(t){var e=t.h;return t=t.next(),this.eraseElementByPos(e),t},m.prototype.pushBack=function(t){this.D.push(t),this.t+=1},m.prototype.popBack=function(){this.t&&(this.D.pop(),--this.t)},m.prototype.setElementByPos=function(t,e){this.D[t]=e},m.prototype.insert=function(t,e,r){var i;void 0===r&&(r=1),(i=this.D).splice.apply(i,l([t,0],c(new Array(r).fill(e)),!1)),this.t+=r},m.prototype.find=function(t){for(var e=0;e<this.t;++e)if(this.D[e]===t)return new v(e,this.size,this.getElementByPos,this.getElementByPos);return this.end()},m.prototype.reverse=function(){this.D.reverse()},m.prototype.unique=function(){for(var t=1,e=1;e<this.t;++e)this.D[e]!==this.D[e-1]&&(this.D[t++]=this.D[e]);this.t=this.D.length=t},m.prototype.sort=function(t){this.D.sort(t)},m.prototype[Symbol.iterator]=function(){return function(){return f(this,function(t){switch(t.label){case 0:return[5,p(this.D)];case 1:return[2,t.sent()]}})}.bind(this)()};var it,d=m;function m(t,e){void 0===t&&(t=[]),void 0===e&&(e=!0);var r=it.call(this)||this;return Array.isArray(t)?(r.D=e?l([],c(t),!1):t,r.t=t.length):(r.D=[],t.forEach(function(t){return r.pushBack(t)})),r.size=r.size.bind(r),r.getElementByPos=r.getElementByPos.bind(r),r.setElementByPos=r.setElementByPos.bind(r),r}var nt,g=function(t){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=t},w=(e(E,nt=D),Object.defineProperty(E.prototype,"pointer",{get:function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h.value},set:function(t){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");this.h.value=t},enumerable:!1,configurable:!0}),E.prototype.equals=function(t){return this.h===t.h},E.prototype.copy=function(){return new E(this.h,this.m,this.iteratorType)},E);function E(t,e,r){r=nt.call(this,r)||this;return r.h=t,r.m=e,0===r.iteratorType?(r.pre=function(){if(this.h.pre===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.pre,this},r.next=function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.next,this}):(r.pre=function(){if(this.h.next===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.next,this},r.next=function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.pre,this}),r}e(B,ot=o),B.prototype.clear=function(){this.t=0,this.C=this.R=void 0,this.m.pre=this.m.next=void 0},B.prototype.begin=function(){return new w(this.C||this.m,this.m)},B.prototype.end=function(){return new w(this.m,this.m)},B.prototype.rBegin=function(){return new w(this.R||this.m,this.m,1)},B.prototype.rEnd=function(){return new w(this.m,this.m,1)},B.prototype.front=function(){return this.C?this.C.value:void 0},B.prototype.back=function(){return this.R?this.R.value:void 0},B.prototype.forEach=function(t){if(this.t)for(var e=this.C,r=0;e!==this.m;)t(e.value,r++),e=e.next},B.prototype.getElementByPos=function(t){for(var e=this.C;t--;)e=e.next;return e.value},B.prototype.eraseElementByPos=function(t){if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var e=this.C;t--;)e=e.next;var r=e.pre,i=e.next;(i.pre=r).next=i,--this.t}},B.prototype.eraseElementByValue=function(t){for(;this.C&&this.C.value===t;)this.popFront();for(;this.R&&this.R.value===t;)this.popBack();if(this.C)for(var e,r,i=this.C;i!==this.m;)i.value===t&&(e=i.pre,(r=i.next)&&(r.pre=e),e&&(e.next=r),--this.t),i=i.next},B.prototype.eraseElementByIterator=function(t){var e,r=t.h;if(r===this.m)throw new RangeError("Invalid iterator");return t=t.next(),this.C===r?this.popFront():this.R===r?this.popBack():(e=r.pre,(r=r.next)&&(r.pre=e),e&&(e.next=r),--this.t),t},B.prototype.pushBack=function(t){this.t+=1;t=new g(t);this.R?((this.R.next=t).pre=this.R,this.R=t):(this.C=this.R=t,this.m.next=this.C,this.C.pre=this.m),this.R.next=this.m,this.m.pre=this.R},B.prototype.popBack=function(){this.R&&(--this.t,this.C===this.R?(this.C=this.R=void 0,this.m.next=void 0):(this.R=this.R.pre,this.R&&(this.R.next=void 0)),this.m.pre=this.R,this.R&&(this.R.next=this.m))},B.prototype.setElementByPos=function(t,e){for(var r=this.C;t--;)r=r.next;r.value=e},B.prototype.insert=function(t,e,r){if(!((r=void 0===r?1:r)<=0))if(0===t)for(;r--;)this.pushFront(e);else if(t===this.t)for(;r--;)this.pushBack(e);else{for(var i=this.C,n=1;n<t;++n)i=i.next;var o=i.next;for(this.t+=r;r--;)i.next=new g(e),i=(i.next.pre=i).next;(i.next=o)&&(o.pre=i)}},B.prototype.find=function(t){if(this.C)for(var e=this.C;e!==this.m;){if(e.value===t)return new w(e,this.m);e=e.next}return this.end()},B.prototype.reverse=function(){if(!(this.t<=1))for(var t=this.C,e=this.R,r=0;r<<1<this.t;){var i=t.value;t.value=e.value,e.value=i,t=t.next,e=e.pre,r+=1}},B.prototype.unique=function(){if(!(this.t<=1))for(var t=this.C;t!==this.m;){for(var e=t;e.next&&e.value===e.next.value;)e=e.next,--this.t;t.next=e.next,t.next&&(t.next.pre=t),t=t.next}},B.prototype.sort=function(t){var e,r;this.t<=1||(e=[],this.forEach(function(t){return e.push(t)}),e.sort(t),r=this.C,e.forEach(function(t){r.value=t,r=r.next}))},B.prototype.pushFront=function(t){this.t+=1;t=new g(t);this.C?(t.next=this.C,this.C.pre=t,this.C=t):(this.C=this.R=t,this.R.next=this.m,this.m.pre=this.R),this.m.next=this.C,this.C.pre=this.m},B.prototype.popFront=function(){this.C&&(--this.t,this.C===this.R?(this.C=this.R=void 0,this.m.pre=this.R):(this.C=this.C.next,this.C&&(this.C.pre=this.m)),this.m.next=this.C)},B.prototype.merge=function(t){var r,i=this;this.C?(r=this.C,t.forEach(function(t){for(;r&&r!==i.m&&r.value<=t;)r=r.next;var e;r===i.m?(i.pushBack(t),r=i.R):r===i.C?(i.pushFront(t),r=i.C):(i.t+=1,(e=r.pre).next=new g(t),((e.next.pre=e).next.next=r).pre=e.next)})):t.forEach(function(t){return i.pushBack(t)})},B.prototype[Symbol.iterator]=function(){return function(){var e;return f(this,function(t){switch(t.label){case 0:if(!this.C)return[2];e=this.C,t.label=1;case 1:return e===this.m?[3,3]:[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})}.bind(this)()};var ot,H=B;function B(t){void 0===t&&(t=[]);var e=ot.call(this)||this;return e.m=new g,e.C=void 0,e.R=void 0,t.forEach(function(t){return e.pushBack(t)}),e}b.prototype.pre=function(){var t=this;if(1===t.color&&t.parent.parent===t)t=t.right;else if(t.left)for(t=t.left;t.right;)t=t.right;else{for(var e=t.parent;e.left===t;)e=(t=e).parent;t=e}return t},b.prototype.next=function(){var t=this;if(t.right)for(t=t.right;t.left;)t=t.left;else{for(var e=t.parent;e.right===t;)e=(t=e).parent;t.right!==e&&(t=e)}return t},b.prototype.rotateLeft=function(){var t=this.parent,e=this.right,r=e.left;return t.parent===this?t.parent=e:t.left===this?t.left=e:t.right=e,e.parent=t,(e.left=this).parent=e,(this.right=r)&&(r.parent=this),e},b.prototype.rotateRight=function(){var t=this.parent,e=this.left,r=e.right;return t.parent===this?t.parent=e:t.left===this?t.left=e:t.right=e,e.parent=t,(e.right=this).parent=e,(this.left=r)&&(r.parent=this),e};var st=b;function b(t,e){this.color=1,this.key=void 0,this.value=void 0,this.left=void 0,this.right=void 0,this.parent=void 0,this.key=t,this.value=e}e(k,x=st),k.prototype.rotateLeft=function(){var t=x.prototype.rotateLeft.call(this);return this.recount(),t.recount(),t},k.prototype.rotateRight=function(){var t=x.prototype.rotateRight.call(this);return this.recount(),t.recount(),t},k.prototype.recount=function(){this.subTreeSize=1,this.left&&(this.subTreeSize+=this.left.subTreeSize),this.right&&(this.subTreeSize+=this.right.subTreeSize)};var x,ht=k;function k(){var t=null!==x&&x.apply(this,arguments)||this;return t.left=void 0,t.right=void 0,t.parent=void 0,t.subTreeSize=1,t}e(P,ut=i),P.prototype.J=function(t,e){for(var r;t;){var i=this.M(t.key,e);if(i<0)t=t.right;else{if(!(0<i))return t;t=(r=t).left}}return void 0===r?this.m:r},P.prototype.F=function(t,e){for(var r;t;){var i=this.M(t.key,e);i<=0?t=t.right:0<i&&(t=(r=t).left)}return void 0===r?this.m:r},P.prototype.K=function(t,e){for(var r;t;){var i=this.M(t.key,e);if(i<0)t=(r=t).right;else{if(!(0<i))return t;t=t.left}}return void 0===r?this.m:r},P.prototype.U=function(t,e){for(var r;t;){var i=this.M(t.key,e);i<0?t=(r=t).right:0<=i&&(t=t.left)}return void 0===r?this.m:r},P.prototype.W=function(t){for(;;){var e,r=t.parent;if(r===this.m)return;if(1===t.color)return void(t.color=0);if(t===r.left){if(1===(e=r.right).color)e.color=0,r.color=1,r===this.V?this.V=r.rotateLeft():r.rotateLeft();else if(0===e.color){if(e.right&&1===e.right.color)return e.color=r.color,r.color=0,e.right.color=0,void(r===this.V?this.V=r.rotateLeft():r.rotateLeft());e.left&&1===e.left.color?(e.color=1,e.left.color=0,e.rotateRight()):(e.color=1,t=r)}}else if(1===(e=r.left).color)e.color=0,r.color=1,r===this.V?this.V=r.rotateRight():r.rotateRight();else{if(e.left&&1===e.left.color)return e.color=r.color,r.color=0,e.left.color=0,void(r===this.V?this.V=r.rotateRight():r.rotateRight());e.right&&1===e.right.color?(e.color=1,e.right.color=0,e.rotateLeft()):(e.color=1,t=r)}}},P.prototype.G=function(t){var e;if(1===this.t)return this.clear(),this.m;for(var r=t;r.left||r.right;){if(r.right)for(r=r.right;r.left;)r=r.left;else r.left&&(r=r.left);e=c([r.key,t.key],2),t.key=e[0],r.key=e[1],e=c([r.value,t.value],2),t.value=e[0],r.value=e[1],t=r}this.m.left===r?this.m.left=r.parent:this.m.right===r&&(this.m.right=r.parent),this.W(r);var i=r.parent;return r===i.left?i.left=void 0:i.right=void 0,--this.t,this.V.color=0,i},P.prototype.P=function(t){for(;;){var e=t.parent;if(0===e.color)return;var r,i,n=e.parent;if(e===n.left){if((r=n.right)&&1===r.color){if(r.color=e.color=0,n===this.V)return;n.color=1,t=n;continue}if(t===e.right)return t.color=0,t.left&&(t.left.parent=e),t.right&&(t.right.parent=n),e.right=t.left,n.left=t.right,t.left=e,(t.right=n)===this.V?(this.V=t,this.m.parent=t):(i=n.parent).left===n?i.left=t:i.right=t,t.parent=n.parent,e.parent=t,n.parent=t,n.color=1,{parentNode:e,grandParent:n,curNode:t};e.color=0,n===this.V?this.V=n.rotateRight():n.rotateRight()}else{if((r=n.left)&&1===r.color){if(r.color=e.color=0,n===this.V)return;n.color=1,t=n;continue}if(t===e.left)return t.color=0,t.left&&(t.left.parent=n),t.right&&(t.right.parent=e),n.right=t.left,e.left=t.right,t.left=n,t.right=e,n===this.V?(this.V=t,this.m.parent=t):(i=n.parent).left===n?i.left=t:i.right=t,t.parent=n.parent,e.parent=t,n.parent=t,n.color=1,{parentNode:e,grandParent:n,curNode:t};e.color=0,n===this.V?this.V=n.rotateLeft():n.rotateLeft()}return void(n.color=1)}},P.prototype.A=function(t,e,r){if(void 0===this.V)this.t+=1,this.V=new this.N(t,e),this.V.color=0,this.V.parent=this.m,this.m.parent=this.V,this.m.left=this.V,this.m.right=this.V;else{var i,n=this.m.left,o=this.M(n.key,t);if(0!==o){if(0<o)n.left=new this.N(t,e),i=(n.left.parent=n).left,this.m.left=i;else{var o=this.m.right,s=this.M(o.key,t);if(0===s)return void(o.value=e);if(s<0)o.right=new this.N(t,e),i=(o.right.parent=o).right,this.m.right=i;else{if(void 0!==r){s=r.h;if(s!==this.m){o=this.M(s.key,t);if(0===o)return void(s.value=e);if(0<o){r=s.pre(),o=this.M(r.key,t);if(0===o)return void(r.value=e);o<0&&(i=new this.N(t,e),void 0===r.right?(r.right=i).parent=r:(s.left=i).parent=s)}}}if(void 0===i)for(i=this.V;;){var h=this.M(i.key,t);if(0<h){if(void 0===i.left){i.left=new this.N(t,e),i=(i.left.parent=i).left;break}i=i.left}else{if(!(h<0))return void(i.value=e);if(void 0===i.right){i.right=new this.N(t,e),i=(i.right.parent=i).right;break}i=i.right}}}}return this.t+=1,i}n.value=e}},P.prototype.clear=function(){this.t=0,this.V=void 0,this.m.parent=void 0,this.m.left=this.m.right=void 0},P.prototype.updateKeyByIterator=function(t,e){t=t.h;if(t===this.m)throw new TypeError("Invalid iterator!");if(1!==this.t){if(t===this.m.left)return 0<this.M(t.next().key,e)&&(t.key=e,!0);if(t===this.m.right)return this.M(t.pre().key,e)<0&&(t.key=e,!0);var r=t.pre().key;if(0<=this.M(r,e))return!1;if(r=t.next().key,this.M(r,e)<=0)return!1}return t.key=e,!0},P.prototype.eraseElementByPos=function(e){var r=this,i=0;this.H(this.V,function(t){return e===i?(r.B(t),!0):(i+=1,!1)})},P.prototype.X=function(t,e){for(;t;){var r=this.M(t.key,e);if(r<0)t=t.right;else{if(!(0<r))return t;t=t.left}}return t},P.prototype.eraseElementByKey=function(t){!this.t||void 0!==(t=this.X(this.V,t))&&this.B(t)},P.prototype.eraseElementByIterator=function(t){var e=t.h;if(e===this.m)throw new RangeError("Invalid iterator");return void 0===e.right&&(t=t.next()),this.B(e),t},P.prototype.getHeight=function(){var e;return this.t?(e=function(t){return t?Math.max(e(t.left),e(t.right))+1:0})(this.V):0};var ut,o=P;function P(t,e){void 0===t&&(t=function(t,e){return t<e?-1:e<t?1:0}),void 0===e&&(e=!1);var r=ut.call(this)||this;return r.V=void 0,r.H=function(t,e){return void 0!==t&&(!!r.H(t.left,e)||(!!e(t)||r.H(t.right,e)))},r.M=t,e?(r.N=ht,r.j=function(t,e,r){t=this.A(t,e,r);if(t){for(var i=t.parent;i!==this.m;)i.subTreeSize+=1,i=i.parent;var e=this.P(t);e&&(r=e.parentNode,t=e.grandParent,e=e.curNode,r.recount(),t.recount(),e.recount())}},r.B=function(t){for(var e=this.G(t);e!==this.m;)--e.subTreeSize,e=e.parent}):(r.N=st,r.j=function(t,e,r){t=this.A(t,e,r);t&&this.P(t)},r.B=r.G),r.m=new r.N,r}e(ft,at=D),Object.defineProperty(ft.prototype,"index",{get:function(){var t=this.h;if(t===this.m)return this.m.parent?this.m.parent.subTreeSize-1:0;var e=0;for(t.left&&(e+=t.left.subTreeSize);t!==this.m;){var r=t.parent;t===r.right&&(e+=1,r.left&&(e+=r.left.subTreeSize)),t=r}return e},enumerable:!1,configurable:!0}),ft.prototype.equals=function(t){return this.h===t.h};var at,i=ft;function ft(t,e,r){r=at.call(this,r)||this;return r.h=t,r.m=e,0===r.iteratorType?(r.pre=function(){if(this.h===this.m.left)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this},r.next=function(){if(this.h===this.m)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this}):(r.pre=function(){if(this.h===this.m.right)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this},r.next=function(){if(this.h===this.m)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this}),r}e(O,pt=i),Object.defineProperty(O.prototype,"pointer",{get:function(){if(this.h===this.m)throw new RangeError("OrderedSet iterator access denied!");return this.h.key},enumerable:!1,configurable:!0}),O.prototype.copy=function(){return new O(this.h,this.m,this.iteratorType)};var pt,R=O;function O(){return null!==pt&&pt.apply(this,arguments)||this}e(C,ct=o),C.prototype.begin=function(){return new R(this.m.left||this.m,this.m)},C.prototype.end=function(){return new R(this.m,this.m)},C.prototype.rBegin=function(){return new R(this.m.right||this.m,this.m,1)},C.prototype.rEnd=function(){return new R(this.m,this.m,1)},C.prototype.front=function(){return this.m.left?this.m.left.key:void 0},C.prototype.back=function(){return this.m.right?this.m.right.key:void 0},C.prototype.forEach=function(t){var e,r,i=0;try{for(var n=p(this),o=n.next();!o.done;o=n.next())t(o.value,i++)}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},C.prototype.getElementByPos=function(t){var e,r,i,n=0;try{for(var o=p(this),s=o.next();!s.done;s=o.next()){var h=s.value;if(n===t){i=h;break}n+=1}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},C.prototype.insert=function(t,e){this.j(t,void 0,e)},C.prototype.find=function(t){t=this.X(this.V,t);return void 0!==t?new R(t,this.m):this.end()},C.prototype.lowerBound=function(t){t=this.J(this.V,t);return new R(t,this.m)},C.prototype.upperBound=function(t){t=this.F(this.V,t);return new R(t,this.m)},C.prototype.reverseLowerBound=function(t){t=this.K(this.V,t);return new R(t,this.m)},C.prototype.reverseUpperBound=function(t){t=this.U(this.V,t);return new R(t,this.m)},C.prototype.union=function(t){var e=this;t.forEach(function(t){return e.insert(t)})},C.prototype[Symbol.iterator]=function(){return this.Y(this.V)};var ct,V=C;function C(t,e,r){void 0===t&&(t=[]);var i=ct.call(this,e,r)||this;return i.Y=function(e){return f(this,function(t){switch(t.label){case 0:return void 0===e?[2]:[5,p(this.Y(e.left))];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,p(this.Y(e.right))];case 3:return t.sent(),[2]}})},t.forEach(function(t){return i.insert(t)}),i}e(L,lt=i),Object.defineProperty(L.prototype,"pointer",{get:function(){var i=this;if(this.h===this.m)throw new RangeError("OrderedMap iterator access denied");return new Proxy([],{get:function(t,e){return"0"===e?i.h.key:"1"===e?i.h.value:void 0},set:function(t,e,r){if("1"!==e)throw new TypeError("props must be 1");return i.h.value=r,!0}})},enumerable:!1,configurable:!0}),L.prototype.copy=function(){return new L(this.h,this.m,this.iteratorType)};var lt,S=L;function L(){return null!==lt&&lt.apply(this,arguments)||this}e(T,yt=o),T.prototype.begin=function(){return new S(this.m.left||this.m,this.m)},T.prototype.end=function(){return new S(this.m,this.m)},T.prototype.rBegin=function(){return new S(this.m.right||this.m,this.m,1)},T.prototype.rEnd=function(){return new S(this.m,this.m,1)},T.prototype.front=function(){var t;if(this.t)return[(t=this.m.left).key,t.value]},T.prototype.back=function(){var t;if(this.t)return[(t=this.m.right).key,t.value]},T.prototype.forEach=function(t){var e,r,i=0;try{for(var n=p(this),o=n.next();!o.done;o=n.next())t(o.value,i++)}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},T.prototype.lowerBound=function(t){t=this.J(this.V,t);return new S(t,this.m)},T.prototype.upperBound=function(t){t=this.F(this.V,t);return new S(t,this.m)},T.prototype.reverseLowerBound=function(t){t=this.K(this.V,t);return new S(t,this.m)},T.prototype.reverseUpperBound=function(t){t=this.U(this.V,t);return new S(t,this.m)},T.prototype.setElement=function(t,e,r){this.j(t,e,r)},T.prototype.find=function(t){t=this.X(this.V,t);return void 0!==t?new S(t,this.m):this.end()},T.prototype.getElementByKey=function(t){t=this.X(this.V,t);return t?t.value:void 0},T.prototype.getElementByPos=function(t){var e,r,i,n=0;try{for(var o=p(this),s=o.next();!s.done;s=o.next()){var h=s.value;if(n===t){i=h;break}n+=1}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},T.prototype.union=function(t){var r=this;t.forEach(function(t){var t=c(t,2),e=t[0],t=t[1];return r.setElement(e,t)})},T.prototype[Symbol.iterator]=function(){return this.Y(this.V)};var yt,z=T;function T(t,e,r){void 0===t&&(t=[]);var i=yt.call(this,e,r)||this;return i.Y=function(e){return f(this,function(t){switch(t.label){case 0:return void 0===e?[2]:[5,p(this.Y(e.left))];case 1:return t.sent(),[4,[e.key,e.value]];case 2:return t.sent(),[5,p(this.Y(e.right))];case 3:return t.sent(),[2]}})},t.forEach(function(t){var t=c(t,2),e=t[0],t=t[1];return i.setElement(e,t)}),i}e(dt,vt=r),dt.prototype.clear=function(){this.t=0,this.O=this.Z,this.tt=[]};var vt,i=dt;function dt(t,e){void 0===t&&(t=16),void 0===e&&(e=function(t){for(var e="string"!=typeof t?JSON.stringify(t):t,r=0,i=e.length,n=0;n<i;n++){r=(r<<5)-r+e.charCodeAt(n);r|=0}return r>>>0});var r=vt.call(this)||this;if(t<16||0!=(t&t-1))throw new RangeError("InitBucketNum range error");return r.O=r.Z=t,r.$=e,r}e(q,mt=i),q.prototype.I=function(){var o=this;if(!(1073741824<=this.O)){for(var s=[],h=this.O,u=(this.O<<=1,Object.keys(this.tt)),t=u.length,a=this,e=0;e<t;++e)!function(t){var e,r,t=parseInt(u[t]),i=a.tt[t],n=i.size();0===n||(1===n?(n=i.front(),s[a.$(n)&a.O-1]=new d([n],!1)):(e=[],r=[],i.forEach(function(t){(0==(o.$(t)&h)?e:r).push(t)}),i instanceof V?(6<e.length?s[t]=new V(e):s[t]=new d(e,!1),6<r.length?s[t+h]=new V(r):s[t+h]=new d(r,!1)):(s[t]=new d(e,!1),s[t+h]=new d(r,!1))))}(e);this.tt=s}},q.prototype.forEach=function(e){for(var t=Object.values(this.tt),r=t.length,i=0,n=0;n<r;++n)t[n].forEach(function(t){return e(t,i++)})},q.prototype.insert=function(t){var e=this.$(t)&this.O-1,r=this.tt[e];if(r){var i=r.size();if(r instanceof d){if(!r.find(t).equals(r.end()))return;if(r.pushBack(t),8<=i+1){if(this.O<=64)return this.t+=1,void this.I();this.tt[e]=new V(r)}this.t+=1}else{r.insert(t);r=r.size();this.t+=r-i}}else this.tt[e]=new d([t],!1),this.t+=1;this.t>.75*this.O&&this.I()},q.prototype.eraseElementByKey=function(t){var e,r,i=this.$(t)&this.O-1,n=this.tt[i];!n||0!==(e=n.size())&&(n instanceof d?(n.eraseElementByValue(t),r=n.size(),this.t+=r-e):(n.eraseElementByKey(t),r=n.size(),this.t+=r-e,r<=6&&(this.tt[i]=new d(n))))},q.prototype.find=function(t){var e=this.$(t)&this.O-1,e=this.tt[e];return!!e&&!e.find(t).equals(e.end())},q.prototype[Symbol.iterator]=function(){return function(){var e,r,i,n,o,s,h,u,a;return f(this,function(t){switch(t.label){case 0:e=Object.values(this.tt),r=e.length,i=0,t.label=1;case 1:if(!(i<r))return[3,10];n=e[i],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,o=p(n),s=o.next(),t.label=3;case 3:return s.done?[3,6]:[4,s.value];case 4:t.sent(),t.label=5;case 5:return s=o.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(u)throw u.error}return[7];case 9:return++i,[3,1];case 10:return[2]}})}.bind(this)()};var mt,o=q;function q(t,e,r){void 0===t&&(t=[]);var i=mt.call(this,e,r)||this;return i.tt=[],t.forEach(function(t){return i.insert(t)}),i}e(M,gt=i),M.prototype.I=function(){var o=this;if(!(1073741824<=this.O)){for(var s=[],h=this.O,u=(this.O<<=1,Object.keys(this.tt)),t=u.length,a=this,e=0;e<t;++e)!function(t){var e,r,t=parseInt(u[t]),i=a.tt[t],n=i.size();0===n||(1===n?(n=i.front(),s[a.$(n[0])&a.O-1]=new d([n],!1)):(e=[],r=[],i.forEach(function(t){(0==(o.$(t[0])&h)?e:r).push(t)}),i instanceof z?(6<e.length?s[t]=new z(e):s[t]=new d(e,!1),6<r.length?s[t+h]=new z(r):s[t+h]=new d(r,!1)):(s[t]=new d(e,!1),s[t+h]=new d(r,!1))))}(e);this.tt=s}},M.prototype.forEach=function(e){for(var t=Object.values(this.tt),r=t.length,i=0,n=0;n<r;++n)t[n].forEach(function(t){return e(t,i++)})},M.prototype.setElement=function(t,e){var r,i=this.$(t)&this.O-1,n=this.tt[i];if(n){var o=n.size();if(n instanceof d){try{for(var s=p(n),h=s.next();!h.done;h=s.next()){var u=h.value;if(u[0]===t)return void(u[1]=e)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}if(n.pushBack([t,e]),8<=o+1){if(this.O<=64)return this.t+=1,void this.I();this.tt[i]=new z(this.tt[i])}this.t+=1}else{n.setElement(t,e);var a=n.size();this.t+=a-o}}else this.t+=1,this.tt[i]=new d([[t,e]],!1);this.t>.75*this.O&&this.I()},M.prototype.getElementByKey=function(t){var e,r,i=this.$(t)&this.O-1,i=this.tt[i];if(i){if(i instanceof z)return i.getElementByKey(t);try{for(var n=p(i),o=n.next();!o.done;o=n.next()){var s=o.value;if(s[0]===t)return s[1]}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}},M.prototype.eraseElementByKey=function(t){var e=this.$(t)&this.O-1,r=this.tt[e];if(r)if(r instanceof d){var i=0;try{for(var n=p(r),o=n.next();!o.done;o=n.next()){if(o.value[0]===t)return r.eraseElementByPos(i),void--this.t;i+=1}}catch(t){h={error:t}}finally{try{o&&!o.done&&(s=n.return)&&s.call(n)}finally{if(h)throw h.error}}}else{var s=r.size(),h=(r.eraseElementByKey(t),r.size());this.t+=h-s,h<=6&&(this.tt[e]=new d(r))}},M.prototype.find=function(t){var e,r,i=this.$(t)&this.O-1,i=this.tt[i];if(i){if(i instanceof z)return!i.find(t).equals(i.end());try{for(var n=p(i),o=n.next();!o.done;o=n.next())if(o.value[0]===t)return!0}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}return!1},M.prototype[Symbol.iterator]=function(){return function(){var e,r,i,n,o,s,h,u,a;return f(this,function(t){switch(t.label){case 0:e=Object.values(this.tt),r=e.length,i=0,t.label=1;case 1:if(!(i<r))return[3,10];n=e[i],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,o=p(n),s=o.next(),t.label=3;case 3:return s.done?[3,6]:[4,s.value];case 4:t.sent(),t.label=5;case 5:return s=o.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(u)throw u.error}return[7];case 9:return++i,[3,1];case 10:return[2]}})}.bind(this)()};var gt,r=M;function M(t,e,r){void 0===t&&(t=[]);var i=gt.call(this,e,r)||this;return i.tt=[],t.forEach(function(t){return i.setElement(t[0],t[1])}),i}t.Deque=J,t.HashMap=r,t.HashSet=o,t.LinkList=H,t.OrderedMap=z,t.OrderedSet=V,t.PriorityQueue=tt,t.Queue=W,t.Stack=F,t.Vector=d,Object.defineProperty(t,"it",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("sdsl",["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var I=function(t,e){return(I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}I(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function f(i,n){var o,s,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(r){return function(t){var e=[r,t];if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,s&&(h=2&e[0]?s.return:e[0]?s.throw||((h=s.return)&&h.call(s),0):s.next)&&!(h=h.call(s,e[1])).done)return h;switch(s=0,(e=h?[2&e[0],h.value]:e)[0]){case 0:case 1:h=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,s=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!h||e[1]>h[0]&&e[1]<h[3]))u.label=e[1];else if(6===e[0]&&u.label<h[1])u.label=h[1],h=e;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(e)}}e=n.call(i,u)}catch(t){e=[6,t],s=0}finally{o=h=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function p(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&i>=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function l(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||((i=i||Array.prototype.slice.call(e,0,n))[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function D(t){this.iteratorType=t=void 0===t?0:t}N.prototype.size=function(){return this.t},N.prototype.empty=function(){return 0===this.t};var r=N;function N(){this.t=0}e(j,_=r);var _,i=j;function j(){return null!==_&&_.apply(this,arguments)||this}e(n,A=r),n.prototype.clear=function(){this.t=0,this.i.length=0},n.prototype.push=function(t){this.i.push(t),this.t+=1},n.prototype.pop=function(){this.i.pop(),0<this.t&&--this.t},n.prototype.top=function(){return this.i[this.t-1]};var A,F=n;function n(t){void 0===t&&(t=[]);var e=A.call(this)||this;return e.i=[],t.forEach(function(t){return e.push(t)}),e}e($,K=i);var K,o=$;function $(){return null!==K&&K.apply(this,arguments)||this}e(s,Y=D),Object.defineProperty(s.prototype,"pointer",{get:function(){return this.o(this.h)},set:function(t){this.v(this.h,t)},enumerable:!1,configurable:!0}),s.prototype.equals=function(t){return this.h===t.h};var Y,H=s;function s(t,e,r,i,n){n=Y.call(this,n)||this;return n.h=t,n.u=e,n.o=r,n.v=i,0===n.iteratorType?(n.pre=function(){if(0===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this},n.next=function(){if(this.h===this.u())throw new RangeError("Random Iterator access denied!");return this.h+=1,this}):(n.pre=function(){if(this.h===this.u()-1)throw new RangeError("Random iterator access denied!");return this.h+=1,this},n.next=function(){if(-1===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this}),n}e(X,U=H),X.prototype.copy=function(){return new X(this.h,this.u,this.o,this.v,this.iteratorType)};var U,h=X;function X(){return null!==U&&U.apply(this,arguments)||this}e(u,G=o),u.prototype.I=function(){for(var t=[],e=Math.max(this.O>>1,1),r=0;r<e;++r)t[r]=new Array(this.S);for(r=this.l;r<this.O;++r)t[t.length]=this.k[r];for(r=0;r<this.L;++r)t[t.length]=this.k[r];t[t.length]=l([],c(this.k[this.L]),!1),this.l=e,this.L=t.length-1;for(r=0;r<e;++r)t[t.length]=new Array(this.S);this.k=t,this.O=t.length},u.prototype.g=function(t){var t=this._+t+1,e=t%this.S,r=e-1,t=this.l+(t-e)/this.S;return 0==e&&--t,t%=this.O,r<0&&(r+=this.S),{curNodeBucketIndex:t,curNodePointerIndex:r}},u.prototype.clear=function(){this.k=[[]],this.O=1,this.l=this.L=this.t=0,this._=this.p=this.S>>1},u.prototype.front=function(){return this.k[this.l][this._]},u.prototype.back=function(){return this.k[this.L][this.p]},u.prototype.begin=function(){return new h(0,this.size,this.getElementByPos,this.setElementByPos)},u.prototype.end=function(){return new h(this.t,this.size,this.getElementByPos,this.setElementByPos)},u.prototype.rBegin=function(){return new h(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},u.prototype.rEnd=function(){return new h(-1,this.size,this.getElementByPos,this.setElementByPos,1)},u.prototype.pushBack=function(t){this.t&&(this.p<this.S-1?this.p+=1:(this.L<this.O-1?this.L+=1:this.L=0,this.p=0),this.L===this.l&&this.p===this._&&this.I()),this.t+=1,this.k[this.L][this.p]=t},u.prototype.popBack=function(){this.t&&(this.k[this.L][this.p]=void 0,1!==this.t&&(0<this.p?--this.p:(0<this.L?--this.L:this.L=this.O-1,this.p=this.S-1)),--this.t)},u.prototype.pushFront=function(t){this.t&&(0<this._?--this._:(0<this.l?--this.l:this.l=this.O-1,this._=this.S-1),this.l===this.L&&this._===this.p&&this.I()),this.t+=1,this.k[this.l][this._]=t},u.prototype.popFront=function(){this.t&&(this.k[this.l][this._]=void 0,1!==this.t&&(this._<this.S-1?this._+=1:(this.l<this.O-1?this.l+=1:this.l=0,this._=0)),--this.t)},u.prototype.forEach=function(t){for(var e=0;e<this.t;++e)t(this.getElementByPos(e),e)},u.prototype.getElementByPos=function(t){var t=this.g(t),e=t.curNodeBucketIndex,t=t.curNodePointerIndex;return this.k[e][t]},u.prototype.setElementByPos=function(t,e){var t=this.g(t),r=t.curNodeBucketIndex,t=t.curNodePointerIndex;this.k[r][t]=e},u.prototype.insert=function(t,e,r){if(void 0===r&&(r=1),0===t)for(;r--;)this.pushFront(e);else if(t===this.t)for(;r--;)this.pushBack(e);else{for(var i=[],n=t;n<this.t;++n)i.push(this.getElementByPos(n));this.cut(t-1);for(n=0;n<r;++n)this.pushBack(e);for(n=0;n<i.length;++n)this.pushBack(i[n])}},u.prototype.cut=function(t){var e,r;t<0?this.clear():(e=(r=this.g(t)).curNodeBucketIndex,r=r.curNodePointerIndex,this.L=e,this.p=r,this.t=t+1)},u.prototype.eraseElementByPos=function(t){var e=this;if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var r=[],i=t+1;i<this.t;++i)r.push(this.getElementByPos(i));this.cut(t),this.popBack(),r.forEach(function(t){return e.pushBack(t)})}},u.prototype.eraseElementByValue=function(t){if(this.t){for(var e=[],r=0;r<this.t;++r){var i=this.getElementByPos(r);i!==t&&e.push(i)}for(var n=e.length,r=0;r<n;++r)this.setElementByPos(r,e[r]);this.cut(n-1)}},u.prototype.eraseElementByIterator=function(t){var e=t.h;return this.eraseElementByPos(e),t=t.next()},u.prototype.find=function(t){for(var e=0;e<this.t;++e)if(this.getElementByPos(e)===t)return new h(e,this.size,this.getElementByPos,this.setElementByPos);return this.end()},u.prototype.reverse=function(){for(var t=0,e=this.t-1;t<e;){var r=this.getElementByPos(t);this.setElementByPos(t,this.getElementByPos(e)),this.setElementByPos(e,r),t+=1,--e}},u.prototype.unique=function(){if(!(this.t<=1)){for(var t=1,e=this.getElementByPos(0),r=1;r<this.t;++r){var i=this.getElementByPos(r);i!==e&&this.setElementByPos(t++,e=i)}for(;this.t>t;)this.popBack()}},u.prototype.sort=function(t){for(var e=[],r=0;r<this.t;++r)e.push(this.getElementByPos(r));e.sort(t);for(r=0;r<this.t;++r)this.setElementByPos(r,e[r])},u.prototype.shrinkToFit=function(){if(this.t){var e=[];this.forEach(function(t){return e.push(t)}),this.O=Math.max(Math.ceil(this.t/this.S),1),this.t=this.l=this.L=this._=this.p=0,this.k=[];for(var t=0;t<this.O;++t)this.k.push(new Array(this.S));for(t=0;t<e.length;++t)this.pushBack(e[t])}},u.prototype[Symbol.iterator]=function(){return function(){var e;return f(this,function(t){switch(t.label){case 0:e=0,t.label=1;case 1:return e<this.t?[4,this.getElementByPos(e)]:[3,4];case 2:t.sent(),t.label=3;case 3:return++e,[3,1];case 4:return[2]}})}.bind(this)()};var G,J=u;function u(t,e){void 0===t&&(t=[]),void 0===e&&(e=4096);var r,i=G.call(this)||this;if(i.l=0,i._=0,i.L=0,i.p=0,i.O=0,i.k=[],"size"in t)r="number"==typeof t.size?t.size:t.size();else{if(!("length"in t))throw new RangeError("Can't get container's size!");r=t.length}i.S=e,i.O=Math.max(Math.ceil(r/i.S),1);for(var n=0;n<i.O;++n)i.k.push(new Array(i.S));e=Math.ceil(r/i.S);return i.l=i.L=(i.O>>1)-(e>>1),i._=i.p=i.S-r%i.S>>1,t.forEach(function(t){return i.pushBack(t)}),i.size=i.size.bind(i),i.getElementByPos=i.getElementByPos.bind(i),i.setElementByPos=i.setElementByPos.bind(i),i}e(a,Q=r),a.prototype.clear=function(){this.T.clear(),this.t=0},a.prototype.push=function(t){this.T.pushBack(t),this.t+=1},a.prototype.pop=function(){this.T.popFront(),this.t&&--this.t},a.prototype.front=function(){return this.T.front()};var Q,W=a;function a(t){void 0===t&&(t=[]);var e=Q.call(this)||this;return e.T=new J(t),e.t=e.T.size(),e}e(y,Z=r),y.prototype.clear=function(){this.t=0,this.q.length=0},y.prototype.push=function(t){var e=this.t;for(this.t+=1,this.q.push(t);0<e;){var r=e-1>>1,i=this.q[r];if(this.M(i,t)<=0)break;this.q[e]=i,e=r}this.q[e]=t},y.prototype.pop=function(){if(this.t){var t=this.q.pop();if(--this.t,this.t){for(var e=0,r=this.t>>1;e<r;){var i=e<<1|1,n=i+1,o=this.q[i],s=this.q[n];if(n<this.t&&0<this.M(o,s)&&(i=n,o=s),0<=this.M(o,t))break;this.q[e]=o,e=i}this.q[e]=t}}},y.prototype.top=function(){return this.q[0]};var Z,tt=y;function y(t,e,r){void 0===t&&(t=[]),void 0===e&&(e=function(t,e){return e<t?-1:t<e?1:0}),void 0===r&&(r=!0);for(var i=Z.call(this)||this,n=(i.M=e,Array.isArray(t)?i.q=r?l([],c(t),!1):t:(i.q=[],t.forEach(function(t){return i.q.push(t)})),i.t=i.q.length,i.t>>1),o=i.t-1>>1;0<=o;--o){for(var s=o,h=i.q[s];s<n;){var u=s<<1|1,a=u+1,f=i.q[u];if(a<i.t&&0<i.M(f,i.q[a])&&(f=i.q[u=a]),0<=i.M(f,h))break;i.q[s]=f,s=u}i.q[s]=h}return i}e(rt,et=H),rt.prototype.copy=function(){return new rt(this.h,this.u,this.o,this.v,this.iteratorType)};var et,v=rt;function rt(){return null!==et&&et.apply(this,arguments)||this}e(m,it=o),m.prototype.clear=function(){this.t=0,this.D.length=0},m.prototype.begin=function(){return new v(0,this.size,this.getElementByPos,this.setElementByPos)},m.prototype.end=function(){return new v(this.t,this.size,this.getElementByPos,this.setElementByPos)},m.prototype.rBegin=function(){return new v(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},m.prototype.rEnd=function(){return new v(-1,this.size,this.getElementByPos,this.setElementByPos,1)},m.prototype.front=function(){return this.D[0]},m.prototype.back=function(){return this.D[this.t-1]},m.prototype.forEach=function(t){for(var e=0;e<this.t;++e)t(this.D[e],e)},m.prototype.getElementByPos=function(t){return this.D[t]},m.prototype.eraseElementByPos=function(t){this.D.splice(t,1),--this.t},m.prototype.eraseElementByValue=function(t){for(var e=0,r=0;r<this.t;++r)this.D[r]!==t&&(this.D[e++]=this.D[r]);this.t=this.D.length=e},m.prototype.eraseElementByIterator=function(t){var e=t.h;return t=t.next(),this.eraseElementByPos(e),t},m.prototype.pushBack=function(t){this.D.push(t),this.t+=1},m.prototype.popBack=function(){this.t&&(this.D.pop(),--this.t)},m.prototype.setElementByPos=function(t,e){this.D[t]=e},m.prototype.insert=function(t,e,r){var i;void 0===r&&(r=1),(i=this.D).splice.apply(i,l([t,0],c(new Array(r).fill(e)),!1)),this.t+=r},m.prototype.find=function(t){for(var e=0;e<this.t;++e)if(this.D[e]===t)return new v(e,this.size,this.getElementByPos,this.getElementByPos);return this.end()},m.prototype.reverse=function(){this.D.reverse()},m.prototype.unique=function(){for(var t=1,e=1;e<this.t;++e)this.D[e]!==this.D[e-1]&&(this.D[t++]=this.D[e]);this.t=this.D.length=t},m.prototype.sort=function(t){this.D.sort(t)},m.prototype[Symbol.iterator]=function(){return function(){return f(this,function(t){switch(t.label){case 0:return[5,p(this.D)];case 1:return[2,t.sent()]}})}.bind(this)()};var it,d=m;function m(t,e){void 0===t&&(t=[]),void 0===e&&(e=!0);var r=it.call(this)||this;return Array.isArray(t)?(r.D=e?l([],c(t),!1):t,r.t=t.length):(r.D=[],t.forEach(function(t){return r.pushBack(t)})),r.size=r.size.bind(r),r.getElementByPos=r.getElementByPos.bind(r),r.setElementByPos=r.setElementByPos.bind(r),r}var nt,g=function(t){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=t},w=(e(E,nt=D),Object.defineProperty(E.prototype,"pointer",{get:function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h.value},set:function(t){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");this.h.value=t},enumerable:!1,configurable:!0}),E.prototype.equals=function(t){return this.h===t.h},E.prototype.copy=function(){return new E(this.h,this.m,this.iteratorType)},E);function E(t,e,r){r=nt.call(this,r)||this;return r.h=t,r.m=e,0===r.iteratorType?(r.pre=function(){if(this.h.pre===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.pre,this},r.next=function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.next,this}):(r.pre=function(){if(this.h.next===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.next,this},r.next=function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.pre,this}),r}e(B,ot=o),B.prototype.clear=function(){this.t=0,this.C=this.R=void 0,this.m.pre=this.m.next=void 0},B.prototype.begin=function(){return new w(this.C||this.m,this.m)},B.prototype.end=function(){return new w(this.m,this.m)},B.prototype.rBegin=function(){return new w(this.R||this.m,this.m,1)},B.prototype.rEnd=function(){return new w(this.m,this.m,1)},B.prototype.front=function(){return this.C?this.C.value:void 0},B.prototype.back=function(){return this.R?this.R.value:void 0},B.prototype.forEach=function(t){if(this.t)for(var e=this.C,r=0;e!==this.m;)t(e.value,r++),e=e.next},B.prototype.getElementByPos=function(t){for(var e=this.C;t--;)e=e.next;return e.value},B.prototype.eraseElementByPos=function(t){if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var e=this.C;t--;)e=e.next;var r=e.pre,i=e.next;(i.pre=r).next=i,--this.t}},B.prototype.eraseElementByValue=function(t){for(;this.C&&this.C.value===t;)this.popFront();for(;this.R&&this.R.value===t;)this.popBack();if(this.C)for(var e,r,i=this.C;i!==this.m;)i.value===t&&(e=i.pre,(r=i.next)&&(r.pre=e),e&&(e.next=r),--this.t),i=i.next},B.prototype.eraseElementByIterator=function(t){var e,r=t.h;if(r===this.m)throw new RangeError("Invalid iterator");return t=t.next(),this.C===r?this.popFront():this.R===r?this.popBack():(e=r.pre,(r=r.next)&&(r.pre=e),e&&(e.next=r),--this.t),t},B.prototype.pushBack=function(t){this.t+=1;t=new g(t);this.R?((this.R.next=t).pre=this.R,this.R=t):(this.C=this.R=t,this.m.next=this.C,this.C.pre=this.m),this.R.next=this.m,this.m.pre=this.R},B.prototype.popBack=function(){this.R&&(--this.t,this.C===this.R?(this.C=this.R=void 0,this.m.next=void 0):(this.R=this.R.pre,this.R&&(this.R.next=void 0)),this.m.pre=this.R,this.R&&(this.R.next=this.m))},B.prototype.setElementByPos=function(t,e){for(var r=this.C;t--;)r=r.next;r.value=e},B.prototype.insert=function(t,e,r){if(!((r=void 0===r?1:r)<=0))if(0===t)for(;r--;)this.pushFront(e);else if(t===this.t)for(;r--;)this.pushBack(e);else{for(var i=this.C,n=1;n<t;++n)i=i.next;var o=i.next;for(this.t+=r;r--;)i.next=new g(e),i=(i.next.pre=i).next;(i.next=o)&&(o.pre=i)}},B.prototype.find=function(t){if(this.C)for(var e=this.C;e!==this.m;){if(e.value===t)return new w(e,this.m);e=e.next}return this.end()},B.prototype.reverse=function(){if(!(this.t<=1))for(var t=this.C,e=this.R,r=0;r<<1<this.t;){var i=t.value;t.value=e.value,e.value=i,t=t.next,e=e.pre,r+=1}},B.prototype.unique=function(){if(!(this.t<=1))for(var t=this.C;t!==this.m;){for(var e=t;e.next&&e.value===e.next.value;)e=e.next,--this.t;t.next=e.next,t.next&&(t.next.pre=t),t=t.next}},B.prototype.sort=function(t){var e,r;this.t<=1||(e=[],this.forEach(function(t){return e.push(t)}),e.sort(t),r=this.C,e.forEach(function(t){r.value=t,r=r.next}))},B.prototype.pushFront=function(t){this.t+=1;t=new g(t);this.C?(t.next=this.C,this.C.pre=t,this.C=t):(this.C=this.R=t,this.R.next=this.m,this.m.pre=this.R),this.m.next=this.C,this.C.pre=this.m},B.prototype.popFront=function(){this.C&&(--this.t,this.C===this.R?(this.C=this.R=void 0,this.m.pre=this.R):(this.C=this.C.next,this.C&&(this.C.pre=this.m)),this.m.next=this.C)},B.prototype.merge=function(t){var r,i=this;this.C?(r=this.C,t.forEach(function(t){for(;r&&r!==i.m&&r.value<=t;)r=r.next;var e;r===i.m?(i.pushBack(t),r=i.R):r===i.C?(i.pushFront(t),r=i.C):(i.t+=1,(e=r.pre).next=new g(t),((e.next.pre=e).next.next=r).pre=e.next)})):t.forEach(function(t){return i.pushBack(t)})},B.prototype[Symbol.iterator]=function(){return function(){var e;return f(this,function(t){switch(t.label){case 0:if(!this.C)return[2];e=this.C,t.label=1;case 1:return e===this.m?[3,3]:[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})}.bind(this)()};var ot,H=B;function B(t){void 0===t&&(t=[]);var e=ot.call(this)||this;return e.m=new g,e.C=void 0,e.R=void 0,t.forEach(function(t){return e.pushBack(t)}),e}b.prototype.pre=function(){var t=this;if(1===t.color&&t.parent.parent===t)t=t.right;else if(t.left)for(t=t.left;t.right;)t=t.right;else{for(var e=t.parent;e.left===t;)e=(t=e).parent;t=e}return t},b.prototype.next=function(){var t=this;if(t.right)for(t=t.right;t.left;)t=t.left;else{for(var e=t.parent;e.right===t;)e=(t=e).parent;t.right!==e&&(t=e)}return t},b.prototype.rotateLeft=function(){var t=this.parent,e=this.right,r=e.left;return t.parent===this?t.parent=e:t.left===this?t.left=e:t.right=e,e.parent=t,(e.left=this).parent=e,(this.right=r)&&(r.parent=this),e},b.prototype.rotateRight=function(){var t=this.parent,e=this.left,r=e.right;return t.parent===this?t.parent=e:t.left===this?t.left=e:t.right=e,e.parent=t,(e.right=this).parent=e,(this.left=r)&&(r.parent=this),e};var st=b;function b(t,e){this.color=1,this.key=void 0,this.value=void 0,this.left=void 0,this.right=void 0,this.parent=void 0,this.key=t,this.value=e}e(k,x=st),k.prototype.rotateLeft=function(){var t=x.prototype.rotateLeft.call(this);return this.recount(),t.recount(),t},k.prototype.rotateRight=function(){var t=x.prototype.rotateRight.call(this);return this.recount(),t.recount(),t},k.prototype.recount=function(){this.subTreeSize=1,this.left&&(this.subTreeSize+=this.left.subTreeSize),this.right&&(this.subTreeSize+=this.right.subTreeSize)};var x,ht=k;function k(){var t=null!==x&&x.apply(this,arguments)||this;return t.left=void 0,t.right=void 0,t.parent=void 0,t.subTreeSize=1,t}e(P,ut=i),P.prototype.J=function(t,e){for(var r;t;){var i=this.M(t.key,e);if(i<0)t=t.right;else{if(!(0<i))return t;t=(r=t).left}}return void 0===r?this.m:r},P.prototype.F=function(t,e){for(var r;t;){var i=this.M(t.key,e);i<=0?t=t.right:0<i&&(t=(r=t).left)}return void 0===r?this.m:r},P.prototype.K=function(t,e){for(var r;t;){var i=this.M(t.key,e);if(i<0)t=(r=t).right;else{if(!(0<i))return t;t=t.left}}return void 0===r?this.m:r},P.prototype.U=function(t,e){for(var r;t;){var i=this.M(t.key,e);i<0?t=(r=t).right:0<=i&&(t=t.left)}return void 0===r?this.m:r},P.prototype.W=function(t){for(;;){var e,r=t.parent;if(r===this.m)return;if(1===t.color)return void(t.color=0);if(t===r.left){if(1===(e=r.right).color)e.color=0,r.color=1,r===this.V?this.V=r.rotateLeft():r.rotateLeft();else if(0===e.color){if(e.right&&1===e.right.color)return e.color=r.color,r.color=0,e.right.color=0,void(r===this.V?this.V=r.rotateLeft():r.rotateLeft());e.left&&1===e.left.color?(e.color=1,e.left.color=0,e.rotateRight()):(e.color=1,t=r)}}else if(1===(e=r.left).color)e.color=0,r.color=1,r===this.V?this.V=r.rotateRight():r.rotateRight();else{if(e.left&&1===e.left.color)return e.color=r.color,r.color=0,e.left.color=0,void(r===this.V?this.V=r.rotateRight():r.rotateRight());e.right&&1===e.right.color?(e.color=1,e.right.color=0,e.rotateLeft()):(e.color=1,t=r)}}},P.prototype.G=function(t){var e;if(1===this.t)return this.clear(),this.m;for(var r=t;r.left||r.right;){if(r.right)for(r=r.right;r.left;)r=r.left;else r.left&&(r=r.left);e=c([r.key,t.key],2),t.key=e[0],r.key=e[1],e=c([r.value,t.value],2),t.value=e[0],r.value=e[1],t=r}this.m.left===r?this.m.left=r.parent:this.m.right===r&&(this.m.right=r.parent),this.W(r);var i=r.parent;return r===i.left?i.left=void 0:i.right=void 0,--this.t,this.V.color=0,i},P.prototype.P=function(t){for(;;){var e=t.parent;if(0===e.color)return;var r,i,n=e.parent;if(e===n.left){if((r=n.right)&&1===r.color){if(r.color=e.color=0,n===this.V)return;n.color=1,t=n;continue}if(t===e.right)return t.color=0,t.left&&(t.left.parent=e),t.right&&(t.right.parent=n),e.right=t.left,n.left=t.right,t.left=e,(t.right=n)===this.V?(this.V=t,this.m.parent=t):(i=n.parent).left===n?i.left=t:i.right=t,t.parent=n.parent,e.parent=t,n.parent=t,n.color=1,{parentNode:e,grandParent:n,curNode:t};e.color=0,n===this.V?this.V=n.rotateRight():n.rotateRight()}else{if((r=n.left)&&1===r.color){if(r.color=e.color=0,n===this.V)return;n.color=1,t=n;continue}if(t===e.left)return t.color=0,t.left&&(t.left.parent=n),t.right&&(t.right.parent=e),n.right=t.left,e.left=t.right,t.left=n,t.right=e,n===this.V?(this.V=t,this.m.parent=t):(i=n.parent).left===n?i.left=t:i.right=t,t.parent=n.parent,e.parent=t,n.parent=t,n.color=1,{parentNode:e,grandParent:n,curNode:t};e.color=0,n===this.V?this.V=n.rotateLeft():n.rotateLeft()}return void(n.color=1)}},P.prototype.A=function(t,e,r){if(void 0===this.V)this.t+=1,this.V=new this.N(t,e),this.V.color=0,this.V.parent=this.m,this.m.parent=this.V,this.m.left=this.V,this.m.right=this.V;else{var i,n=this.m.left,o=this.M(n.key,t);if(0!==o){if(0<o)n.left=new this.N(t,e),i=(n.left.parent=n).left,this.m.left=i;else{var o=this.m.right,s=this.M(o.key,t);if(0===s)return void(o.value=e);if(s<0)o.right=new this.N(t,e),i=(o.right.parent=o).right,this.m.right=i;else{if(void 0!==r){s=r.h;if(s!==this.m){o=this.M(s.key,t);if(0===o)return void(s.value=e);if(0<o){r=s.pre(),o=this.M(r.key,t);if(0===o)return void(r.value=e);o<0&&(i=new this.N(t,e),void 0===r.right?(r.right=i).parent=r:(s.left=i).parent=s)}}}if(void 0===i)for(i=this.V;;){var h=this.M(i.key,t);if(0<h){if(void 0===i.left){i.left=new this.N(t,e),i=(i.left.parent=i).left;break}i=i.left}else{if(!(h<0))return void(i.value=e);if(void 0===i.right){i.right=new this.N(t,e),i=(i.right.parent=i).right;break}i=i.right}}}}return this.t+=1,i}n.value=e}},P.prototype.clear=function(){this.t=0,this.V=void 0,this.m.parent=void 0,this.m.left=this.m.right=void 0},P.prototype.updateKeyByIterator=function(t,e){t=t.h;if(t===this.m)throw new TypeError("Invalid iterator!");if(1!==this.t){if(t===this.m.left)return 0<this.M(t.next().key,e)&&(t.key=e,!0);if(t===this.m.right)return this.M(t.pre().key,e)<0&&(t.key=e,!0);var r=t.pre().key;if(0<=this.M(r,e))return!1;if(r=t.next().key,this.M(r,e)<=0)return!1}return t.key=e,!0},P.prototype.eraseElementByPos=function(e){var r=this,i=0;this.H(this.V,function(t){return e===i?(r.B(t),!0):(i+=1,!1)})},P.prototype.X=function(t,e){for(;t;){var r=this.M(t.key,e);if(r<0)t=t.right;else{if(!(0<r))return t;t=t.left}}return t},P.prototype.eraseElementByKey=function(t){!this.t||void 0!==(t=this.X(this.V,t))&&this.B(t)},P.prototype.eraseElementByIterator=function(t){var e=t.h;if(e===this.m)throw new RangeError("Invalid iterator");return void 0===e.right&&(t=t.next()),this.B(e),t},P.prototype.getHeight=function(){var e;return this.t?(e=function(t){return t?Math.max(e(t.left),e(t.right))+1:0})(this.V):0};var ut,o=P;function P(t,e){void 0===t&&(t=function(t,e){return t<e?-1:e<t?1:0}),void 0===e&&(e=!1);var r=ut.call(this)||this;return r.V=void 0,r.H=function(t,e){return void 0!==t&&(!!r.H(t.left,e)||(!!e(t)||r.H(t.right,e)))},r.M=t,e?(r.N=ht,r.j=function(t,e,r){t=this.A(t,e,r);if(t){for(var i=t.parent;i!==this.m;)i.subTreeSize+=1,i=i.parent;var e=this.P(t);e&&(r=e.parentNode,t=e.grandParent,e=e.curNode,r.recount(),t.recount(),e.recount())}},r.B=function(t){for(var e=this.G(t);e!==this.m;)--e.subTreeSize,e=e.parent}):(r.N=st,r.j=function(t,e,r){t=this.A(t,e,r);t&&this.P(t)},r.B=r.G),r.m=new r.N,r}e(ft,at=D),Object.defineProperty(ft.prototype,"index",{get:function(){var t=this.h,e=this.m.parent;if(t===this.m)return e?e.subTreeSize-1:0;var r=0;for(t.left&&(r+=t.left.subTreeSize);t!==e;){var i=t.parent;t===i.right&&(r+=1,i.left&&(r+=i.left.subTreeSize)),t=i}return r},enumerable:!1,configurable:!0}),ft.prototype.equals=function(t){return this.h===t.h};var at,i=ft;function ft(t,e,r){r=at.call(this,r)||this;return r.h=t,r.m=e,0===r.iteratorType?(r.pre=function(){if(this.h===this.m.left)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this},r.next=function(){if(this.h===this.m)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this}):(r.pre=function(){if(this.h===this.m.right)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this},r.next=function(){if(this.h===this.m)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this}),r}e(O,pt=i),Object.defineProperty(O.prototype,"pointer",{get:function(){if(this.h===this.m)throw new RangeError("OrderedSet iterator access denied!");return this.h.key},enumerable:!1,configurable:!0}),O.prototype.copy=function(){return new O(this.h,this.m,this.iteratorType)};var pt,R=O;function O(){return null!==pt&&pt.apply(this,arguments)||this}e(C,ct=o),C.prototype.begin=function(){return new R(this.m.left||this.m,this.m)},C.prototype.end=function(){return new R(this.m,this.m)},C.prototype.rBegin=function(){return new R(this.m.right||this.m,this.m,1)},C.prototype.rEnd=function(){return new R(this.m,this.m,1)},C.prototype.front=function(){return this.m.left?this.m.left.key:void 0},C.prototype.back=function(){return this.m.right?this.m.right.key:void 0},C.prototype.forEach=function(t){var e,r,i=0;try{for(var n=p(this),o=n.next();!o.done;o=n.next())t(o.value,i++)}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},C.prototype.getElementByPos=function(t){var e,r,i,n=0;try{for(var o=p(this),s=o.next();!s.done;s=o.next()){var h=s.value;if(n===t){i=h;break}n+=1}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},C.prototype.insert=function(t,e){this.j(t,void 0,e)},C.prototype.find=function(t){t=this.X(this.V,t);return void 0!==t?new R(t,this.m):this.end()},C.prototype.lowerBound=function(t){t=this.J(this.V,t);return new R(t,this.m)},C.prototype.upperBound=function(t){t=this.F(this.V,t);return new R(t,this.m)},C.prototype.reverseLowerBound=function(t){t=this.K(this.V,t);return new R(t,this.m)},C.prototype.reverseUpperBound=function(t){t=this.U(this.V,t);return new R(t,this.m)},C.prototype.union=function(t){var e=this;t.forEach(function(t){return e.insert(t)})},C.prototype[Symbol.iterator]=function(){return this.Y(this.V)};var ct,V=C;function C(t,e,r){void 0===t&&(t=[]);var i=ct.call(this,e,r)||this;return i.Y=function(e){return f(this,function(t){switch(t.label){case 0:return void 0===e?[2]:[5,p(this.Y(e.left))];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,p(this.Y(e.right))];case 3:return t.sent(),[2]}})},t.forEach(function(t){return i.insert(t)}),i}e(L,lt=i),Object.defineProperty(L.prototype,"pointer",{get:function(){var i=this;if(this.h===this.m)throw new RangeError("OrderedMap iterator access denied");return new Proxy([],{get:function(t,e){return"0"===e?i.h.key:"1"===e?i.h.value:void 0},set:function(t,e,r){if("1"!==e)throw new TypeError("props must be 1");return i.h.value=r,!0}})},enumerable:!1,configurable:!0}),L.prototype.copy=function(){return new L(this.h,this.m,this.iteratorType)};var lt,S=L;function L(){return null!==lt&&lt.apply(this,arguments)||this}e(T,yt=o),T.prototype.begin=function(){return new S(this.m.left||this.m,this.m)},T.prototype.end=function(){return new S(this.m,this.m)},T.prototype.rBegin=function(){return new S(this.m.right||this.m,this.m,1)},T.prototype.rEnd=function(){return new S(this.m,this.m,1)},T.prototype.front=function(){var t;if(this.t)return[(t=this.m.left).key,t.value]},T.prototype.back=function(){var t;if(this.t)return[(t=this.m.right).key,t.value]},T.prototype.forEach=function(t){var e,r,i=0;try{for(var n=p(this),o=n.next();!o.done;o=n.next())t(o.value,i++)}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},T.prototype.lowerBound=function(t){t=this.J(this.V,t);return new S(t,this.m)},T.prototype.upperBound=function(t){t=this.F(this.V,t);return new S(t,this.m)},T.prototype.reverseLowerBound=function(t){t=this.K(this.V,t);return new S(t,this.m)},T.prototype.reverseUpperBound=function(t){t=this.U(this.V,t);return new S(t,this.m)},T.prototype.setElement=function(t,e,r){this.j(t,e,r)},T.prototype.find=function(t){t=this.X(this.V,t);return void 0!==t?new S(t,this.m):this.end()},T.prototype.getElementByKey=function(t){t=this.X(this.V,t);return t?t.value:void 0},T.prototype.getElementByPos=function(t){var e,r,i,n=0;try{for(var o=p(this),s=o.next();!s.done;s=o.next()){var h=s.value;if(n===t){i=h;break}n+=1}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},T.prototype.union=function(t){var r=this;t.forEach(function(t){var t=c(t,2),e=t[0],t=t[1];return r.setElement(e,t)})},T.prototype[Symbol.iterator]=function(){return this.Y(this.V)};var yt,z=T;function T(t,e,r){void 0===t&&(t=[]);var i=yt.call(this,e,r)||this;return i.Y=function(e){return f(this,function(t){switch(t.label){case 0:return void 0===e?[2]:[5,p(this.Y(e.left))];case 1:return t.sent(),[4,[e.key,e.value]];case 2:return t.sent(),[5,p(this.Y(e.right))];case 3:return t.sent(),[2]}})},t.forEach(function(t){var t=c(t,2),e=t[0],t=t[1];return i.setElement(e,t)}),i}e(dt,vt=r),dt.prototype.clear=function(){this.t=0,this.O=this.Z,this.tt=[]};var vt,i=dt;function dt(t,e){void 0===t&&(t=16),void 0===e&&(e=function(t){for(var e="string"!=typeof t?JSON.stringify(t):t,r=0,i=e.length,n=0;n<i;n++){r=(r<<5)-r+e.charCodeAt(n);r|=0}return r>>>0});var r=vt.call(this)||this;if(t<16||0!=(t&t-1))throw new RangeError("InitBucketNum range error");return r.O=r.Z=t,r.$=e,r}e(q,mt=i),q.prototype.I=function(){var o=this;if(!(1073741824<=this.O)){for(var s=[],h=this.O,u=(this.O<<=1,Object.keys(this.tt)),t=u.length,a=this,e=0;e<t;++e)!function(t){var e,r,t=parseInt(u[t]),i=a.tt[t],n=i.size();0===n||(1===n?(n=i.front(),s[a.$(n)&a.O-1]=new d([n],!1)):(e=[],r=[],i.forEach(function(t){(0==(o.$(t)&h)?e:r).push(t)}),i instanceof V?(6<e.length?s[t]=new V(e):s[t]=new d(e,!1),6<r.length?s[t+h]=new V(r):s[t+h]=new d(r,!1)):(s[t]=new d(e,!1),s[t+h]=new d(r,!1))))}(e);this.tt=s}},q.prototype.forEach=function(e){for(var t=Object.values(this.tt),r=t.length,i=0,n=0;n<r;++n)t[n].forEach(function(t){return e(t,i++)})},q.prototype.insert=function(t){var e=this.$(t)&this.O-1,r=this.tt[e];if(r){var i=r.size();if(r instanceof d){if(!r.find(t).equals(r.end()))return;if(r.pushBack(t),8<=i+1){if(this.O<=64)return this.t+=1,void this.I();this.tt[e]=new V(r)}this.t+=1}else{r.insert(t);r=r.size();this.t+=r-i}}else this.tt[e]=new d([t],!1),this.t+=1;this.t>.75*this.O&&this.I()},q.prototype.eraseElementByKey=function(t){var e,r,i=this.$(t)&this.O-1,n=this.tt[i];!n||0!==(e=n.size())&&(n instanceof d?(n.eraseElementByValue(t),r=n.size(),this.t+=r-e):(n.eraseElementByKey(t),r=n.size(),this.t+=r-e,r<=6&&(this.tt[i]=new d(n))))},q.prototype.find=function(t){var e=this.$(t)&this.O-1,e=this.tt[e];return!!e&&!e.find(t).equals(e.end())},q.prototype[Symbol.iterator]=function(){return function(){var e,r,i,n,o,s,h,u,a;return f(this,function(t){switch(t.label){case 0:e=Object.values(this.tt),r=e.length,i=0,t.label=1;case 1:if(!(i<r))return[3,10];n=e[i],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,o=p(n),s=o.next(),t.label=3;case 3:return s.done?[3,6]:[4,s.value];case 4:t.sent(),t.label=5;case 5:return s=o.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(u)throw u.error}return[7];case 9:return++i,[3,1];case 10:return[2]}})}.bind(this)()};var mt,o=q;function q(t,e,r){void 0===t&&(t=[]);var i=mt.call(this,e,r)||this;return i.tt=[],t.forEach(function(t){return i.insert(t)}),i}e(M,gt=i),M.prototype.I=function(){var o=this;if(!(1073741824<=this.O)){for(var s=[],h=this.O,u=(this.O<<=1,Object.keys(this.tt)),t=u.length,a=this,e=0;e<t;++e)!function(t){var e,r,t=parseInt(u[t]),i=a.tt[t],n=i.size();0===n||(1===n?(n=i.front(),s[a.$(n[0])&a.O-1]=new d([n],!1)):(e=[],r=[],i.forEach(function(t){(0==(o.$(t[0])&h)?e:r).push(t)}),i instanceof z?(6<e.length?s[t]=new z(e):s[t]=new d(e,!1),6<r.length?s[t+h]=new z(r):s[t+h]=new d(r,!1)):(s[t]=new d(e,!1),s[t+h]=new d(r,!1))))}(e);this.tt=s}},M.prototype.forEach=function(e){for(var t=Object.values(this.tt),r=t.length,i=0,n=0;n<r;++n)t[n].forEach(function(t){return e(t,i++)})},M.prototype.setElement=function(t,e){var r,i=this.$(t)&this.O-1,n=this.tt[i];if(n){var o=n.size();if(n instanceof d){try{for(var s=p(n),h=s.next();!h.done;h=s.next()){var u=h.value;if(u[0]===t)return void(u[1]=e)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}if(n.pushBack([t,e]),8<=o+1){if(this.O<=64)return this.t+=1,void this.I();this.tt[i]=new z(this.tt[i])}this.t+=1}else{n.setElement(t,e);var a=n.size();this.t+=a-o}}else this.t+=1,this.tt[i]=new d([[t,e]],!1);this.t>.75*this.O&&this.I()},M.prototype.getElementByKey=function(t){var e,r,i=this.$(t)&this.O-1,i=this.tt[i];if(i){if(i instanceof z)return i.getElementByKey(t);try{for(var n=p(i),o=n.next();!o.done;o=n.next()){var s=o.value;if(s[0]===t)return s[1]}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}},M.prototype.eraseElementByKey=function(t){var e=this.$(t)&this.O-1,r=this.tt[e];if(r)if(r instanceof d){var i=0;try{for(var n=p(r),o=n.next();!o.done;o=n.next()){if(o.value[0]===t)return r.eraseElementByPos(i),void--this.t;i+=1}}catch(t){h={error:t}}finally{try{o&&!o.done&&(s=n.return)&&s.call(n)}finally{if(h)throw h.error}}}else{var s=r.size(),h=(r.eraseElementByKey(t),r.size());this.t+=h-s,h<=6&&(this.tt[e]=new d(r))}},M.prototype.find=function(t){var e,r,i=this.$(t)&this.O-1,i=this.tt[i];if(i){if(i instanceof z)return!i.find(t).equals(i.end());try{for(var n=p(i),o=n.next();!o.done;o=n.next())if(o.value[0]===t)return!0}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}return!1},M.prototype[Symbol.iterator]=function(){return function(){var e,r,i,n,o,s,h,u,a;return f(this,function(t){switch(t.label){case 0:e=Object.values(this.tt),r=e.length,i=0,t.label=1;case 1:if(!(i<r))return[3,10];n=e[i],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,o=p(n),s=o.next(),t.label=3;case 3:return s.done?[3,6]:[4,s.value];case 4:t.sent(),t.label=5;case 5:return s=o.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(u)throw u.error}return[7];case 9:return++i,[3,1];case 10:return[2]}})}.bind(this)()};var gt,r=M;function M(t,e,r){void 0===t&&(t=[]);var i=gt.call(this,e,r)||this;return i.tt=[],t.forEach(function(t){return i.setElement(t[0],t[1])}),i}t.Deque=J,t.HashMap=r,t.HashSet=o,t.LinkList=H,t.OrderedMap=z,t.OrderedSet=V,t.PriorityQueue=tt,t.Queue=W,t.Stack=F,t.Vector=d,Object.defineProperty(t,"it",{value:!0})});
//# sourceMappingURL=js-sdsl.min.js.map
{
"name": "js-sdsl",
"version": "4.1.5-beta.0",
"version": "4.1.5-beta.1",
"description": "javascript standard data structure library which benchmark against C++ STL",

@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc