/*! * js-sdsl v4.2.0 * https://github.com/js-sdsl/js-sdsl * (c) 2021-present ZLY201 * MIT license */ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var k=function(t,i){return(k=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,i){t.__proto__=i}:function(t,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}))(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=t}k(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}function r(e,n){var s,o,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},p={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(p[Symbol.iterator]=function(){return this}),p;function t(r){return function(t){var i=[r,t];if(s)throw new TypeError("Generator is already executing.");for(;u=p&&i[p=0]?0:u;)try{if(s=1,o&&(h=2&i[0]?o.return:i[0]?o.throw||((h=o.return)&&h.call(o),0):o.next)&&!(h=h.call(o,i[1])).done)return h;switch(o=0,(i=h?[2&i[0],h.value]:i)[0]){case 0:case 1:h=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,o=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!h||i[1]>h[0]&&i[1]=t.length?void 0:t)&&t[e++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(t,i){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,n,s=r.call(t),o=[];try{for(;(void 0===i||0this.u()-1)throw new RangeError;return this.o(this.t)},set:function(t){if(this.t<0||this.t>this.u()-1)throw new RangeError;this.v(this.t,t)},enumerable:!1,configurable:!0});var z,Y=W;function W(t,i,r,e,n){n=z.call(this,n)||this;return n.t=t,n.u=i,n.o=r,n.v=e,0===n.iteratorType?(n.pre=function(){return 0===this.t&&o(),--this.t,this},n.next=function(){return this.t===this.u()&&o(),this.t+=1,this}):(n.pre=function(){return this.t===this.u()-1&&o(),this.t+=1,this},n.next=function(){return-1===this.t&&o(),--this.t,this}),n}i(Z,X=Y),Z.prototype.copy=function(){return new Z(this.t,this.u,this.o,this.v,this.iteratorType)};var X,f=Z;function Z(){return null!==X&&X.apply(this,arguments)||this}i(c,C=H),c.prototype.k=function(){for(var t=[],i=Math.max(this.S>>1,1),r=0;r>1},c.prototype.begin=function(){return new f(0,this.size,this.getElementByPos,this.setElementByPos)},c.prototype.end=function(){return new f(this.i,this.size,this.getElementByPos,this.setElementByPos)},c.prototype.rBegin=function(){return new f(this.i-1,this.size,this.getElementByPos,this.setElementByPos,1)},c.prototype.rEnd=function(){return new f(-1,this.size,this.getElementByPos,this.setElementByPos,1)},c.prototype.front=function(){return this.L[this.l][this._]},c.prototype.back=function(){return this.L[this.p][this.I]},c.prototype.pushBack=function(t){return this.i&&(this.Ithis.i-1)throw new RangeError;var t=this.g(t),i=t.curNodeBucketIndex,t=t.curNodePointerIndex;return this.L[i][t]},c.prototype.setElementByPos=function(t,i){if(t<0||t>this.i-1)throw new RangeError;var t=this.g(t),r=t.curNodeBucketIndex,t=t.curNodePointerIndex;this.L[r][t]=i},c.prototype.insert=function(t,i,r){if(void 0===r&&(r=1),t<0||t>this.i)throw new RangeError;if(0===t)for(;r--;)this.pushFront(i);else if(t===this.i)for(;r--;)this.pushBack(i);else{for(var e=[],n=t;nthis.i-1)throw new RangeError;if(0===t)this.popFront();else if(t===this.i-1)this.popBack();else{for(var i=[],r=t+1;rt;)this.popBack()}return this.i},c.prototype.sort=function(t){for(var i=[],r=0;r>1)-(i>>1),e._=e.I=e.O-r%e.O>>1,e);return t.forEach(function(t){s.pushBack(t)}),e.size=e.size.bind(e),e.getElementByPos=e.getElementByPos.bind(e),e.setElementByPos=e.setElementByPos.bind(e),e}i(a,tt=n),a.prototype.clear=function(){this.H.clear(),this.i=0},a.prototype.push=function(t){return this.H.pushBack(t),this.i+=1,this.i},a.prototype.pop=function(){if(0!==this.i)return--this.i,this.H.popFront()},a.prototype.front=function(){return this.H.front()};var tt,it=a;function a(t){void 0===t&&(t=[]);var i=tt.call(this)||this;return i.H=new Q(t),i.i=i.H.size(),i}i(l,rt=n),l.prototype.T=function(t){for(var i=this.A[t];0>1,e=this.A[r];if(this.M(e,i)<=0)break;this.A[t]=e,t=r}this.A[t]=i},l.prototype.C=function(t,i){for(var r=this.A[t];t>1)),t},l.prototype.top=function(){return this.A[0]},l.prototype.find=function(t){return 0<=this.A.indexOf(t)},l.prototype.remove=function(t){t=this.A.indexOf(t);return!(t<0||(0===t?this.pop():t===this.i-1?(this.A.pop(),--this.i):(this.A.splice(t,1,this.A.pop()),--this.i,this.T(t),this.C(t,this.i>>1)),0))},l.prototype.updateItem=function(t){t=this.A.indexOf(t);return!(t<0||(this.T(t),this.C(t,this.i>>1),0))},l.prototype.toArray=function(){return p([],h(this.A),!1)};var rt,n=l;function l(t,i,r){void 0===t&&(t=[]),void 0===i&&(i=function(t,i){return i>1),o=n.i-1>>1;0<=o;--o)n.C(o,s);return n}i(nt,et=Y),nt.prototype.copy=function(){return new nt(this.t,this.u,this.o,this.v,this.iteratorType)};var et,y=nt;function nt(){return null!==et&&et.apply(this,arguments)||this}i(v,st=H),v.prototype.clear=function(){this.i=0,this.q.length=0},v.prototype.begin=function(){return new y(0,this.size,this.getElementByPos,this.setElementByPos)},v.prototype.end=function(){return new y(this.i,this.size,this.getElementByPos,this.setElementByPos)},v.prototype.rBegin=function(){return new y(this.i-1,this.size,this.getElementByPos,this.setElementByPos,1)},v.prototype.rEnd=function(){return new y(-1,this.size,this.getElementByPos,this.setElementByPos,1)},v.prototype.front=function(){return this.q[0]},v.prototype.back=function(){return this.q[this.i-1]},v.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.q[t]},v.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.q.splice(t,1),--this.i,this.i},v.prototype.eraseElementByValue=function(t){for(var i=0,r=0;rthis.i-1)throw new RangeError;this.q[t]=i},v.prototype.insert=function(t,i,r){var e;if(void 0===r&&(r=1),t<0||t>this.i)throw new RangeError;return(e=this.q).splice.apply(e,p([t,0],h(new Array(r).fill(i)),!1)),this.i+=r,this.i},v.prototype.find=function(t){for(var i=0;ithis.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return i.R},w.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return this.P(i),this.i},w.prototype.eraseElementByValue=function(t){for(var i=this.j;i!==this.D;)i.R===t&&this.P(i),i=i.V;return this.i},w.prototype.eraseElementByIterator=function(t){var i=t.t;return i===this.D&&o(),t=t.next(),this.P(i),t},w.prototype.pushBack=function(t){return this.B(t,this.N),this.i},w.prototype.popBack=function(){var t;if(0!==this.i)return t=this.N.R,this.P(this.N),t},w.prototype.pushFront=function(t){return this.B(t,this.D),this.i},w.prototype.popFront=function(){var t;if(0!==this.i)return t=this.j.R,this.P(this.j),t},w.prototype.setElementByPos=function(t,i){if(t<0||t>this.i-1)throw new RangeError;for(var r=this.j;t--;)r=r.V;r.R=i},w.prototype.insert=function(t,i,r){if(void 0===r&&(r=1),t<0||t>this.i)throw new RangeError;if(!(r<=0))if(0===t)for(;r--;)this.pushFront(i);else if(t===this.i)for(;r--;)this.pushBack(i);else{for(var e=this.j,n=1;nthis.i-1)throw new RangeError;var r=0,e=this;return this.ct(this.$,function(t){return i===r?(e.P(t),!0):(r+=1,!1)}),this.i},b.prototype.eraseElementByKey=function(t){return 0!==this.i&&(t=this.vt(this.$,t))!==this.D&&(this.P(t),!0)},b.prototype.eraseElementByIterator=function(t){var i=t.t,r=(i===this.D&&o(),void 0===i.K);return 0===t.iteratorType?r&&t.next():r&&void 0!==i.J||t.next(),this.P(i),t},b.prototype.forEach=function(t){var i,r,e=0;try{for(var n=u(this),s=n.next();!s.done;s=n.next())t(s.value,e++,this)}catch(t){i={error:t}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}},b.prototype.getElementByPos=function(t){var i,r,e;if(t<0||t>this.i-1)throw new RangeError;var n=0;try{for(var s=u(this),o=s.next();!o.done;o=s.next()){var h=o.value;if(n===t){e=h;break}n+=1}}catch(t){i={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return e},b.prototype.getHeight=function(){var i;return 0===this.i?0:(i=function(t){return t?Math.max(i(t.J),i(t.K))+1:0})(this.$)};var ft,B=b;function b(t,i){void 0===t&&(t=function(t,i){return tthis.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return this.P(i),this.i};var Bt,e=U;function U(){var t=Bt.call(this)||this;return t.lt=[],t.wt={},t.HASH_TAG=Symbol("@@HASH_TAG"),Object.setPrototypeOf(t.wt,null),t.D={},t.D.m=t.D.V=t.j=t.N=t.D,t}i(G,bt=B),Object.defineProperty(G.prototype,"pointer",{get:function(){return this.t===this.D&&o(),this.t.F},enumerable:!1,configurable:!0}),G.prototype.copy=function(){return new G(this.t,this.D,this.iteratorType)};var bt,j=G;function G(){return null!==bt&&bt.apply(this,arguments)||this}i(F,Pt=e),F.prototype.begin=function(){return new j(this.j,this.D)},F.prototype.end=function(){return new j(this.D,this.D)},F.prototype.rBegin=function(){return new j(this.N,this.D,1)},F.prototype.rEnd=function(){return new j(this.D,this.D,1)},F.prototype.front=function(){return this.j.F},F.prototype.back=function(){return this.N.F},F.prototype.insert=function(t,i){return this.it(t,void 0,i)},F.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return i.F},F.prototype.find=function(t,i){t=this.vt(t,i);return new j(t,this.D)},F.prototype.forEach=function(t){for(var i=0,r=this.j;r!==this.D;)t(r.F,i++,this),r=r.V},F.prototype[Symbol.iterator]=function(){return function(){var i;return r(this,function(t){switch(t.label){case 0:i=this.j,t.label=1;case 1:return i===this.D?[3,3]:[4,i.F];case 2:return t.sent(),i=i.V,[3,1];case 3:return[2]}})}.bind(this)()};var Pt,_=F;function F(t){void 0===t&&(t=[]);var i=Pt.call(this)||this,r=i;return t.forEach(function(t){r.insert(t)}),i}i(Kt,Jt=B),Object.defineProperty(Kt.prototype,"pointer",{get:function(){this.t===this.D&&o();var e=this;return new Proxy([],{get:function(t,i){return"0"===i?e.t.F:"1"===i?e.t.R:void 0},set:function(t,i,r){if("1"!==i)throw new TypeError("props must be 1");return e.t.R=r,!0}})},enumerable:!1,configurable:!0}),Kt.prototype.copy=function(){return new Kt(this.t,this.D,this.iteratorType)};var Jt,x=Kt;function Kt(){return null!==Jt&&Jt.apply(this,arguments)||this}i($,Rt=e),$.prototype.begin=function(){return new x(this.j,this.D)},$.prototype.end=function(){return new x(this.D,this.D)},$.prototype.rBegin=function(){return new x(this.N,this.D,1)},$.prototype.rEnd=function(){return new x(this.D,this.D,1)},$.prototype.front=function(){if(0!==this.i)return[this.j.F,this.j.R]},$.prototype.back=function(){if(0!==this.i)return[this.N.F,this.N.R]},$.prototype.setElement=function(t,i,r){return this.it(t,i,r)},$.prototype.getElementByKey=function(t,i){return(i=void 0===i?mt(t):i)?void 0!==(i=t[this.HASH_TAG])?this.lt[i].R:void 0:(i=this.wt[t])?i.R:void 0},$.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.j;t--;)i=i.V;return[i.F,i.R]},$.prototype.find=function(t,i){t=this.vt(t,i);return new x(t,this.D)},$.prototype.forEach=function(t){for(var i=0,r=this.j;r!==this.D;)t([r.F,r.R],i++,this),r=r.V},$.prototype[Symbol.iterator]=function(){return function(){var i;return r(this,function(t){switch(t.label){case 0:i=this.j,t.label=1;case 1:return i===this.D?[3,3]:[4,[i.F,i.R]];case 2:return t.sent(),i=i.V,[3,1];case 3:return[2]}})}.bind(this)()};var Rt,B=$;function $(t){void 0===t&&(t=[]);var i=Rt.call(this)||this,r=i;return t.forEach(function(t){r.setElement(t[0],t[1])}),i}t.Deque=Q,t.HashMap=B,t.HashSet=_,t.LinkList=H,t.OrderedMap=at,t.OrderedSet=dt,t.PriorityQueue=n,t.Queue=it,t.Stack=q,t.Vector=Y,Object.defineProperty(t,"_t",{value:!0})}); //# sourceMappingURL=js-sdsl.min.js.map