diff --git a/dist/dastal.min.js b/dist/dastal.min.js index 4a35eca..47672c0 100644 --- a/dist/dastal.min.js +++ b/dist/dastal.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Dastal",[],e):"object"==typeof exports?exports.Dastal=e():t.Dastal=e()}(self,(function(){return(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AATree:()=>ce,AVLTree:()=>ke,ArrayList:()=>ht,ArrayQueue:()=>Wt,ArrayStack:()=>re,ArrayUtils:()=>i,BinaryHeap:()=>$,DoublyLinkedList:()=>pt,InOrderSegmentTree:()=>Nt,IteratorUtils:()=>r,LevelOrderSegmentTree:()=>Kt,LinkedList:()=>At,LinkedQueue:()=>$t,LinkedStack:()=>oe,NumberUtils:()=>n,SkewHeap:()=>lt,StringUtils:()=>a,isCollection:()=>E,u32:()=>o});var r={};t.r(r),t.d(r,{always:()=>l,fill:()=>u,first:()=>s,join:()=>h,never:()=>f,once:()=>c,skip:()=>v,split:()=>y});var n={};t.r(n),t.d(n,{clamp:()=>g,wrap:()=>b,wrapLeft:()=>d,wrapRight:()=>p});var i={};t.r(i),t.d(i,{MAX_ARRAY_LENGTH:()=>w,MAX_SAFE_ARGUMENT_LENGTH:()=>A,isArray:()=>S,isTypedArray:()=>O,splice:()=>_});var a={};t.r(a),t.d(a,{pad:()=>R});var o={};function l(t){return{next:function(){return{done:!1,value:t()}}}}function u(t,e){return{next:function(){return t<1?{done:!0,value:void 0}:(--t,{done:!1,value:e()})}}}function s(t,e){return{next:function(){if(t<1)return{done:!0,value:void 0};var r=e.next();return t=r.done?0:t-1,r}}}function h(t){var e={next:function(){return{done:!0,value:void 0}}};return{next:function(){if(null==e)return{done:!0,value:void 0};for(var r=e.next();r.done;){var n=t.next();if(n.done)return e=void 0,{done:!0,value:void 0};r=(e=n.value).next()}return r}}}function f(){return{next:function(){return{done:!0,value:void 0}}}}function c(t){var e=!1;return{next:function(){var r={done:e,value:t()};return e=!0,t=function(){},r}}}function v(t,e){var r=function(){for(var n={done:!1,value:void 0};t-- >0&&!n.done;)n=e.next();return r=e.next.bind(e),n};return{next:function(){return r()}}}function y(t,e){if(t<1)return{next:function(){return{done:!0,value:void 0}}};var r=!1;return{next:function(){if(r)return{done:r,value:void 0};var n=s(t,e),i=n.next();return i.done?{done:r=!0,value:void 0}:{done:r,value:h([c((function(){return i.value})),n][Symbol.iterator]())}}}}function g(t,e,r){return Math.min(r,Math.max(e,t))}function d(t,e,r){return tr?e+(t-r):t}function b(t,e,r){return tt.length)&&(e=t.length);for(var r=0,n=new Array(e);rSt,invert:()=>zt,isPow2:()=>jt,lsb:()=>Ot,lsp:()=>_t,lsps:()=>Rt,msb:()=>Et,msp:()=>It,msps:()=>Pt,reverse:()=>Tt,u32:()=>Mt});var w=4294967295,A=32767;function S(t){return t instanceof Array||O(t)}var z,j,O=(z=Object.getPrototypeOf(Uint8Array),function(t){return t instanceof z});function _(t,e,r,n){var i,a;if(e=g(d(null!==(i=e)&&void 0!==i?i:0,0,t.length),0,t.length),r=g(null!==(a=r)&&void 0!==a?a:t.length,0,t.length-e),null==n)return t.splice(e,r);var o=A-2,l=n[Symbol.iterator](),u=t.length-r,h=w-u,f=Math.min(o,h),c=t.splice.apply(t,[e,r].concat(k(m({},Symbol.iterator,(function(){return s(f,l)})))));for(e+=u=t.length-u,f=h-u;f>=o&&u>=o;f-=u)u=t.length,t.splice.apply(t,[e,0].concat(k(m({},Symbol.iterator,(function(){return s(o,l)}))))),e+=u=t.length-u;if(f>0&&u>=o&&t.splice.apply(t,[e,0].concat(k(m({},Symbol.iterator,(function(){return s(f,l)}))))),1!=l.next().done)throw new RangeError("Invalid array length");return c}function R(t,e,r){var n=t.length;if(n>=e)return t;var i=e-n;return t.padStart(n+i/2,r).padEnd(n+i,r)}function E(t){return null!=t&&"number"==typeof t.size&&"function"==typeof t[Symbol.iterator]}function I(t,e,r){for(var n=r[t];t>0;){var i=Math.floor((t+1)/2)-1,a=r[i];if(e(a,n)<=0)break;r[i]=n,r[t]=a,t=i}}function P(t,e){for(var r=e.length+1>>>1;r>0;T(--r,t,e));}function T(t,e,r){for(var n=r.length,i=r[t];;){var a=2*t+1;if(a>=n)break;var o=r[a];if(a+11;i=i.next){var a;e[0]=null!==(a=e[0].next)&&void 0!==a?a:e.pop(),T(0,r,e),i.next=e[0]}return n}((function(e,r){return t(r.value,e.value)}),n),s=u.value;u=u.next;){var h=u.value;h.right=h.left,h.left=s,s=h}return s}function C(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return F(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?F(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rw)throw new RangeError("Invalid heap length");for(var n=0;n=w)throw new RangeError("Invalid heap length");e.push(o)}}catch(t){a.e(t)}finally{a.f()}}return r=0}},{key:"delete",value:function(t){var e=this.array.indexOf(t);if(e<0)return!1;var r=this.array.pop();return e>=this.array.length||(this.array[e]=r,T(e,this.compare,this.array),I(e,this.compare,this.array)),!0}},{key:"merge",value:function(t){var e=this.array;if(t.size<1)return this;if(e.length+t.size>w)throw new RangeError("Invalid heap length");var r,n=C(t);try{for(n.s();!(r=n.n()).done;){var i=r.value;e.push(i)}}catch(t){n.e(t)}finally{n.f()}return P(this.compare,e),this}},{key:"peek",value:function(){return this.array.length>0?this.array[0]:void 0}},{key:"pop",value:function(){if(!(this.array.length<1)){var t=this.array[0],e=this.array.pop();return this.array.length>0&&(this.array[0]=e,T(0,this.compare,this.array)),t}}},{key:"push",value:function(t){return this.array.push(t),I(this.array.length-1,this.compare,this.array),this.size}},{key:"pushPop",value:function(t){if(this.array.length<1||this.compare(t,this.array[0])<=0)return t;var e=this.array[0];return this.array[0]=t,T(0,this.compare,this.array),e}},{key:"replace",value:function(t){if(!(this.array.length<1)){var e=this.array[0];return this.array[0]=t,t=e,T(0,this.compare,this.array),t}this.array.push(t)}},{key:"size",get:function(){return this.array.length}},{key:"sorted",value:regeneratorRuntime.mark((function e(){var r,n,i,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.array.length<1)){e.next=2;break}return e.abrupt("return");case 2:r=this.array,n=new t((function(t,e){return a.compare(r[t],r[e])}),[0]);case 4:if(!((i=n.pop())0){e.next=4;break}case 12:case"end":return e.stop()}}),e,this)}))},{key:j,value:function(){return this.array[Symbol.iterator]()}},{key:"update",value:function(t,e){var r=this.array.indexOf(t);return!(r<0||(this.array[r]=e,T(r,this.compare,this.array),I(r,this.compare,this.array),0))}}])&&W(e.prototype,r),t}(),X=regeneratorRuntime.mark(G),q=regeneratorRuntime.mark(B);function Z(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=t.value,n=r.to;if(null==n)return t;if(null==n.right)n=n.left;else if(null==n.left)n=n.right;else if(e){var i=(r=(t=tt(t)).value).to;n.value=i.value,n=i.right}else{var a=(r=(t=Q(t)).value).to;n.value=a.value,n=a.left}return r.to=n,r.from&&(r.from[r.label]=r.to=n),t}function D(t){if(null!=t){var e=Object.assign({},t),r={value:e};do{t=r.value,r=r.next,t.left&&(r={next:r,value:t.left=Object.assign({},t.left)}),t.right&&(r={next:r,value:t.right=Object.assign({},t.right)})}while(r);return e}}function H(t){if(null!=t){for(;t.left;)t=t.left;return t}}function N(t){var e=t.value.to;if(null==e)return t;for(;e.left;)t={next:t,value:{label:"left",from:e,to:e.left}},e=e.left;return t}function G(t){var e;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(e=void 0;t;)e={next:e,value:t},t=t.left;case 2:if(!e){r.next=11;break}return t=e.value,e=e.next,r.next=7,t;case 7:for(t=t.right;t;)e={next:e,value:t},t=t.left;r.next=2;break;case 11:case"end":return r.stop()}}),X)}function Q(t){var e=t.value.to;return null==e?t:Y(t={next:t,value:{label:"left",from:e,to:e.left}})}function B(t){var e;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:e={value:t};case 1:if(t=e.value,e=e.next,!t){r.next=8;break}return r.next=6,t;case 6:e={next:e={next:e,value:t.right},value:t.left};case 8:if(e){r.next=1;break}case 9:case"end":return r.stop()}}),q)}function V(t){if(null!=t){for(;t.right;)t=t.right;return t}}function Y(t){var e=t.value.to;if(null==e)return t;for(;e.right;)t={next:t,value:{label:"right",from:e,to:e.right}},e=e.right;return t}function J(t,e,r){for(;e;){var n=r(t,e.value);if(0==n)break;e=n<0?e.left:e.right}return e}function K(t,e,r){for(var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=["left","right"],a=e.value.to;a;){var o=r(t,a.value)||n;if(0===o)break;var l=i[+(o>0)];e={next:e,value:{label:l,from:a,to:a[l]}},a=a[l]}return e}function tt(t){var e=t.value.to;return null==e?t:N(t={next:t,value:{label:"right",from:e,to:e.right}})}function et(t){if(!(null==t||t.length<1||null==t[0])){var e=t.length,r=new Array(e);r[0]={value:t[0]};for(var n=1;n>>1],a={value:t[n]};r[n]=a,1&n?i.left=a:i.right=a}return r[0]}}function rt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return nt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function nt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0){e.next=3;break}case 9:case"end":return e.stop()}}),e,this)}))},{key:L,value:regeneratorRuntime.mark((function t(){var e,r,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=rt(B(this.root)),t.prev=1,e.s();case 3:if((r=e.n()).done){t.next=9;break}return n=r.value,t.next=7,n.value;case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),e.e(t.t0);case 14:return t.prev=14,e.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])}))},{key:"update",value:function(t,e){if(null==this.root)return!1;if(this.root.value===t)return this.root=M(this.compare,[this.root.left,this.root.right,{value:e}]),!0;var r,n=void 0,i=rt(B(this.root));try{for(i.s();!(r=i.n()).done;){var a=r.value;if(a.left&&a.left.value===t){n=a.left,a.left=void 0;break}if(a.right&&a.right.value===t){n=a.right,a.right=void 0;break}}}catch(t){i.e(t)}finally{i.f()}return null!=n&&(this.root=M(this.compare,[this.root,n.left,n.right,{value:e}]),!0)}}])&&it(e.prototype,r),t}();function ut(t,e){for(var r=0;r=0&&t<=this.size&&this.array.splice(t,0,e),this.size}},{key:"addAll",value:function(t,e){return t>=0&&t<=this.size&&_(this.array,t,0,e),this.size}},{key:"clear",value:function(){this.array.length=0}},{key:"concat",value:function(){for(var e=new t(this),r=arguments.length,n=new Array(r),i=0;i=this.size?void 0:this.array[t]}},{key:"getSet",value:function(t,e){var r=void 0;return t>=0&&t=this.size?void 0:this.array.splice(t,1)[0]}},{key:"reverse",value:function(t,e){var r,n;for(t=g(d(null!==(r=t)&&void 0!==r?r:0,0,this.size),0,this.size),e=g(d(null!==(n=e)&&void 0!==n?n:this.size,0,this.size),0,this.size)-1;t=0&&t=0?function(){return Math.min(r,a.size)}:function(){return a.size+r};case 2:if(!(e0);a.next=t[o],r&&(a.next.prev=a),a=a.next,t[o]=a.next,--e[o]}while(e[0]>0&&e[1]>0);return a.next=t[+(e[0]<1)],r&&a.next&&(a.next.prev=a),i.next}(a,i,r,n),r&&(t.prev=l),[t,o[+(i[0]<1)]]}function ct(t,e){if(t){if("string"==typeof t)return vt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vt(t,e):void 0}}function vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rthis.length)return this.length;var r=this._get(t-1),n={next:r.next,prev:r,value:e};return r.next=n,n.next.prev=n,++this.length}},{key:"addAll",value:function(t,e){return t>=0&&t<=this.length&&this._addAll(this._get(t),e),this.length}},{key:"clear",value:function(){this.length=0,this.root.prev=this.root.next=this.root}},{key:"concat",value:function(){for(var e=new t(this),r=arguments.length,n=new Array(r),i=0;i=(r=e+Math.min(r-e,this.length-t)))return this;if(e=this.length?void 0:this._get(t).value}},{key:"getSet",value:function(t,e){if(!(t<0||t>=this.length)){var r=this._get(t),n=r.value;return r.value=e(r.value),n}}},{key:"pop",value:function(){if(!(this.length<1)){var t=this.root.prev;return t.prev.next=this.root,this.root.prev=t.prev,--this.length,t.value}}},{key:"push",value:function(t){var e=this.root.prev,r={next:this.root,prev:e,value:t};return e.next=this.root.prev=r,++this.length}},{key:"remove",value:function(t){if(!(t<0||t>=this.length)){var e=this._get(t);return e.prev.next=e.next,e.next.prev=e.prev,--this.length,e.value}}},{key:"reverse",value:function(t,e){var r,n;if(t=g(d(null!==(r=t)&&void 0!==r?r:0,0,this.length),0,this.length),(e=g(d(null!==(n=e)&&void 0!==n?n:this.length,0,this.length),0,this.length))-t<2)return this;var i=this._get(t-1),a=i.next,o=a;do{var l=o.next;o.next=o.prev,o.prev=l,i.next=o,o=l}while(++t=this.length)){var r=this._get(t),n=r.value;return r.value=e,n}}},{key:"shift",value:function(){if(!(this.length<1)){var t=this.root.next;return t.next.prev=this.root,this.root.next=t.next,--this.length,t.value}}},{key:"size",get:function(){return this.length}},{key:"slice",value:function(e,r){return new t(this.view(e,r))}},{key:"splice",value:function(e,r,n){var i,a;e=g(d(null!==(i=e)&&void 0!==i?i:0,0,this.length),0,this.length),r=g(null!==(a=r)&&void 0!==a?a:this.size,0,this.size-e);var o=new t;if(null==n&&r<1)return o;for(var l=this._get(e);r-- >0;)o.push(l.value),l.prev.next=l.next,l.next.prev=l.prev,l=l.next,--this.length;return this._addAll(l,null!=n?n:[]),o}},{key:"sort",value:function(t){if(this.length>1){var e=(i=ft(this.root.next,this.length,!0,t),a=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a=[],o=!0,l=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);o=!0);}catch(t){l=!0,i=t}finally{try{o||null==r.return||r.return()}finally{if(l)throw i}}return a}}(i,a)||ct(i,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),r=e[0],n=e[1];this.root.next=r,n.next.prev=n}var i,a;return this}},{key:st,value:regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=this.root.next;case 1:if(e===this.root){t.next=7;break}return t.next=4,e.value;case 4:e=e.next,t.next=1;break;case 7:case"end":return t.stop()}}),t,this)}))},{key:"unshift",value:function(t){var e=this.root.next,r={next:e,prev:this.root,value:t};return this.root.next=e.prev=r,++this.length}},{key:"update",value:function(t,e,r){var n,i;if(null==r&&(arguments.length<2?(r=t,t=void 0):(r=e,e=void 0)),(t=g(d(null!==(n=t)&&void 0!==n?n:0,0,this.length),0,this.length))<(e=g(d(null!==(i=e)&&void 0!==i?i:this.length,0,this.length),0,this.length))){var a=this._get(t);do{a.value=r(a.value,t),a=a.next}while(++t=0?function(){return r}:function(){return o.length+r})())){t.next=8;break}a=this._get(e);case 4:return t.next=6,a.value;case 6:a=a.next;case 7:if(++e=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}(e);try{for(i.s();!(r=i.n()).done;){var a={prev:n,value:r.value};n.next=a,n=a,++this.length}}catch(t){i.e(t)}finally{i.f()}n.next=t,t.prev=n}},{key:"_get",value:function(t){var e=this.root;if(t=0;)e=e.next;else for(t=this.length-t;t>0;--t)e=e.prev;return e}}])&&yt(e.prototype,r),t}();function bt(t,e){if(t){if("string"==typeof t)return mt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?mt(t,e):void 0}}function mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0&&t=0&&t=(r=e+Math.min(r-e,this.length-t)))return this;if(tr){var o=this._get(e-1);return this._copyWithin(o,this._get(t-e-1,o),r-e),this}var l=this._get(e-1),u=this._get(r-e-1,l),s=this._copyWithin(l,u,t-e);t+(r-e)>=this.length&&(this.tail=u);var h=l.next;return l.next=u.next,u.next=s.next,s.next=h,this}},{key:"fill",value:function(t,e,r){var n,i;if((e=g(d(null!==(n=e)&&void 0!==n?n:0,0,this.length),0,this.length))<(r=g(d(null!==(i=r)&&void 0!==i?i:this.length,0,this.length),0,this.length))){var a=this._get(e);do{a.value=t,a=a.next}while(++e=this.length))return t=this.length)){var r=t=this.length)){var e=this._get(t-1),r=e.next;return e.next=r.next,t===--this.length&&(this.tail=e),r.value}}},{key:"reverse",value:function(t,e){var r,n;if(t=g(d(null!==(r=t)&&void 0!==r?r:0,0,this.length),0,this.length),(e=g(d(null!==(n=e)&&void 0!==n?n:this.length,0,this.length),0,this.length))-t<2)return this;var i=this._get(t-1);this.tail=e>=this.length?i.next:this.tail;for(var a=i.next,o=a,l=a.next;++t=this.length)){var r=this._get(t),n=r.value;return r.value=e,n}}},{key:"shift",value:function(){return this.remove(0)}},{key:"size",get:function(){return this.length}},{key:"slice",value:function(e,r){return new t(this.view(e,r))}},{key:"splice",value:function(e,r,n){var i,a;e=g(d(null!==(i=e)&&void 0!==i?i:0,0,this.length),0,this.length),r=g(null!==(a=r)&&void 0!==a?a:this.size,0,this.size-e);var o=new t;if(null==n&&r<1)return o;for(var l=this._get(e-1),u=e+r>=this.size;r-- >0;){var s=l.next;o.push(s.value),l.next=s.next,--this.length}return l=this._addAll(l,null!=n?n:[]),this.tail=u?l:this.tail,o}},{key:"sort",value:function(t){if(this.length>1){var e=(i=ft(this.root.next,this.length,!1,t),a=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a=[],o=!0,l=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);o=!0);}catch(t){l=!0,i=t}finally{try{o||null==r.return||r.return()}finally{if(l)throw i}}return a}}(i,a)||bt(i,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),r=e[0],n=e[1];this.root.next=r,this.tail=n}var i,a;return this}},{key:dt,value:regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=this.root.next;case 1:if(e===this.root){t.next=7;break}return t.next=4,e.value;case 4:e=e.next,t.next=1;break;case 7:case"end":return t.stop()}}),t,this)}))},{key:"unshift",value:function(t){return this.add(0,t)}},{key:"update",value:function(t,e,r){var n,i;if(null==r&&(arguments.length<2?(r=t,t=void 0):(r=e,e=void 0)),(t=g(d(null!==(n=t)&&void 0!==n?n:0,0,this.length),0,this.length))<(e=g(d(null!==(i=e)&&void 0!==i?i:this.length,0,this.length),0,this.length))){var a=this._get(t);do{a.value=r(a.value,t),a=a.next}while(++t=0?function(){return r}:function(){return o.length+r})())){t.next=8;break}a=this._get(e);case 4:return t.next=6,a.value;case 6:a=a.next;case 7:if(++e=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}(e);try{for(i.s();!(r=i.n()).done;){var a={value:r.value};t.next=a,t=a,++this.length}}catch(t){i.e(t)}finally{i.f()}return t.next=n,t}},{key:"_copyWithin",value:function(t,e,r){for(;r-- >0;)t=t.next,(e=e.next).value=t.value;return e}},{key:"_get",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.root,r=e;t-- >=0;)r=r.next;return r}}])&&kt(e.prototype,r),t}();function St(t){for(var e=0;t;)++e,t&=t-1;return e}function zt(t){var e=It(t);return Mt(t^(e|e-1))}function jt(t){return 0==(t&t-1)}function Ot(t){var e=-1;for(t=_t(t);t;t>>>=1)++e;return e}function _t(t){return Mt(t&-t)}function Rt(t){return Mt(t&_t(t+_t(t))-1)}function Et(t){for(var e=-1;0!==t;)++e,t>>>=1;return e}function It(t){for(var e=t&-t;t!=e;)e=(t^=e)&-t;return Mt(e)}function Pt(t){for(var e=t&-t;t&t+e;)e=(t^=e)&-t;return Mt(t)}function Tt(t){return Mt((t=(4278255360&(t=(4042322160&(t=(3435973836&(t=(2863311530&t)>>>1|(1431655765&t)<<1))>>>2|(858993459&t)<<2))>>>4|(252645135&t)<<4))>>>8|(16711935&t)<<8)>>>16|t<<16)}function Mt(t){return t>>>0}function Ct(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:[];qt(this,t),Dt(this,"array",void 0),Dt(this,"combine",void 0),this.array=[],this.combine=e,this.build(r)}var e,r;return e=t,(r=[{key:"clear",value:function(){this.array.length=0}},{key:"pop",value:function(){if(!(this.size<1)){for(var t=this.array.length-1,e=2;t&e;e*=2)this.array[t-e]=this.array[t-e-(e>>>1)];var r=this.array[t-1];return this.array.length-=2,r}}},{key:"push",value:function(e){if(this.size>=t.MAX_SIZE)throw new RangeError("Invalid length");var r=this.array.length;return this.array[r+1]=this.set(r,e),this.size}},{key:"query",value:function(t,e){if(t>=e)throw new RangeError("Range [".concat(t,"..").concat(e,") is empty"));if(t<0||e>this.size)throw new RangeError("Range [".concat(t,"..").concat(e,") not in [0..").concat(this.size,")"));var r=_t((t*=2)|It((e*=2)-t)),n=this.array[t-1+(r>>>1)];for(t+=r;t>>1)]);return n}},{key:"size",get:function(){return this.array.length>>>1}},{key:Lt,value:regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e=e)){if(t<0||e>this.size)throw new RangeError("Range [".concat(t,"..").concat(e,") not in [0..").concat(this.size,")"));var n;t*=2,e*=2;do{n=this.set(t,r(this.array[t],t>>>1)),t+=2}while(t0;--e)n=this.combine(n,this.array[t+(a>>>1)-i]),this.array[t]=n,t+=a-(i=(t&2*a)>>>0),a*=2;this.array[t]=n}}},{key:"build",value:function(t){var e,r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Xt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;this.push(n)}}catch(t){r.e(t)}finally{r.f()}}},{key:"set",value:function(t,e){this.array[t++]=e;for(var r=2;t&r;r*=2)e=this.combine(this.array[t-r-(r>>>1)],e),this.array[t-r]=e;return e}}])&&Zt(e.prototype,r),t}();function Gt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Qt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function Qt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r>>1),Ht=Symbol.iterator;var Jt,Kt=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];Bt(this,t),Yt(this,"array",void 0),Yt(this,"combine",void 0),Yt(this,"length",void 0),Yt(this,"level",void 0),this.array=[],this.combine=e,this.length=0,this.level=0,this.build(r)}var e,r;return e=t,(r=[{key:"clear",value:function(){this.length=0,this.level=0,this.array.length=0}},{key:"pop",value:function(){if(!(this.length<=this.level)){var t=this.array[--this.length];return this.length<=this.array.length+1>>>2&&this.shrink(),t}}},{key:"push",value:function(t){this.length>=this.array.length&&this.grow(),this.array[this.length++]=t;for(var e=this.length;1&e;this.array[e-1]=t)t=this.combine(this.array[e-2],t),e>>>=1;return this.size}},{key:"query",value:function(t,e){if(t>=e)throw new RangeError("Range [".concat(t,"..").concat(e,") is empty"));if(t<0||e>this.size)throw new RangeError("Range [".concat(t,"..").concat(e,") not in [0..").concat(this.size,")"));var r=_t((t+=this.level+1)|It((e+=this.level+1)-t)),n=this.array[t/r-1];for(t+=r;t=e)){if(t<0||e>this.size)throw new RangeError("Range [".concat(t,"..").concat(e,") not in [0..").concat(this.size,")"));t+=this.level,e+=this.level;for(var n=t;n>>=1){e+=e&e-r>>>31;for(var n=(1|t)>>>0;n>>1)-1]=this.combine(this.array[n-2],this.array[n-1]);t>>>=1,e>>>=1}}},{key:"build",value:function(e){var r=void 0;if(S(e))r="length";else{if(!E(e)){var n,i=Gt(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;this.push(a)}}catch(t){i.e(t)}finally{i.f()}return}r="size"}var o=e[r];if(o<1)return this.array.length=0,this.length=0,void(this.level=0);if(o>=t.MAX_SIZE)throw new RangeError("Invalid length");this.level=2*It(o-1)-1,this.length=this.level,this.array.length=2*this.level+1;var l,u=Gt(e);try{for(u.s();!(l=u.n()).done;){var s=l.value;this.array[this.length++]=s}}catch(t){u.e(t)}finally{u.f()}this.aggregate(this.level,this.length)}},{key:"grow",value:function(){if(this.size<1)this.array.length=1;else{if(this.size>=t.MAX_SIZE)throw new RangeError("Invalid length");this.array.length+=this.array.length+1;for(var e=this.level+1,r=this.length+1;e>>=1)this.array.copyWithin(2*e-1,e-1,r-1),e>>>=1;this.length+=this.level+1,this.level+=this.level+1}}},{key:"shrink",value:function(){var t=this.length-this.level;if(t<2)return this.array.copyWithin(0,this.level,this.length),this.level=0,this.length=t,void(this.array.length=t);var e=this.level+1,r=It(t);if(!((e=e/_t(e|r)-1)<2)){this.level=1;for(var n=e+1;r;this.level+=this.level+1)this.array.copyWithin(this.level,e,n),e+=e+1,n+=n+2+ +((t&(r>>>=1))>0);this.length=this.level+t,this.array.length=2*this.level+1}}}])&&Vt(e.prototype,r),t}();function te(t,e){for(var r=0;r0)){t.next=7;break}case 3:return t.next=5,e[--r];case 5:t.next=2;break;case 7:case"end":return t.stop()}}),t,this)}))}])&&te(e.prototype,r),t}();function ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}(e||[]);try{for(a.s();!(i=a.n()).done;){var o=i.value;this.push(o)}}catch(t){a.e(t)}finally{a.f()}}var e,r;return e=t,(r=[{key:"clear",value:function(){this.list.clear()}},{key:"peek",value:function(){return this.list.get(0)}},{key:"pop",value:function(){return this.list.shift()}},{key:"push",value:function(t){return this.list.unshift(t)}},{key:"size",get:function(){return this.list.size}},{key:ee,value:function(){return this.list[Symbol.iterator]()}}])&&ie(e.prototype,r),t}();function le(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ue(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ue(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function ue(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function pe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1?(t.right.balanceFactor<0&&(t.right=Se(t.right)),t=Ae(t)):t.balanceFactor<-1&&(t.left.balanceFactor>0&&(t.left=Ae(t.left)),t=Se(t)),t}function we(t){var e=t.value;if(null==e.to)return!1;for(var r=(t=Z(t)).value.label;t.next&&((e=(t=t.next).value).to.balanceFactor-="left"===r?-1:1,e.to=xe(e.to),e.from[r=e.label]=e.to,0===e.to.balanceFactor););return!0}function Ae(t){var e=t.right;return t.right=e.left,e.left=t,t.balanceFactor-=1+Math.max(0,e.balanceFactor),e.balanceFactor-=1-Math.min(0,t.balanceFactor),e}function Se(t){var e=t.left;return t.left=e.right,e.right=t,t.balanceFactor+=1-Math.min(0,e.balanceFactor),e.balanceFactor+=1+Math.max(0,t.balanceFactor),e}return e})()})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Dastal",[],e):"object"==typeof exports?exports.Dastal=e():t.Dastal=e()}(self,(function(){return(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AATree:()=>ce,AVLTree:()=>ke,ArrayList:()=>ht,ArrayQueue:()=>Wt,ArrayStack:()=>re,ArrayUtils:()=>i,BinaryHeap:()=>$,DoublyLinkedList:()=>dt,InOrderSegmentTree:()=>Nt,IteratorUtils:()=>r,LevelOrderSegmentTree:()=>Kt,LinkedList:()=>At,LinkedQueue:()=>$t,LinkedStack:()=>oe,NumberUtils:()=>n,SkewHeap:()=>lt,StringUtils:()=>a,isCollection:()=>E,u32:()=>o});var r={};t.r(r),t.d(r,{always:()=>l,fill:()=>u,first:()=>s,join:()=>h,never:()=>f,once:()=>c,skip:()=>v,split:()=>y});var n={};t.r(n),t.d(n,{clamp:()=>g,wrap:()=>b,wrapLeft:()=>p,wrapRight:()=>d});var i={};t.r(i),t.d(i,{MAX_ARRAY_LENGTH:()=>w,MAX_SAFE_ARGUMENT_LENGTH:()=>A,isArray:()=>S,isTypedArray:()=>O,splice:()=>_});var a={};t.r(a),t.d(a,{pad:()=>R});var o={};function l(t){return{next:function(){return{done:!1,value:t()}}}}function u(t,e){return{next:function(){return t<1?{done:!0,value:void 0}:(--t,{done:!1,value:e()})}}}function s(t,e){return{next:function(){if(t<1)return{done:!0,value:void 0};var r=e.next();return t=r.done?0:t-1,r}}}function h(t){var e={next:function(){return{done:!0,value:void 0}}};return{next:function(){if(null==e)return{done:!0,value:void 0};for(var r=e.next();r.done;){var n=t.next();if(n.done)return e=void 0,{done:!0,value:void 0};r=(e=n.value).next()}return r}}}function f(){return{next:function(){return{done:!0,value:void 0}}}}function c(t){var e=!1;return{next:function(){var r={done:e,value:t()};return e=!0,t=function(){},r}}}function v(t,e){var r=function(){for(var n={done:!1,value:void 0};t-- >0&&!n.done;)n=e.next();return r=e.next.bind(e),n};return{next:function(){return r()}}}function y(t,e){if(t<1)return{next:function(){return{done:!0,value:void 0}}};var r=!1;return{next:function(){if(r)return{done:r,value:void 0};var n=s(t,e),i=n.next();return i.done?{done:r=!0,value:void 0}:{done:r,value:h([c((function(){return i.value})),n][Symbol.iterator]())}}}}function g(t,e,r){return Math.min(r,Math.max(e,t))}function p(t,e,r){return tr?e+(t-r):t}function b(t,e,r){return tt.length)&&(e=t.length);for(var r=0,n=new Array(e);rSt,invert:()=>zt,isPow2:()=>jt,lsb:()=>Ot,lsp:()=>_t,lsps:()=>Rt,msb:()=>Et,msp:()=>It,msps:()=>Mt,reverse:()=>Pt,u32:()=>Tt});var w=4294967295,A=32767;function S(t){return t instanceof Array||O(t)}var z,j,O=(z=Object.getPrototypeOf(Uint8Array),function(t){return t instanceof z});function _(t,e,r,n){var i,a;if(e=g(p(null!==(i=e)&&void 0!==i?i:0,0,t.length),0,t.length),r=g(null!==(a=r)&&void 0!==a?a:t.length,0,t.length-e),null==n)return t.splice(e,r);var o=A-2,l=n[Symbol.iterator](),u=t.length-r,h=w-u,f=Math.min(o,h),c=t.splice.apply(t,[e,r].concat(k(m({},Symbol.iterator,(function(){return s(f,l)})))));for(e+=u=t.length-u,f=h-u;f>=o&&u>=o;f-=u)u=t.length,t.splice.apply(t,[e,0].concat(k(m({},Symbol.iterator,(function(){return s(o,l)}))))),e+=u=t.length-u;if(f>0&&u>=o&&t.splice.apply(t,[e,0].concat(k(m({},Symbol.iterator,(function(){return s(f,l)}))))),1!=l.next().done)throw new RangeError("Invalid array length");return c}function R(t,e,r){var n=t.length;if(n>=e)return t;var i=e-n;return t.padStart(n+i/2,r).padEnd(n+i,r)}function E(t){return null!=t&&"number"==typeof t.size&&"function"==typeof t[Symbol.iterator]}function I(t,e,r){for(var n=r[t];t>0;){var i=Math.floor((t+1)/2)-1,a=r[i];if(e(a,n)<=0)break;r[i]=n,r[t]=a,t=i}}function M(t,e){for(var r=e.length+1>>>1;r>0;P(--r,t,e));}function P(t,e,r){for(var n=r.length,i=r[t];;){var a=2*t+1;if(a>=n)break;var o=r[a];if(a+11;i=i.next){var a;e[0]=null!==(a=e[0].next)&&void 0!==a?a:e.pop(),P(0,r,e),i.next=e[0]}return n}((function(e,r){return t(r.value,e.value)}),n),s=u.value;u=u.next;){var h=u.value;h.right=h.left,h.left=s,s=h}return s}function C(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return F(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?F(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rw)throw new RangeError("Invalid heap length");for(var n=0;n=w)throw new RangeError("Invalid heap length");e.push(o)}}catch(t){a.e(t)}finally{a.f()}}return r=0}},{key:"delete",value:function(t){var e=this.array.indexOf(t);if(e<0)return!1;var r=this.array.pop();return e>=this.array.length||(this.array[e]=r,P(e,this.compare,this.array),I(e,this.compare,this.array)),!0}},{key:"merge",value:function(t){var e=this.array;if(t.size<1)return this;if(e.length+t.size>w)throw new RangeError("Invalid heap length");var r,n=C(t);try{for(n.s();!(r=n.n()).done;){var i=r.value;e.push(i)}}catch(t){n.e(t)}finally{n.f()}return M(this.compare,e),this}},{key:"peek",value:function(){return this.array.length>0?this.array[0]:void 0}},{key:"pop",value:function(){if(!(this.array.length<1)){var t=this.array[0],e=this.array.pop();return this.array.length>0&&(this.array[0]=e,P(0,this.compare,this.array)),t}}},{key:"push",value:function(t){return this.array.push(t),I(this.array.length-1,this.compare,this.array),this.size}},{key:"pushPop",value:function(t){if(this.array.length<1||this.compare(t,this.array[0])<=0)return t;var e=this.array[0];return this.array[0]=t,P(0,this.compare,this.array),e}},{key:"replace",value:function(t){if(!(this.array.length<1)){var e=this.array[0];return this.array[0]=t,t=e,P(0,this.compare,this.array),t}this.array.push(t)}},{key:"size",get:function(){return this.array.length}},{key:"sorted",value:regeneratorRuntime.mark((function e(){var r,n,i,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.array.length<1)){e.next=2;break}return e.abrupt("return");case 2:r=this.array,n=new t((function(t,e){return a.compare(r[t],r[e])}),[0]);case 4:if(!((i=n.pop())0){e.next=4;break}case 12:case"end":return e.stop()}}),e,this)}))},{key:j,value:function(){return this.array[Symbol.iterator]()}},{key:"update",value:function(t,e){var r=this.array.indexOf(t);return!(r<0||(this.array[r]=e,P(r,this.compare,this.array),I(r,this.compare,this.array),0))}}])&&W(e.prototype,r),t}(),X=regeneratorRuntime.mark(G),q=regeneratorRuntime.mark(B);function Z(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=t.value,n=r.to;if(null==n)return t;if(null==n.right)n=n.left;else if(null==n.left)n=n.right;else if(e){var i=(r=(t=tt(t)).value).to;n.value=i.value,n=i.right}else{var a=(r=(t=Q(t)).value).to;n.value=a.value,n=a.left}return r.to=n,r.from&&(r.from[r.label]=r.to=n),t}function D(t){if(null!=t){var e=Object.assign({},t),r={value:e};do{t=r.value,r=r.next,t.left&&(r={next:r,value:t.left=Object.assign({},t.left)}),t.right&&(r={next:r,value:t.right=Object.assign({},t.right)})}while(r);return e}}function H(t){if(null!=t){for(;t.left;)t=t.left;return t}}function N(t){var e=t.value.to;if(null==e)return t;for(;e.left;)t={next:t,value:{label:"left",from:e,to:e.left}},e=e.left;return t}function G(t){var e;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(e=void 0;t;)e={next:e,value:t},t=t.left;case 2:if(!e){r.next=11;break}return t=e.value,e=e.next,r.next=7,t;case 7:for(t=t.right;t;)e={next:e,value:t},t=t.left;r.next=2;break;case 11:case"end":return r.stop()}}),X)}function Q(t){var e=t.value.to;return null==e?t:Y(t={next:t,value:{label:"left",from:e,to:e.left}})}function B(t){var e;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:e={value:t};case 1:if(t=e.value,e=e.next,!t){r.next=8;break}return r.next=6,t;case 6:e={next:e={next:e,value:t.right},value:t.left};case 8:if(e){r.next=1;break}case 9:case"end":return r.stop()}}),q)}function V(t){if(null!=t){for(;t.right;)t=t.right;return t}}function Y(t){var e=t.value.to;if(null==e)return t;for(;e.right;)t={next:t,value:{label:"right",from:e,to:e.right}},e=e.right;return t}function J(t,e,r){for(;e;){var n=r(t,e.value);if(0==n)break;e=n<0?e.left:e.right}return e}function K(t,e,r){for(var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=["left","right"],a=e.value.to;a;){var o=r(t,a.value)||n;if(0===o)break;var l=i[+(o>0)];e={next:e,value:{label:l,from:a,to:a[l]}},a=a[l]}return e}function tt(t){var e=t.value.to;return null==e?t:N(t={next:t,value:{label:"right",from:e,to:e.right}})}function et(t){if(!(null==t||t.length<1||null==t[0])){var e=t.length,r=new Array(e);r[0]={value:t[0]};for(var n=1;n>>1],a={value:t[n]};r[n]=a,1&n?i.left=a:i.right=a}return r[0]}}function rt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return nt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function nt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0){e.next=3;break}case 9:case"end":return e.stop()}}),e,this)}))},{key:L,value:regeneratorRuntime.mark((function t(){var e,r,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=rt(B(this.root)),t.prev=1,e.s();case 3:if((r=e.n()).done){t.next=9;break}return n=r.value,t.next=7,n.value;case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),e.e(t.t0);case 14:return t.prev=14,e.f(),t.finish(14);case 17:case"end":return t.stop()}}),t,this,[[1,11,14,17]])}))},{key:"update",value:function(t,e){if(null==this.root)return!1;if(this.root.value===t)return this.root=T(this.compare,[this.root.left,this.root.right,{value:e}]),!0;var r,n=void 0,i=rt(B(this.root));try{for(i.s();!(r=i.n()).done;){var a=r.value;if(a.left&&a.left.value===t){n=a.left,a.left=void 0;break}if(a.right&&a.right.value===t){n=a.right,a.right=void 0;break}}}catch(t){i.e(t)}finally{i.f()}return null!=n&&(this.root=T(this.compare,[this.root,n.left,n.right,{value:e}]),!0)}}])&&it(e.prototype,r),t}();function ut(t,e){for(var r=0;r=0&&t<=this.size&&this.array.splice(t,0,e),this.size}},{key:"addAll",value:function(t,e){return t>=0&&t<=this.size&&_(this.array,t,0,e),this.size}},{key:"clear",value:function(){this.array.length=0}},{key:"concat",value:function(){for(var e=new t(this),r=arguments.length,n=new Array(r),i=0;i=this.size?void 0:this.array[t]}},{key:"getSet",value:function(t,e){var r=void 0;return t>=0&&t=this.size?void 0:this.array.splice(t,1)[0]}},{key:"reverse",value:function(t,e){var r,n;for(t=g(p(null!==(r=t)&&void 0!==r?r:0,0,this.size),0,this.size),e=g(p(null!==(n=e)&&void 0!==n?n:this.size,0,this.size),0,this.size)-1;t=0&&t=0?function(){return Math.min(r,a.size)}:function(){return a.size+r};case 2:if(!(e0);a.next=t[o],r&&(a.next.prev=a),a=a.next,t[o]=a.next,--e[o]}while(e[0]>0&&e[1]>0);return a.next=t[+(e[0]<1)],r&&a.next&&(a.next.prev=a),i.next}(a,i,r,n),r&&(t.prev=l),[t,o[+(i[0]<1)]]}function ct(t,e){if(t){if("string"==typeof t)return vt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vt(t,e):void 0}}function vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rthis.length)return this.length;var r=this._get(t-1),n={next:r.next,prev:r,value:e};return r.next=n,n.next.prev=n,++this.length}},{key:"addAll",value:function(t,e){return t>=0&&t<=this.length&&this._addAll(this._get(t),e),this.length}},{key:"clear",value:function(){this.length=0,this.root.prev=this.root.next=this.root}},{key:"concat",value:function(){for(var e=new t(this),r=arguments.length,n=new Array(r),i=0;i=(r=e+Math.min(r-e,this.length-t)))return this;if(e=this.length?void 0:this._get(t).value}},{key:"getSet",value:function(t,e){if(!(t<0||t>=this.length)){var r=this._get(t),n=r.value;return r.value=e(r.value),n}}},{key:"pop",value:function(){if(!(this.length<1)){var t=this.root.prev;return t.prev.next=this.root,this.root.prev=t.prev,--this.length,t.value}}},{key:"push",value:function(t){var e=this.root.prev,r={next:this.root,prev:e,value:t};return e.next=this.root.prev=r,++this.length}},{key:"remove",value:function(t){if(!(t<0||t>=this.length)){var e=this._get(t);return e.prev.next=e.next,e.next.prev=e.prev,--this.length,e.value}}},{key:"reverse",value:function(t,e){var r,n;if(t=g(p(null!==(r=t)&&void 0!==r?r:0,0,this.length),0,this.length),(e=g(p(null!==(n=e)&&void 0!==n?n:this.length,0,this.length),0,this.length))-t<2)return this;var i=this._get(t-1),a=i.next,o=a;do{var l=o.next;o.next=o.prev,o.prev=l,i.next=o,o=l}while(++t=this.length)){var r=this._get(t),n=r.value;return r.value=e,n}}},{key:"shift",value:function(){if(!(this.length<1)){var t=this.root.next;return t.next.prev=this.root,this.root.next=t.next,--this.length,t.value}}},{key:"size",get:function(){return this.length}},{key:"slice",value:function(e,r){return new t(this.view(e,r))}},{key:"splice",value:function(e,r,n){var i,a;e=g(p(null!==(i=e)&&void 0!==i?i:0,0,this.length),0,this.length),r=g(null!==(a=r)&&void 0!==a?a:this.size,0,this.size-e);var o=new t;if(null==n&&r<1)return o;for(var l=this._get(e);r-- >0;)o.push(l.value),l.prev.next=l.next,l.next.prev=l.prev,l=l.next,--this.length;return this._addAll(l,null!=n?n:[]),o}},{key:"sort",value:function(t){if(this.length>1){var e=(i=ft(this.root.next,this.length,!0,t),a=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a=[],o=!0,l=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);o=!0);}catch(t){l=!0,i=t}finally{try{o||null==r.return||r.return()}finally{if(l)throw i}}return a}}(i,a)||ct(i,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),r=e[0],n=e[1];this.root.next=r,n.next.prev=n}var i,a;return this}},{key:st,value:regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=this.root.next;case 1:if(e===this.root){t.next=7;break}return t.next=4,e.value;case 4:e=e.next,t.next=1;break;case 7:case"end":return t.stop()}}),t,this)}))},{key:"unshift",value:function(t){var e=this.root.next,r={next:e,prev:this.root,value:t};return this.root.next=e.prev=r,++this.length}},{key:"update",value:function(t,e,r){var n,i;if(null==r&&(arguments.length<2?(r=t,t=void 0):(r=e,e=void 0)),(t=g(p(null!==(n=t)&&void 0!==n?n:0,0,this.length),0,this.length))<(e=g(p(null!==(i=e)&&void 0!==i?i:this.length,0,this.length),0,this.length))){var a=this._get(t);do{a.value=r(a.value,t),a=a.next}while(++t=0?function(){return r}:function(){return o.length+r})())){t.next=8;break}a=this._get(e);case 4:return t.next=6,a.value;case 6:a=a.next;case 7:if(++e=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}(e);try{for(i.s();!(r=i.n()).done;){var a={prev:n,value:r.value};n.next=a,n=a,++this.length}}catch(t){i.e(t)}finally{i.f()}n.next=t,t.prev=n}},{key:"_get",value:function(t){var e=this.root;if(t=0;)e=e.next;else for(t=this.length-t;t>0;--t)e=e.prev;return e}}])&&yt(e.prototype,r),t}();function bt(t,e){if(t){if("string"==typeof t)return mt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?mt(t,e):void 0}}function mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0&&t=0&&t=(r=e+Math.min(r-e,this.length-t)))return this;if(tr){var o=this._get(e-1);return this._copyWithin(o,this._get(t-e-1,o),r-e),this}var l=this._get(e-1),u=this._get(r-e-1,l),s=this._copyWithin(l,u,t-e);t+(r-e)>=this.length&&(this.tail=u);var h=l.next;return l.next=u.next,u.next=s.next,s.next=h,this}},{key:"fill",value:function(t,e,r){var n,i;if((e=g(p(null!==(n=e)&&void 0!==n?n:0,0,this.length),0,this.length))<(r=g(p(null!==(i=r)&&void 0!==i?i:this.length,0,this.length),0,this.length))){var a=this._get(e);do{a.value=t,a=a.next}while(++e=this.length))return t=this.length)){var r=t=this.length)){var e=this._get(t-1),r=e.next;return e.next=r.next,t===--this.length&&(this.tail=e),r.value}}},{key:"reverse",value:function(t,e){var r,n;if(t=g(p(null!==(r=t)&&void 0!==r?r:0,0,this.length),0,this.length),(e=g(p(null!==(n=e)&&void 0!==n?n:this.length,0,this.length),0,this.length))-t<2)return this;var i=this._get(t-1);this.tail=e>=this.length?i.next:this.tail;for(var a=i.next,o=a,l=a.next;++t=this.length)){var r=this._get(t),n=r.value;return r.value=e,n}}},{key:"shift",value:function(){return this.remove(0)}},{key:"size",get:function(){return this.length}},{key:"slice",value:function(e,r){return new t(this.view(e,r))}},{key:"splice",value:function(e,r,n){var i,a;e=g(p(null!==(i=e)&&void 0!==i?i:0,0,this.length),0,this.length),r=g(null!==(a=r)&&void 0!==a?a:this.size,0,this.size-e);var o=new t;if(null==n&&r<1)return o;for(var l=this._get(e-1),u=e+r>=this.size;r-- >0;){var s=l.next;o.push(s.value),l.next=s.next,--this.length}return l=this._addAll(l,null!=n?n:[]),this.tail=u?l:this.tail,o}},{key:"sort",value:function(t){if(this.length>1){var e=(i=ft(this.root.next,this.length,!1,t),a=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a=[],o=!0,l=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);o=!0);}catch(t){l=!0,i=t}finally{try{o||null==r.return||r.return()}finally{if(l)throw i}}return a}}(i,a)||bt(i,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),r=e[0],n=e[1];this.root.next=r,this.tail=n}var i,a;return this}},{key:pt,value:regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=this.root.next;case 1:if(e===this.root){t.next=7;break}return t.next=4,e.value;case 4:e=e.next,t.next=1;break;case 7:case"end":return t.stop()}}),t,this)}))},{key:"unshift",value:function(t){return this.add(0,t)}},{key:"update",value:function(t,e,r){var n,i;if(null==r&&(arguments.length<2?(r=t,t=void 0):(r=e,e=void 0)),(t=g(p(null!==(n=t)&&void 0!==n?n:0,0,this.length),0,this.length))<(e=g(p(null!==(i=e)&&void 0!==i?i:this.length,0,this.length),0,this.length))){var a=this._get(t);do{a.value=r(a.value,t),a=a.next}while(++t=0?function(){return r}:function(){return o.length+r})())){t.next=8;break}a=this._get(e);case 4:return t.next=6,a.value;case 6:a=a.next;case 7:if(++e=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}(e);try{for(i.s();!(r=i.n()).done;){var a={value:r.value};t.next=a,t=a,++this.length}}catch(t){i.e(t)}finally{i.f()}return t.next=n,t}},{key:"_copyWithin",value:function(t,e,r){for(;r-- >0;)t=t.next,(e=e.next).value=t.value;return e}},{key:"_get",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.root,r=e;t-- >=0;)r=r.next;return r}}])&&kt(e.prototype,r),t}();function St(t){for(var e=0;t;)++e,t&=t-1;return e}function zt(t){var e=It(t);return Tt(t^(e|e-1))}function jt(t){return 0==(t&t-1)}function Ot(t){var e=-1;for(t=_t(t);t;t>>>=1)++e;return e}function _t(t){return Tt(t&-t)}function Rt(t){return Tt(t&_t(t+_t(t))-1)}function Et(t){for(var e=-1;0!==t;)++e,t>>>=1;return e}function It(t){for(var e=t&-t;t!=e;)e=(t^=e)&-t;return Tt(e)}function Mt(t){for(var e=t&-t;t&t+e;)e=(t^=e)&-t;return Tt(t)}function Pt(t){return Tt((t=(4278255360&(t=(4042322160&(t=(3435973836&(t=(2863311530&t)>>>1|(1431655765&t)<<1))>>>2|(858993459&t)<<2))>>>4|(252645135&t)<<4))>>>8|(16711935&t)<<8)>>>16|t<<16)}function Tt(t){return t>>>0}function Ct(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:[];qt(this,t),Dt(this,"array",void 0),Dt(this,"combine",void 0),this.array=[],this.combine=e,this.build(r)}var e,r;return e=t,(r=[{key:"clear",value:function(){this.array.length=0}},{key:"pop",value:function(){if(!(this.size<1)){for(var t=this.array.length-1,e=2;t&e;e*=2)this.array[t-e]=this.array[t-e-(e>>>1)];var r=this.array[t-1];return this.array.length-=2,r}}},{key:"push",value:function(e){if(this.size>=t.MAX_SIZE)throw new RangeError("Invalid length");var r=this.array.length;return this.array[r+1]=this.set(r,e),this.size}},{key:"query",value:function(t,e){if(t>=e)throw new RangeError("Range [".concat(t,"..").concat(e,") is empty"));if(t<0||e>this.size)throw new RangeError("Range [".concat(t,"..").concat(e,") not in [0..").concat(this.size,")"));var r=_t((t*=2)|It((e*=2)-t)),n=this.array[t-1+(r>>>1)];for(t+=r;t>>1)]);return n}},{key:"size",get:function(){return this.array.length>>>1}},{key:Lt,value:regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:if(!(e=e)){if(t<0||e>this.size)throw new RangeError("Range [".concat(t,"..").concat(e,") not in [0..").concat(this.size,")"));var n;t*=2,e*=2;do{n=this.set(t,r(this.array[t],t>>>1)),t+=2}while(t0;--e)n=this.combine(n,this.array[t+(a>>>1)-i]),this.array[t]=n,t+=a-(i=(t&2*a)>>>0),a*=2;this.array[t]=n}}},{key:"build",value:function(t){var e,r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Xt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;this.push(n)}}catch(t){r.e(t)}finally{r.f()}}},{key:"set",value:function(t,e){this.array[t++]=e;for(var r=2;t&r;r*=2)e=this.combine(this.array[t-r-(r>>>1)],e),this.array[t-r]=e;return e}}])&&Zt(e.prototype,r),t}();function Gt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Qt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function Qt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:[];Bt(this,t),Yt(this,"array",void 0),Yt(this,"combine",void 0),Yt(this,"length",void 0),Yt(this,"level",void 0),this.array=[],this.combine=e,this.length=0,this.level=0,this.build(r)}var e,r;return e=t,(r=[{key:"clear",value:function(){this.length=0,this.level=0,this.array.length=0}},{key:"pop",value:function(){if(!(this.length<=this.level)){var t=this.array[--this.length];return this.size<=this.level+1>>>2&&this.shrink(),t}}},{key:"push",value:function(t){this.length>=this.array.length&&this.grow(),this.array[this.length++]=t;for(var e=this.length;1&e;this.array[e-1]=t)t=this.combine(this.array[e-2],t),e>>>=1;return this.size}},{key:"query",value:function(t,e){if(t>=e)throw new RangeError("Range [".concat(t,"..").concat(e,") is empty"));if(t<0||e>this.size)throw new RangeError("Range [".concat(t,"..").concat(e,") not in [0..").concat(this.size,")"));var r=_t((t+=this.level+1)|It((e+=this.level+1)-t)),n=this.array[t/r-1];for(t+=r;t=e)){if(t<0||e>this.size)throw new RangeError("Range [".concat(t,"..").concat(e,") not in [0..").concat(this.size,")"));t+=this.level,e+=this.level;for(var n=t;n>>=1){e+=e&e-r>>>31;for(var n=(1|t)>>>0;n>>1)-1]=this.combine(this.array[n-2],this.array[n-1]);t>>>=1,e>>>=1}}},{key:"build",value:function(e){var r=void 0;if(S(e))r="length";else{if(!E(e)){var n,i=Gt(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;this.push(a)}}catch(t){i.e(t)}finally{i.f()}return}r="size"}var o=e[r];if(o<1)return this.array.length=0,this.length=0,void(this.level=0);if(o>=t.MAX_SIZE)throw new RangeError("Invalid length");this.level=2*It(o-1)-1,this.length=this.level,this.array.length=2*this.level+1;var l,u=Gt(e);try{for(u.s();!(l=u.n()).done;){var s=l.value;this.array[this.length++]=s}}catch(t){u.e(t)}finally{u.f()}this.aggregate(this.level,this.length)}},{key:"grow",value:function(){if(this.size<1)this.array.length=1;else{if(this.size>=t.MAX_SIZE)throw new RangeError("Invalid length");this.array.length+=this.array.length+1;for(var e=this.level+1,r=this.length+1;e>>=1)this.array.copyWithin(2*e-1,e-1,r-1),e>>>=1;this.length+=this.level+1,this.level+=this.level+1}}},{key:"shrink",value:function(){var t=this.length-this.level;if(t<2)return this.array.copyWithin(0,this.level,this.length),this.level=0,this.length=t,void(this.array.length=t);var e=this.level+1,r=It(t);if(!((e=e/_t(e|r)-1)<2)){this.level=0;for(var n=e+1;r;e+=e+1)this.level+=this.level+1,this.array.copyWithin(this.level,e,n),n+=n+2+ +((t&(r>>>=1))>0);this.length=this.level+t,this.array.length=2*this.level+1}}}])&&Vt(e.prototype,r),t}();function te(t,e){for(var r=0;r0)){t.next=7;break}case 3:return t.next=5,e[--r];case 5:t.next=2;break;case 7:case"end":return t.stop()}}),t,this)}))}])&&te(e.prototype,r),t}();function ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}(e||[]);try{for(a.s();!(i=a.n()).done;){var o=i.value;this.push(o)}}catch(t){a.e(t)}finally{a.f()}}var e,r;return e=t,(r=[{key:"clear",value:function(){this.list.clear()}},{key:"peek",value:function(){return this.list.get(0)}},{key:"pop",value:function(){return this.list.shift()}},{key:"push",value:function(t){return this.list.unshift(t)}},{key:"size",get:function(){return this.list.size}},{key:ee,value:function(){return this.list[Symbol.iterator]()}}])&&ie(e.prototype,r),t}();function le(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ue(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ue(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function ue(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw a}}}}function de(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1?(t.right.balanceFactor<0&&(t.right=Se(t.right)),t=Ae(t)):t.balanceFactor<-1&&(t.left.balanceFactor>0&&(t.left=Ae(t.left)),t=Se(t)),t}function we(t){var e=t.value;if(null==e.to)return!1;for(var r=(t=Z(t)).value.label;t.next&&((e=(t=t.next).value).to.balanceFactor-="left"===r?-1:1,e.to=xe(e.to),e.from[r=e.label]=e.to,0===e.to.balanceFactor););return!0}function Ae(t){var e=t.right;return t.right=e.left,e.left=t,t.balanceFactor-=1+Math.max(0,e.balanceFactor),e.balanceFactor-=1-Math.min(0,t.balanceFactor),e}function Se(t){var e=t.left;return t.left=e.right,e.right=t,t.balanceFactor+=1-Math.min(0,e.balanceFactor),e.balanceFactor+=1+Math.max(0,t.balanceFactor),e}return e})()})); //# sourceMappingURL=dastal.min.js.map \ No newline at end of file diff --git a/dist/dastal.min.js.map b/dist/dastal.min.js.map index bd5a80a..2cd57ca 100644 --- a/dist/dastal.min.js.map +++ b/dist/dastal.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Dastal/webpack/universalModuleDefinition","webpack://Dastal/webpack/bootstrap","webpack://Dastal/webpack/runtime/define property getters","webpack://Dastal/webpack/runtime/hasOwnProperty shorthand","webpack://Dastal/webpack/runtime/make namespace object","webpack://Dastal/./src/collection/iteratorUtils.ts","webpack://Dastal/./src/math/numberUtils.ts","webpack://Dastal/./src/collection/arrayUtils.ts","webpack://Dastal/./src/collection/stringUtils.ts","webpack://Dastal/./src/collection/index.ts","webpack://Dastal/./src/heap/utils.ts","webpack://Dastal/./src/heap/binaryHeap.ts","webpack://Dastal/./src/tree/binaryTreeUtils.ts","webpack://Dastal/./src/heap/skewHeap.ts","webpack://Dastal/./src/list/arrayList.ts","webpack://Dastal/./src/list/utils.ts","webpack://Dastal/./src/list/doublyLinkedList.ts","webpack://Dastal/./src/list/linkedList.ts","webpack://Dastal/./src/math/u32.ts","webpack://Dastal/./src/queue/arrayQueue.ts","webpack://Dastal/./src/queue/linkedQueue.ts","webpack://Dastal/./src/segmentTree/inOrderSegmentTree.ts","webpack://Dastal/./src/segmentTree/levelOrderSegmentTree.ts","webpack://Dastal/./src/stack/arrayStack.ts","webpack://Dastal/./src/stack/linkedStack.ts","webpack://Dastal/./src/tree/aaTree.ts","webpack://Dastal/./src/tree/avlTree.ts"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","always","fn","next","done","fill","length","undefined","first","n","iterator","res","join","iterators","res2","never","once","skip","bind","split","iter","clamp","num","min","max","Math","wrapLeft","wrapRight","wrap","MAX_ARRAY_LENGTH","MAX_SAFE_ARGUMENT_LENGTH","isArray","Array","isTypedArray","TypedArray","getPrototypeOf","Uint8Array","splice","array","start","count","elements","maxStepSize","stepSize","maxElems","out","RangeError","pad","str","maxLen","fillString","len","diff","padStart","padEnd","isCollection","bubbleUp","index","compareFn","parentIndex","floor","parent","heapify","i","sinkDown","childIndex","child","skewMerge","heaps","lists","push","list","tree","right","compare","a","b","tail","pop","mergeKSorted","heap","node","left","BinaryHeap","this","addAll","element","indexOf","last","size","curElement","newElement","inOrderTraverse","preOrderTraverse","removeStack","stack","dir","edge","to","temp","successorStack","predecessorStack","from","label","clone","assign","leftmost","leftmostStack","rightmostStack","rightmost","search","comp","searchStack","dupeWeight","paths","toBinaryTree","nodes","par","SkewHeap","merge","comparator","ArrayList","copyWithin","callback","prev","shift","slice","sort","unshift","arguments","linkedMergeSort","isDoubly","lens","ceil","heads","tails","linkedMergeSorted","DoublyLinkedList","_addAll","_get","nodeA","nodeB","head","view","LinkedList","_copyWithin","nodeC","nodeD","remove","deleted","newTail","add","bitsSet","invert","msp","u32","isPow2","lsb","lsp","lsps","msb","msps","reverse","ArrayQueue","LinkedQueue","clear","InOrderSegmentTree","combine","build","mask","MAX_SIZE","set","offset","operation","dc","dp","LevelOrderSegmentTree","level","shrink","grow","aggregate","cap","ArrayStack","LinkedStack","AATree","allowDuplicates","sentinel","skew","removed","delete","AVLTree","balanceFactor","balance","rotateR","rotateL","P","R","L"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,SAAU,GAAIH,GACK,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,M,mBCTA,IAAIC,EAAsB,CCA1B,EAAwB,CAACL,E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,eAAiB,EAAItK,KAAKD,IAAI,EAAG4K,EAAEL,eACrCK,EAAEL,eAAiB,EAAItK,KAAKF,IAAI,EAAG4K,EAAEJ,eAC9BK,EAKJ,SAASH,GAAWE,GACvB,IAAME,EAAIF,EAAEjH,KAKZ,OAJAiH,EAAEjH,KAAOmH,EAAE5H,MACX4H,EAAE5H,MAAQ0H,EACVA,EAAEJ,eAAiB,EAAItK,KAAKF,IAAI,EAAG8K,EAAEN,eACrCM,EAAEN,eAAiB,EAAItK,KAAKD,IAAI,EAAG2K,EAAEJ,eAC9BM,E","file":"dastal.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Dastal\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Dastal\"] = factory();\n\telse\n\t\troot[\"Dastal\"] = factory();\n})(self, function() {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Get an iterator that always returns a given value.\n */\nexport function always(fn: () => T): Iterator {\n return { next: () => ({ done: false, value: fn() }) };\n}\n/**\n * Get an iterator that returns a value a given amount of times.\n */\nexport function fill(length: number, fn: () => T): Iterator {\n return {\n next: () => {\n if (length < 1) {\n return { done: true, value: undefined };\n }\n --length;\n return { done: false, value: fn() };\n },\n };\n}\n/**\n * Iterate through the first num elements of an iterator.\n *\n * @param n - The number of elements to iterate.\n * @param iterator - The iterator.\n *\n * @returns - An iterator limited to the next n elements.\n */\nexport function first(n: number, iterator: Iterator): Iterator {\n return {\n next: () => {\n if (n < 1) {\n return { done: true, value: undefined };\n }\n const res = iterator.next();\n n = res.done ? 0 : n - 1;\n return res;\n },\n };\n}\n/**\n * Join multiple iterators into one.\n *\n * @param iterators - The iterators to join.\n */\nexport function join(iterators: Iterator>): Iterator {\n let iterator: Iterator | undefined = { next: () => ({ done: true, value: undefined }) };\n return {\n next: () => {\n if (iterator == null) {\n return { done: true, value: undefined };\n }\n let res = iterator.next();\n while (res.done) {\n const res2 = iterators.next();\n if (res2.done) {\n iterator = undefined;\n return { done: true, value: undefined };\n }\n iterator = res2.value;\n res = iterator.next();\n }\n return res;\n },\n };\n}\n/**\n * Get an empty iterator.\n */\nexport function never(): Iterator {\n return { next: () => ({ done: true, value: undefined }) };\n}\n/**\n * Wrap a value in an iterator.\n */\nexport function once(fn: () => T): Iterator {\n let done = false;\n return {\n next: () => {\n const res = { done, value: fn() };\n done = true;\n fn = () => undefined!;\n return res;\n },\n };\n}\n/**\n * Skip the next num elements of an iterator.\n *\n * @param n - The number of elements to skip.\n * @param iterator - The iterator.\n *\n * @returns - The iterator after skipping n elements.\n */\nexport function skip(n: number, iterator: Iterator): Iterator {\n let fn = () => {\n let res: IteratorResult = { done: false, value: undefined! };\n while (n-- > 0 && !res.done) {\n res = iterator.next();\n }\n fn = iterator.next.bind(iterator);\n return res;\n };\n return { next: () => fn() };\n}\n/**\n * Split an iterator into multiple iterators of a given length.\n *\n * @param length - The length of each iterator.\n * @param iterator - The iterator to split.\n *\n * @returns - An iterator of the resulting iterators.\n */\nexport function split(length: number, iterator: Iterator): Iterator> {\n if (length < 1) {\n return { next: () => ({ done: true, value: undefined }) };\n }\n let done = false;\n return {\n next: () => {\n if (done) {\n return { done, value: undefined };\n }\n const iter = first(length, iterator);\n const res = iter.next();\n if (res.done) {\n done = true;\n return { done, value: undefined };\n }\n return { done, value: join([once(() => res.value), iter][Symbol.iterator]()) };\n },\n };\n}\n","/**\n * Limits a number to be within a given range.\n *\n * f(x, min, max) = y, where min <= y <= max\n *\n * @param num - The number to clamp\n * @param min - The minimum result value, inclusive\n * @param max - The maximum result value, inclusive\n *\n * @returns The clamped number\n */\nexport function clamp(num: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, num));\n}\n/**\n * Wraps a number if below a given range\n *\n * f(x, min, max) = {\n * x, where x >= min\n * max - (min - x), where x < min\n * }\n *\n * @param num - The number to wrap\n * @param min - The minimum result value, inclusive\n * @param max - The maximum result value, inclusive\n *\n * @returns - The wrapped number\n */\nexport function wrapLeft(num: number, min: number, max: number): number {\n return num < min ? max - min + num : num;\n}\n/**\n * Wraps a number if above a given range\n *\n * f(x, min, max) = {\n * x, where x <= max\n * min + (x - max), where x > max\n * }\n *\n * @param num - The number to wrap\n * @param min - The minimum result value, inclusive\n * @param max - The maximum result value, inclusive\n *\n * @returns - The wrapped number\n */\nexport function wrapRight(num: number, min: number, max: number): number {\n return num > max ? min + (num - max) : num;\n}\n/**\n * Wraps a number if outside a given range\n *\n * @param num - The number to wrap\n * @param min - The minimum result value, inclusive\n * @param max - The maximum result value, inclusive\n *\n * @returns - The wrapped number\n */\nexport function wrap(num: number, min: number, max: number): number {\n return num < min ? max - min + num : wrapRight(num, min, max);\n}\n","import { first } from 'src/collection/iteratorUtils';\nimport { clamp, wrapLeft } from 'src/math/numberUtils';\n\n/**\n * The maximum length of an array.\n *\n * According to the [ECMA-262](https://tc39.es/ecma262/#array-index):\n * 0 <= array.length <= 2^32 - 1\n *\n * If this value should be updated, please\n * submit a pull request with details supporting a new max length.\n */\nexport const MAX_ARRAY_LENGTH = 4294967295;\n/**\n * The maximum number of arguments that can be safely accepted by a function.\n *\n * According to the [ECMA-262](https://tc39.es/ecma262/#sec-list-and-record-specification-type), there is no maximum. In practice, different\n * environments impose their own limit ([source](https://stackoverflow.com/questions/22747068/is-there-a-max-number-of-arguments-javascript-functions-can-accept)).\n *\n * This value was chosen through research, local testing and iteration. The actual number of arguments\n * accepted in an environment may be larger but hopefully not smaller. If errors are raised,\n * please submit a bug with your environment details and a new max length.\n */\nexport const MAX_SAFE_ARGUMENT_LENGTH = 32767;\n/**\n * Check if a value is an Array or TypedArray.\n *\n * @param obj - The value to check.\n *\n * @returns `true` if an Array or TypedArray, otherwise `false`.\n */\nexport function isArray(obj: unknown): obj is T[] {\n return obj instanceof Array || isTypedArray(obj);\n}\n/**\n * Check if a value is a TypedArray.\n *\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)\n * for more details.\n *\n * @param obj - The value to check.\n *\n * @returns `true` if a TypedArray, otherwise `false`.\n */\nexport const isTypedArray = (() => {\n const TypedArray = Object.getPrototypeOf(Uint8Array);\n return function isTypedArray(obj: unknown): obj is T[] {\n return obj instanceof TypedArray;\n };\n})();\n/**\n * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.\n *\n * Contrary to Array.splice, this will not throw an error if too many new elements are given as arguments.\n *\n * @param array - The array to splice.\n * @param start - The zero-based location in the array from which to start removing elements.\n * @param count - The number of elements to remove.\n * @param elements - The new elements to splice in.\n *\n * @returns - An array containing the elements that were deleted.\n */\nexport function splice(array: T[], start?: number, count?: number, elements?: Iterable): T[] {\n start = clamp(wrapLeft(start ?? 0, 0, array.length), 0, array.length);\n count = clamp(count ?? array.length, 0, array.length - start);\n\n // Base case\n if (elements == null) {\n return array.splice(start, count);\n }\n\n const maxStepSize = MAX_SAFE_ARGUMENT_LENGTH - 2;\n const iterator = elements[Symbol.iterator]();\n\n // Perform the initial splice\n let stepSize = array.length - count;\n const maxElems = MAX_ARRAY_LENGTH - stepSize;\n let n = Math.min(maxStepSize, maxElems);\n const out = array.splice(start, count, ...{ [Symbol.iterator]: () => first(n, iterator) });\n stepSize = array.length - stepSize;\n start += stepSize;\n\n // Splice in new elements as long as there is space in the array\n for (n = maxElems - stepSize; n >= maxStepSize && stepSize >= maxStepSize; n -= stepSize) {\n stepSize = array.length;\n array.splice(start, 0, ...{ [Symbol.iterator]: () => first(maxStepSize, iterator) });\n stepSize = array.length - stepSize;\n start += stepSize;\n }\n if (n > 0 && stepSize >= maxStepSize) {\n array.splice(start, 0, ...{ [Symbol.iterator]: () => first(n, iterator) });\n }\n\n // If maximum array capacity reached\n if (iterator.next().done != true) {\n throw new RangeError('Invalid array length');\n }\n\n return out;\n}\n","/**\n * Pad a string from both sides.\n */\nexport function pad(str: string, maxLen: number, fillString: string): string {\n const len = str.length;\n if (len >= maxLen) {\n return str;\n }\n const diff = maxLen - len;\n return str.padStart(len + diff / 2, fillString).padEnd(len + diff, fillString);\n}\n","import { Collection } from './collection';\n\nexport * as ArrayUtils from './arrayUtils';\nexport * from './collection';\nexport * as IteratorUtils from './iteratorUtils';\nexport * as StringUtils from './stringUtils';\n\n/**\n * Check if a value is a {@link Collection}.\n *\n * @param obj - The value to check.\n *\n * @returns - `true` if obj is a Collection, `false` otherwise.\n */\nexport function isCollection(obj: any): obj is Collection {\n return (\n obj != null && typeof obj['size'] === 'number' && typeof obj[Symbol.iterator] === 'function'\n );\n}\n","import { LinkedNode } from 'src/list';\nimport { BinaryTreeNode } from 'src/tree/binaryTreeNode';\nimport { CompareFn } from '..';\n\n/**\n * @internal\n */\nexport function bubbleUp(index: number, compareFn: CompareFn, array: Array): void {\n const value = array[index];\n\n // Until we reach the top of the heap\n while (index > 0) {\n // Get the parent\n const parentIndex = Math.floor((index + 1) / 2) - 1;\n const parent = array[parentIndex]!;\n\n // If the parent is above or equal to value, the heap is in order\n if (compareFn(parent, value) <= 0) {\n break;\n }\n\n // Swap the parent with value and continue\n array[parentIndex] = value;\n array[index] = parent;\n index = parentIndex;\n }\n}\n/**\n * @internal\n */\nexport function heapify(compareFn: CompareFn, array: T[]): void {\n for (let i = (array.length + 1) >>> 1; i > 0; sinkDown(--i, compareFn, array)) {}\n}\n/**\n * @internal\n */\nexport function mergeKSorted(compareFn: CompareFn, lists: LinkedNode[]): LinkedNode {\n // Heapify the list of lists based on\n // the value at the head of each list.\n const compare: CompareFn> = (a, b) => compareFn(a.value, b.value);\n heapify(compare, lists);\n\n // Combine the lists into a single list.\n const list: LinkedNode = lists[0];\n for (let tail = list; lists.length > 1; tail = tail.next) {\n lists[0] = lists[0].next ?? lists.pop()!;\n sinkDown(0, compare, lists);\n tail.next = lists[0];\n }\n\n return list;\n}\n/**\n * @internal\n */\nexport function sinkDown(index: number, compareFn: CompareFn, array: Array): void {\n const n = array.length;\n const value = array[index];\n do {\n // Compute the left child's index\n let childIndex = 2 * index + 1;\n\n // If no children exist\n if (childIndex >= n) {\n break;\n }\n\n // Decide which child to compare with\n let child = array[childIndex];\n if (childIndex + 1 < n && compareFn(array[childIndex + 1], child) <= 0) {\n child = array[++childIndex]!;\n }\n\n // If value <= child\n if (compareFn(value, child) <= 0) {\n break;\n }\n\n // Swap value and child\n array[index] = child;\n array[childIndex] = value;\n index = childIndex;\n } while (true);\n}\n/**\n * See: https://en.wikipedia.org/wiki/Skew_heap#Merging_two_heaps\n *\n * @param compareFn - A function used to determine the order of the heap.\n *\n * It is expected to return:\n * - A negative value if first argument < second argument\n * - Zero if first argument == second argument\n * - A positive value if first argument > second argument\n * @param heaps - An iterable of heaps to merge\n *\n * @returns The new heap\n */\nexport function skewMerge(\n compareFn: CompareFn,\n heaps: (BinaryTreeNode | undefined)[],\n): BinaryTreeNode | undefined {\n // Remove undefineds and initialize a list for each heap\n const lists: LinkedNode>[] = [];\n for (let i = 0; i < heaps.length; ++i) {\n if (heaps[i] != null) {\n lists.push({ value: heaps[i]! });\n }\n }\n\n // Check if nothing to merge with\n if (lists.length < 2) {\n return lists[0]?.value;\n }\n\n // Split each heap into subheaps by cutting every right path; From the root\n // node, sever the right node to make the right child its own heap. Repeat\n // until you can't go right. This will turn each heap into a list of heaps\n // where the root either only has a left child or no children at all. The\n // lists of heaps will be in desc order (from bottom to top).\n for (let i = 0; i < lists.length; ++i) {\n let list = lists[i];\n let tree: BinaryTreeNode | undefined = list.value;\n while ((tree = tree.right)) {\n list = { next: list, value: tree };\n }\n lists[i] = list;\n }\n\n // Combine the lists into a single list in desc order\n let list: LinkedNode> | undefined = mergeKSorted(\n (a, b) => compareFn(b.value, a.value),\n lists,\n );\n\n // While there are still multiple heaps, iteratively combine\n // the first two (from left to right). If the root of the second-to-first\n // subtree has a left child, swap it to be the right child. Link the root\n // of the last subtree as the left child of the second-to-first subtree.\n let heap = list.value;\n while ((list = list.next)) {\n const node = list.value;\n node.right = node.left;\n node.left = heap;\n heap = node;\n }\n\n return heap;\n}\n","import { isArray, MAX_ARRAY_LENGTH } from 'src/collection/arrayUtils';\nimport { CompareFn } from '..';\nimport { Heap } from './heap';\nimport { bubbleUp, heapify, sinkDown } from './utils';\n\n/**\n * A binary heap is a heap implemented as a binary tree with an additional shape property\n * ([source](https://en.wikipedia.org/wiki/Binary_heap)).\n *\n * **Shape property**: Must be a complete binary tree. This means all levels of the tree\n * (except possibly the last one) are fully filled. If the last level of the tree is incomplete,\n * the nodes of that level are filled from left to right.\n *\n * #### Complexity\n *\n * | Property | Average | Worst |\n * | :------- | :------ | :---- |\n * | Space | O(n) | O(n)\n * | Push | O(1) | O(log n)\n * | Peek | O(1)\t| O(1)\n * | Pop | O(log n)| O(log n)\n * | Search | O(n) | O(n)\n */\nexport class BinaryHeap implements Heap {\n /**\n * The array containing every element.\n */\n protected array: T[];\n /**\n * The function to determine the order of elements.\n */\n protected compare: CompareFn;\n /**\n * Instantiate a heap.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param elements - A set of elements to initialize the list with.\n */\n constructor(compareFn: CompareFn, elements?: Iterable) {\n this.compare = compareFn;\n this.array = [];\n this.addAll(elements ?? []);\n }\n\n addAll(elements: Iterable): number {\n const array = this.array;\n const length = array.length;\n\n if (isArray(elements)) {\n if (array.length + elements.length > MAX_ARRAY_LENGTH) {\n throw new RangeError('Invalid heap length');\n }\n for (let i = 0; i < elements.length; ++i) {\n array.push(elements[i]);\n }\n } else {\n for (const element of elements) {\n if (array.length >= MAX_ARRAY_LENGTH) {\n throw new RangeError('Invalid heap length');\n }\n array.push(element);\n }\n }\n\n // Update the heap\n if (length < array.length) {\n heapify(this.compare, array);\n }\n\n return array.length;\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n comparator(): CompareFn {\n return this.compare;\n }\n\n contains(element: T): boolean {\n return this.array.indexOf(element) >= 0;\n }\n\n delete(element: T): boolean {\n const index = this.array.indexOf(element);\n if (index < 0) {\n return false;\n }\n\n // If deleting the last value\n const last = this.array.pop()!;\n if (index >= this.array.length) {\n return true;\n }\n\n // Add the last value to the\n // deleted index and update the heap\n this.array[index] = last;\n sinkDown(index, this.compare, this.array);\n bubbleUp(index, this.compare, this.array);\n return true;\n }\n\n merge(heap: Heap): this {\n const array = this.array;\n\n if (heap.size < 1) {\n return this;\n }\n\n if (array.length + heap.size > MAX_ARRAY_LENGTH) {\n throw new RangeError('Invalid heap length');\n }\n\n for (const element of heap) {\n array.push(element);\n }\n\n heapify(this.compare, array);\n return this;\n }\n\n peek(): T | undefined {\n return this.array.length > 0 ? this.array[0] : undefined;\n }\n\n pop(): T | undefined {\n if (this.array.length < 1) {\n return undefined;\n }\n\n // Get the root and the last value\n const value = this.array[0];\n const last = this.array.pop();\n\n // If value != last\n if (this.array.length > 0) {\n // Move the last value to the root and update the heap\n this.array[0] = last!;\n sinkDown(0, this.compare, this.array);\n }\n\n return value;\n }\n\n push(value: T): number {\n // Add new value to the end of the heap\n this.array.push(value);\n\n // Update the heap\n bubbleUp(this.array.length - 1, this.compare, this.array);\n return this.size;\n }\n\n pushPop(value: T): T {\n // If empty or value is <= to root\n if (this.array.length < 1 || this.compare(value, this.array[0]) <= 0) {\n return value;\n }\n\n // Swap the root and value\n const root = this.array[0];\n this.array[0] = value;\n sinkDown(0, this.compare, this.array);\n return root;\n }\n\n replace(value: T): T | undefined {\n // If empty\n if (this.array.length < 1) {\n this.array.push(value);\n return undefined;\n }\n\n // Swap the root with value\n const root = this.array[0];\n this.array[0] = value;\n value = root;\n\n // Update the heap\n sinkDown(0, this.compare, this.array);\n return value;\n }\n\n get size(): number {\n return this.array.length;\n }\n\n *sorted(): Iterable {\n if (this.array.length < 1) {\n return;\n }\n const array = this.array;\n const heap = new BinaryHeap((a, b) => this.compare(array[a], array[b]), [0]);\n do {\n let index = heap.pop()!;\n if (index < array.length) {\n yield array[index];\n index = 2 * index + 1;\n index < array.length && heap.push(index);\n ++index < array.length && heap.push(index);\n }\n } while (heap.size > 0);\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n [Symbol.iterator](): Iterator {\n return this.array[Symbol.iterator]();\n }\n\n update(curElement: T, newElement: T): boolean {\n const index = this.array.indexOf(curElement);\n if (index < 0) {\n return false;\n }\n this.array[index] = newElement;\n sinkDown(index, this.compare, this.array);\n bubbleUp(index, this.compare, this.array);\n return true;\n }\n}\n","import { pad } from 'src/collection/stringUtils';\nimport { LinkedNode } from 'src/list';\nimport { CompareFn } from '..';\nimport { BinaryTreeNode } from './binaryTreeNode';\n\n/**\n * @internal\n */\nexport interface Edge> {\n label?: 'left' | 'right';\n from?: Node;\n to?: Node;\n}\n/**\n * [source](https://stackoverflow.com/questions/51419176/how-to-get-a-subset-of-keyof-t-whose-value-tk-are-callable-functions-in-typ)\n * \n * @internal\n *\nexport type KeyOfType = {[K in keyof T]: T[K] extends U ? K: never}[keyof T];\n*/\n/**\n * @internal\n */\nexport function debug, T = any>(\n root: N | undefined,\n mapFn?: (node: N) => any,\n): void {\n mapFn = mapFn == null ? (n) => n.value : mapFn;\n\n // Turn the tree into an array in level-order\n const array: string[] = [];\n for (const node of levelOrderTraverse(root, true)) {\n array.push(node ? `${mapFn(node)}` : '?');\n }\n\n // If empty\n if (array.length < 1) {\n console.log('\\n');\n return;\n }\n\n // Find the longest value string\n const lenV = array.reduce((p, c) => Math.max(p, c.length), 0);\n\n // Pad each value\n for (let i = 0; i < array.length; ++i) {\n array[i] = pad(array[i], lenV, ' ');\n }\n\n // Split values into levels\n const levels = [];\n for (let n = 1; array.length > 0; n *= 2) {\n levels.push(array.splice(0, n));\n }\n\n // Initialize formatting variables\n let branch = '_'.repeat(1 + lenV / 2);\n let offset = '';\n const offsetOffset = ' '.repeat(branch.length);\n let separator = ' '.repeat(1 + ((lenV - 1) & 1));\n const separatorOffset = ' '.repeat(lenV);\n\n // Build the last level\n array.length = levels.length;\n array[array.length - 1] = levels.pop()!.join(separator);\n\n // Build remaining levels in reverse\n for (let n = levels.length - 1; n >= 0; --n) {\n const level = levels.pop()!;\n for (let j = 0; j < level.length; ++j) {\n level[j] = branch + level[j] + branch;\n }\n array[n] = offset + level.join(separator);\n branch += branch;\n offset += offset + offsetOffset;\n separator += separator + separatorOffset;\n }\n\n // Output\n console.log(array.join('\\n'), '\\n');\n}\n/**\n * @internal\n */\nexport function removeStack>(\n stack: LinkedNode>,\n dir = true,\n): LinkedNode> {\n let edge = stack.value;\n let node = edge.to;\n\n // Input check\n if (node == null) {\n return stack;\n }\n\n // Find the replacement\n if (node.right == null) {\n // If no right child, replace with left\n node = node.left;\n } else if (node.left == null) {\n // If no left child, replace with right\n node = node.right;\n } else if (dir) {\n // Replace with the successor\n stack = successorStack(stack);\n edge = stack.value;\n const temp = edge.to!;\n node.value = temp.value;\n node = temp.right;\n } else {\n // Replace with the predecessor\n stack = predecessorStack(stack);\n edge = stack.value;\n const temp = edge.to!;\n node.value = temp.value;\n node = temp.left;\n }\n\n // Make the replacement / update the tree\n edge.to = node;\n if (edge.from) {\n edge.from[edge.label!] = edge.to = node;\n }\n\n return stack;\n}\n/**\n * @internal\n */\nexport function clone>(node: undefined): undefined;\nexport function clone>(node: Node): Node;\nexport function clone>(node: Node | undefined): Node | undefined;\nexport function clone>(node: Node | undefined): Node | undefined {\n if (node == null) {\n return undefined;\n }\n const out: Node = Object.assign({}, node);\n let stack: LinkedNode | undefined = { value: out };\n do {\n node = stack.value;\n stack = stack.next;\n if (node.left) {\n stack = { next: stack, value: (node.left = Object.assign({}, node.left)) };\n }\n if (node.right) {\n stack = { next: stack, value: (node.right = Object.assign({}, node.right)) };\n }\n } while (stack);\n return out;\n}\n/**\n * @internal\n */\nexport function leftmost>(node: undefined): undefined;\nexport function leftmost>(node: Node): Node;\nexport function leftmost>(\n node: Node | undefined,\n): Node | undefined;\nexport function leftmost>(\n node: Node | undefined,\n): Node | undefined {\n if (node == null) {\n return undefined;\n }\n while (node.left) {\n node = node.left;\n }\n return node;\n}\n/**\n * @internal\n */\nexport function leftmostStack>(\n stack: LinkedNode>,\n): LinkedNode> {\n let node = stack.value.to;\n if (node == null) {\n return stack;\n }\n while (node.left) {\n stack = { next: stack, value: { label: 'left', from: node, to: node.left } };\n node = node.left;\n }\n return stack;\n}\n/**\n * @internal\n */\nexport function* inOrderTraverse>(\n node: Node | undefined,\n): Generator {\n let stack: LinkedNode | undefined = undefined;\n\n while (node) {\n stack = { next: stack, value: node };\n node = node.left;\n }\n\n while (stack) {\n node = stack.value;\n stack = stack.next;\n yield node;\n node = node.right;\n while (node) {\n stack = { next: stack, value: node };\n node = node.left;\n }\n }\n}\n/**\n * @internal\n */\nexport function levelOrderTraverse>(\n node: Node | undefined,\n padded?: false,\n): Generator;\nexport function levelOrderTraverse>(\n node: Node | undefined,\n padded: true,\n): Generator;\nexport function* levelOrderTraverse>(\n node: Node | undefined,\n padded = false,\n): Generator {\n const nil = {} as LinkedNode;\n let head: LinkedNode = { value: node };\n let tail = head;\n for (let cont = node != null; cont; head = head.next!) {\n tail = tail.next = nil;\n for (cont = false; head !== nil; head = head.next!) {\n node = head.value;\n if (node) {\n yield node;\n cont ||= node.left != null || node.right != null;\n tail = tail.next = { value: node.left };\n tail = tail.next = { value: node.right };\n } else if (padded) {\n yield undefined;\n tail = tail.next = { value: undefined };\n tail = tail.next = { value: undefined };\n }\n }\n }\n}\n/**\n * @internal\n */\nexport function* postOrderTraverse>(\n node: Node | undefined,\n): Generator {\n interface Meta {\n seen: boolean;\n node?: Node;\n }\n let stack: LinkedNode | undefined = { value: { seen: false, node } };\n do {\n const meta = stack.value;\n stack = stack.next;\n if (meta.node) {\n if (meta.seen) {\n yield meta.node;\n } else {\n meta.seen = true;\n stack = { next: stack, value: meta };\n stack = { next: stack, value: { seen: false, node: meta.node.right } };\n stack = { next: stack, value: { seen: false, node: meta.node.left } };\n }\n }\n } while (stack);\n}\n/**\n * @internal\n */\nexport function predecessor>(\n node: Node | undefined,\n): Node | undefined {\n return node == null ? undefined : rightmost(node.left);\n}\n/**\n * @internal\n */\nexport function predecessorStack>(\n stack: LinkedNode>,\n): LinkedNode> {\n const node = stack.value.to;\n if (node == null) {\n return stack;\n }\n stack = { next: stack, value: { label: 'left', from: node, to: node.left } };\n return rightmostStack(stack);\n}\n/**\n * @internal\n */\nexport function* preOrderTraverse>(\n node: Node | undefined,\n): Generator {\n let stack: LinkedNode | undefined = { value: node };\n do {\n node = stack.value;\n stack = stack.next;\n if (node) {\n yield node;\n stack = { next: stack, value: node.right };\n stack = { next: stack, value: node.left };\n }\n } while (stack);\n}\n/**\n * @internal\n */\nexport function reverse>(root?: Node): void {\n if (root == null) {\n return;\n }\n for (const node of preOrderTraverse(root)) {\n const left = node.left;\n node.left = node.right;\n node.right = left;\n }\n}\n/**\n * @internal\n */\nexport function rightmost>(node: undefined): undefined;\nexport function rightmost>(node: Node): Node;\nexport function rightmost>(\n node: Node | undefined,\n): Node | undefined;\nexport function rightmost>(\n node: Node | undefined,\n): Node | undefined {\n if (node == null) {\n return undefined;\n }\n while (node.right) {\n node = node.right;\n }\n return node;\n}\n/**\n * @internal\n */\nexport function rightmostStack>(\n stack: LinkedNode>,\n): LinkedNode> {\n let node = stack.value.to;\n if (node == null) {\n return stack;\n }\n while (node.right) {\n stack = { next: stack, value: { label: 'right', from: node, to: node.right } };\n node = node.right;\n }\n return stack;\n}\n/**\n * Assumes sorted by compareFn\n * @internal\n */\nexport function search>(\n element: T,\n node: Node | undefined,\n compareFn: CompareFn,\n): Node | undefined {\n while (node) {\n const comp: number = compareFn(element, node.value);\n if (comp == 0) {\n break;\n }\n node = comp < 0 ? node.left : node.right;\n }\n return node;\n}\n/**\n * Assumes sorted by compareFn\n * @internal\n */\nexport function searchStack>(\n element: T,\n stack: LinkedNode>,\n compareFn: CompareFn,\n dupeWeight = 0,\n): LinkedNode> {\n const paths: ['left', 'right'] = ['left', 'right'];\n let node = stack.value.to;\n while (node) {\n const comp: number = compareFn(element, node.value) || dupeWeight;\n if (comp === 0) {\n break;\n }\n const label = paths[+(comp > 0)];\n stack = { next: stack, value: { label, from: node, to: node[label] } };\n node = node[label]!;\n }\n return stack;\n}\n/**\n * @internal\n */\nexport function successor>(\n node: Node | undefined,\n): Node | undefined {\n return node == null ? undefined : leftmost(node.right);\n}\n/**\n * @internal\n */\nexport function successorStack>(\n stack: LinkedNode>,\n): LinkedNode> {\n const node = stack.value.to;\n if (node == null) {\n return stack;\n }\n stack = { next: stack, value: { label: 'right', from: node, to: node.right } };\n return leftmostStack(stack);\n}\n/**\n * Turn an array into a binary tree. Assumes elements are in level-order.\n *\n * @internal\n */\nexport function toBinaryTree(\n elements: (T | undefined)[] | undefined,\n): BinaryTreeNode | undefined {\n if (elements == null || elements.length < 1 || elements[0] == null) {\n return undefined;\n }\n const n = elements.length;\n const nodes: BinaryTreeNode[] = new Array(n);\n nodes[0] = { value: elements[0] };\n for (let i = 1; i < n; ++i) {\n if (elements[i] == null) {\n continue;\n }\n const par = nodes[(i - 1) >>> 1];\n const node = { value: elements[i]! };\n nodes[i] = node;\n if (i & 1) {\n par.left = node;\n } else {\n par.right = node;\n }\n }\n return nodes[0];\n}\n","import { isArray } from 'src/collection/arrayUtils';\nimport { BinaryTreeNode } from 'src/tree/binaryTreeNode';\nimport { clone, preOrderTraverse, toBinaryTree } from 'src/tree/binaryTreeUtils';\nimport { CompareFn } from '..';\nimport { BinaryHeap } from './binaryHeap';\nimport { Heap } from './heap';\nimport { skewMerge } from './utils';\n\n/**\n * A skew heap is a heap implemented as a binary tree\n * ([source](https://en.wikipedia.org/wiki/Skew_heap)).\n *\n * A skew heap is a self-adjusting heap which attempts to maintain balance\n * by unconditionally swapping all nodes in the merge path when merging two heaps. Every\n * operation that modifies the heap (e.g. push, pop, merge) is considered a merge and is done\n * by using a skew heap merge.\n *\n * Skew heaps can merge more quickly than binary heaps. This can seem contradictory, since\n * skew heaps have no structural constraints and no guarantee that the height of the tree is\n * logarithmic (i.e. balanced). However, amortized complexity analysis can demonstrate that\n * all operations on a skew heap can be done in O(log(n). More specifically, the\n * amortized complexity is known to be logφ(n) where φ is the golden ratio. This is\n * approximately 1.44*log2(n).\n *\n * #### Complexity\n *\n * | Property | Average | Worst |\n * | :------- | :------ | :---- |\n * | Space | O(n) | O(n)\n * | Push | O(log n) | O(log n)\n * | Peek | O(1)\t | O(1)\n * | Pop | O(log n) | O(log n)\n * | Search | O(n) | O(n)\n */\nexport class SkewHeap implements Heap {\n /**\n * The function to determine the order of elements.\n */\n protected compare: CompareFn;\n /**\n * The number of elements in the list.\n */\n protected length: number;\n /**\n * The node at the \"top\" of the heap.\n */\n protected root: BinaryTreeNode | undefined;\n /**\n * Instantiate a heap.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param elements - A set of elements to initialize the heap with.\n */\n constructor(compareFn: CompareFn, elements?: Iterable) {\n this.compare = compareFn;\n this.length = 0;\n this.addAll(elements ?? []);\n }\n\n addAll(elements: Iterable): number {\n if (isArray(elements)) {\n for (let i = 0; i < elements.length; ++i) {\n this.push(elements[i]);\n }\n } else if (elements instanceof SkewHeap || elements instanceof BinaryHeap) {\n this.merge(elements);\n } else {\n for (const element of elements) {\n this.push(element);\n }\n }\n return this.length;\n }\n\n clear(): void {\n this.length = 0;\n this.root = undefined;\n }\n\n comparator(): CompareFn {\n return this.compare;\n }\n\n contains(element: T): boolean {\n for (const node of preOrderTraverse(this.root)) {\n if (element === node.value) {\n return true;\n }\n }\n return false;\n }\n\n delete(element: T): boolean {\n if (this.root == null) {\n return false;\n }\n if (this.root.value === element) {\n this.pop()!;\n return true;\n }\n for (const par of preOrderTraverse(this.root)) {\n const key: keyof BinaryTreeNode | undefined =\n par.left && par.left.value === element\n ? 'left'\n : par.right && par.right.value === element\n ? 'right'\n : undefined;\n if (key != null) {\n const node = par[key]!;\n par[key] = skewMerge(this.compare, [node.left, node.right]);\n --this.length;\n return true;\n }\n }\n return false;\n }\n\n merge(heap: Heap): this {\n if (this.compare !== heap.comparator()) {\n this.addAll(heap);\n } else if (heap instanceof SkewHeap) {\n this.root = skewMerge(this.compare, [this.root, clone(heap.root)]);\n this.length += heap.size;\n } else if (heap instanceof BinaryHeap) {\n this.root = skewMerge(this.compare, [this.root, toBinaryTree(heap['array'])!]);\n this.length += heap.size;\n } else {\n this.addAll(heap);\n }\n return this;\n }\n\n peek(): T | undefined {\n return this.root?.value;\n }\n\n pop(): T | undefined {\n if (this.root == null) {\n return undefined;\n }\n const value = this.root.value;\n this.root = skewMerge(this.compare, [this.root.left, this.root.right]);\n --this.length;\n return value;\n }\n\n push(value: T): number {\n this.root = skewMerge(this.compare, [this.root, { value }]);\n return ++this.length;\n }\n\n pushPop(value: T): T {\n this.push(value);\n return this.pop()!;\n }\n\n replace(value: T): T | undefined {\n if (this.root == null) {\n this.root = { value };\n this.length = 1;\n return undefined;\n }\n const out = this.root.value;\n this.root = skewMerge(this.compare, [this.root.left, this.root.right, { value }]);\n return out;\n }\n\n get size(): number {\n return this.length;\n }\n\n *sorted(): Iterable {\n if (this.root == null) {\n return;\n }\n const heap = new SkewHeap>(\n (a, b) => this.compare(a.value, b.value),\n [this.root],\n );\n do {\n const node = heap.pop()!;\n yield node.value;\n node.left && heap.push(node.left);\n node.right && heap.push(node.right);\n } while (heap.size > 0);\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (const node of preOrderTraverse(this.root)) {\n yield node.value;\n }\n }\n\n update(curElement: T, newElement: T): boolean {\n if (this.root == null) {\n return false;\n }\n\n if (this.root.value === curElement) {\n this.root = skewMerge(this.compare, [\n this.root.left,\n this.root.right,\n { value: newElement },\n ]);\n return true;\n }\n\n let node: BinaryTreeNode | undefined = undefined;\n for (const par of preOrderTraverse(this.root)) {\n if (par.left && par.left.value === curElement) {\n node = par.left;\n par.left = undefined;\n break;\n }\n if (par.right && par.right.value === curElement) {\n node = par.right;\n par.right = undefined;\n break;\n }\n }\n\n if (node == null) {\n return false;\n }\n\n this.root = skewMerge(this.compare, [\n this.root,\n node.left,\n node.right,\n { value: newElement },\n ]);\n return true;\n }\n}\n","import { splice } from 'src/collection/arrayUtils';\nimport { clamp, wrapLeft } from 'src/math/numberUtils';\nimport { CompareFn } from '..';\nimport { List } from './list';\n\n/**\n * An implementation of the {@link List} interface using an array\n */\nexport class ArrayList implements List {\n /**\n * The array containing every element.\n */\n protected array: Array;\n /**\n * Instantiate the list.\n *\n * @param elements - A set of elements to initialize the list with.\n */\n constructor(elements?: Iterable) {\n this.array = elements ? Array.from(elements) : [];\n }\n\n add(index: number, element: T): number {\n if (index >= 0 && index <= this.size) {\n this.array.splice(index, 0, element);\n }\n return this.size;\n }\n\n addAll(index: number, elements: Iterable): number {\n if (index >= 0 && index <= this.size) {\n splice(this.array, index, 0, elements);\n }\n return this.size;\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n concat(...lists: Iterable[]): ArrayList {\n const out = new ArrayList(this);\n for (const list of lists) {\n out.addAll(out.size, list);\n }\n return out;\n }\n\n copyWithin(index: number, min?: number, max?: number): this {\n index = clamp(wrapLeft(index, 0, this.size), 0, this.size);\n min = clamp(wrapLeft(min ?? 0, 0, this.size), 0, this.size);\n max = clamp(wrapLeft(max ?? this.size, 0, this.size), 0, this.size);\n this.array.copyWithin(index, min, max);\n return this;\n }\n\n fill(element: T, min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.size), 0, this.size);\n max = clamp(wrapLeft(max ?? this.size, 0, this.size), 0, this.size);\n this.array.fill(element, min, max);\n return this;\n }\n\n get(index: number): T | undefined {\n return index < 0 || index >= this.size ? undefined : this.array[index];\n }\n\n getSet(index: number, callback: (element: T) => T): T | undefined {\n let value: T | undefined = undefined;\n if (index >= 0 && index < this.size) {\n value = this.array[index];\n this.array[index] = callback(value);\n }\n return value;\n }\n\n pop(): T | undefined {\n return this.array.pop();\n }\n\n push(element: T): number {\n return this.array.push(element);\n }\n\n remove(index: number): T | undefined {\n return index < 0 || index >= this.size ? undefined : this.array.splice(index, 1)[0];\n }\n\n reverse(min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.size), 0, this.size);\n max = clamp(wrapLeft(max ?? this.size, 0, this.size), 0, this.size) - 1;\n while (min < max) {\n const temp = this.array[min];\n this.array[min++] = this.array[max];\n this.array[max--] = temp;\n }\n return this;\n }\n\n set(index: number, element: T): T | undefined {\n let prev: T | undefined = undefined;\n if (index >= 0 && index < this.size) {\n prev = this.array[index];\n this.array[index] = element;\n }\n return prev;\n }\n\n shift(): T | undefined {\n return this.array.shift();\n }\n\n get size(): number {\n return this.array.length;\n }\n\n slice(min?: number, max?: number): ArrayList {\n return new ArrayList(this.array.slice(min, max));\n }\n\n splice(start?: number, count?: number, elements?: Iterable): List {\n return new ArrayList(splice(this.array, start, count, elements));\n }\n\n sort(compareFn: CompareFn): this {\n this.array.sort(compareFn);\n return this;\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n [Symbol.iterator](): Iterator {\n return this.array[Symbol.iterator]();\n }\n\n unshift(element: T): number {\n return this.array.unshift(element);\n }\n\n update(callback: (element: T, index: number) => T): this;\n update(min: number | undefined, callback: (element: T, index: number) => T): this;\n update(\n min: number | undefined,\n max: number | undefined,\n callback: (element: T, index: number) => T,\n ): this;\n update(\n min: number | undefined | ((element: T, index: number) => T),\n max?: number | ((element: T, index: number) => T),\n callback?: (element: T, index: number) => T,\n ): this {\n if (callback == null) {\n if (arguments.length < 2) {\n callback = min as (element: T, index: number) => T;\n min = undefined;\n } else {\n callback = max as (element: T, index: number) => T;\n max = undefined;\n }\n }\n min = clamp(wrapLeft((min as number) ?? 0, 0, this.size), 0, this.size);\n max = clamp(wrapLeft((max as number) ?? this.size, 0, this.size), 0, this.size);\n while (min < max) {\n this.array[min] = callback(this.array[min], min);\n ++min;\n }\n return this;\n }\n\n *view(min?: number, max?: number): Iterable {\n min = clamp(wrapLeft(min ?? 0, 0, this.size), 0, this.size);\n\n let len: () => number;\n if (max == null) {\n len = () => this.size;\n } else if (max >= 0) {\n len = () => Math.min(max, this.size);\n } else {\n len = () => this.size + max;\n }\n\n while (min < len()) {\n yield this.array[min++];\n }\n }\n}\n","import { CompareFn } from '..';\nimport { DoublyLinkedNode } from './doublyLinkedNode';\nimport { LinkedNode } from './linkedNode';\n\n/**\n * Sorts a list in place.\n *\n * Works on complete lists as well as sublists and circular lists:\n * - Linked lists will keep the link to the next node beyond the sorted section\n * - Doubly linked lists will keep links to the prev and next nodes outside the sorted section\n *\n * @param node - The head of the list\n * @param len - The length of the list beginning from node\n * @param isDoubly - Whether node is a doubly linked node\n * @param compareFn - A function used to determine the order of elements.\n *\n * It is expected to return:\n * - A negative value if first argument < second argument\n * - Zero if first argument == second argument\n * - A positive value if first argument > second argument\n *\n * @returns The new head and tail of the sorted list\n *\n * @internal\n */\nexport function linkedMergeSort>(\n node: Node,\n len: number,\n isDoubly: boolean,\n compareFn: CompareFn,\n): [Node, Node] {\n // Base case\n if (len < 2) {\n return [node, node];\n }\n\n // Split the list into two halves and sort them\n len = len / 2;\n const lens: [number, number] = [Math.ceil(len), Math.floor(len)];\n const heads = linkedMergeSort(node, lens[0], isDoubly, compareFn);\n const tails = linkedMergeSort(heads[1].next as Node, lens[1], isDoubly, compareFn);\n\n // Group the heads and tails together\n node = heads[1];\n heads[1] = tails[0];\n tails[0] = node;\n tails[0].next = tails[1].next;\n\n // Merge the sorted halves\n const prev = (heads[0] as DoublyLinkedNode).prev;\n node = linkedMergeSorted(heads, lens, isDoubly, compareFn);\n if (isDoubly) {\n (node as DoublyLinkedNode).prev = prev;\n }\n\n // Return the head and tail\n return [node, tails[+(lens[0] < 1)]];\n}\n/**\n * Merges two sorted lists.\n *\n * @param nodes - The heads of the lists\n * @param lens - The lengths of the lists\n * @param isDoubly - Whether the lists are a doubly linked\n * @param compareFn - A function used to determine the order of elements.\n *\n * It is expected to return:\n * - A negative value if first argument < second argument\n * - Zero if first argument == second argument\n * - A positive value if first argument > second argument\n *\n * @returns The new head of the sorted list\n *\n * @internal\n */\nexport function linkedMergeSorted>(\n heads: [Node, Node],\n lens: [number, number],\n isDoubly: boolean,\n compareFn: CompareFn,\n): Node {\n const root = {} as Node;\n\n let node = root;\n do {\n const index = +(compareFn(heads[0].value, heads[1].value) > 0);\n node.next = heads[index];\n if (isDoubly) {\n (node.next as DoublyLinkedNode).prev = node;\n }\n node = node.next as Node;\n heads[index] = node.next as Node;\n --lens[index];\n } while (lens[0] > 0 && lens[1] > 0);\n\n // Add any remaining nodes\n node.next = heads[+(lens[0] < 1)];\n if (isDoubly && node.next) {\n (node.next as DoublyLinkedNode).prev = node;\n }\n return root.next as Node;\n}\n","import { clamp, wrapLeft } from 'src/math/numberUtils';\nimport { CompareFn } from '..';\nimport { DoublyLinkedNode } from './doublyLinkedNode';\nimport { List } from './list';\nimport { linkedMergeSort } from './utils';\n\n/**\n * A (circular) doubly-linked list implementation of the {@link List} interface.\n *\n * Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.\n */\nexport class DoublyLinkedList implements List {\n /**\n * The number of elements in the list\n */\n protected length: number;\n /**\n * The sentinel node at the fron of the list\n */\n protected root: DoublyLinkedNode;\n /**\n * Instantiate the list.\n *\n * @param elements - A set of elements to initialize the list with.\n */\n constructor(elements?: Iterable) {\n this.length = 0;\n this.root = {} as DoublyLinkedNode;\n this.root.prev = this.root.next = this.root;\n this._addAll(this.root, elements ?? []);\n }\n\n add(index: number, value: T): number {\n if (index < 0 || index > this.length) {\n return this.length;\n }\n const prev = this._get(index - 1);\n const node = { next: prev.next, prev, value };\n prev.next = node;\n node.next!.prev = node;\n return ++this.length;\n }\n\n addAll(index: number, elements: Iterable): number {\n if (index >= 0 && index <= this.length) {\n this._addAll(this._get(index), elements);\n }\n return this.length;\n }\n\n clear(): void {\n this.length = 0;\n this.root.prev = this.root.next = this.root;\n }\n\n concat(...lists: Iterable[]): DoublyLinkedList {\n const out = new DoublyLinkedList(this);\n for (const list of lists) {\n out.addAll(out.size, list);\n }\n return out;\n }\n\n copyWithin(index: number, min?: number, max?: number): this {\n // Check if copying to the same section\n index = clamp(wrapLeft(index, 0, this.length), 0, this.length);\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n if (min === index) {\n return this;\n }\n\n // Check if the section to copy has no length\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n max = min + Math.min(max - min, this.length - index);\n if (min >= max) {\n return this;\n }\n\n // Check for overlap edge case\n if (min < index && index < max) {\n let nodeA = this._get(max);\n let nodeB = this._get(index + (max - min));\n do {\n nodeA = nodeA.prev!;\n nodeB = nodeB.prev!;\n nodeB.value = nodeA.value;\n } while (++min < max);\n return this;\n }\n\n // Copy the section to the destination\n let nodeA = this._get(min);\n let nodeB = this._get(index);\n do {\n nodeB.value = nodeA.value;\n nodeA = nodeA.next!;\n nodeB = nodeB.next!;\n } while (++min < max);\n return this;\n }\n\n fill(element: T, min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n if (min < max) {\n let node = this._get(min);\n do {\n node.value = element;\n node = node.next!;\n } while (++min < max);\n }\n return this;\n }\n\n get(index: number): T | undefined {\n return index < 0 || index >= this.length ? undefined : this._get(index).value;\n }\n\n getSet(index: number, callback: (element: T) => T): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = this._get(index);\n const value = node.value;\n node.value = callback(node.value);\n return value;\n }\n\n pop(): T | undefined {\n if (this.length < 1) {\n return undefined;\n }\n const tail = this.root.prev!;\n tail.prev!.next = this.root;\n this.root.prev = tail.prev;\n --this.length;\n return tail.value;\n }\n\n push(value: T): number {\n const prev = this.root.prev!;\n const node = { next: this.root, prev, value };\n prev.next = this.root.prev = node;\n return ++this.length;\n }\n\n remove(index: number): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = this._get(index);\n node.prev!.next = node.next;\n node.next!.prev = node.prev;\n --this.length;\n return node.value;\n }\n\n reverse(min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n if (max - min < 2) {\n return this;\n }\n const root = this._get(min - 1);\n const tail = root.next!;\n let node = tail;\n do {\n const temp = node.next!;\n node.next = node.prev;\n node.prev = temp;\n root.next = node;\n node = temp;\n } while (++min < max);\n tail.next = node;\n node.prev = tail;\n root.next!.prev = root;\n return this;\n }\n\n set(index: number, element: T): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = this._get(index);\n const value = node.value;\n node.value = element;\n return value;\n }\n\n shift(): T | undefined {\n if (this.length < 1) {\n return undefined;\n }\n const head = this.root.next!;\n head.next!.prev = this.root;\n this.root.next = head.next;\n --this.length;\n return head.value;\n }\n\n get size(): number {\n return this.length;\n }\n\n slice(min?: number, max?: number): DoublyLinkedList {\n return new DoublyLinkedList(this.view(min, max));\n }\n\n splice(start?: number, count?: number, elements?: Iterable): List {\n start = clamp(wrapLeft(start ?? 0, 0, this.length), 0, this.length);\n count = clamp(count ?? this.size, 0, this.size - start);\n\n // If not modifying the list\n const list = new DoublyLinkedList();\n if (elements == null && count < 1) {\n return list;\n }\n\n // Delete elements\n let node = this._get(start);\n while (count-- > 0) {\n list.push(node.value);\n node.prev!.next = node.next!;\n node.next!.prev = node.prev!;\n node = node.next!;\n --this.length;\n }\n\n // Add elements\n this._addAll(node, elements ?? []);\n\n return list;\n }\n\n sort(compareFn: CompareFn): this {\n if (this.length > 1) {\n const [head, tail] = linkedMergeSort(this.root.next!, this.length, true, compareFn);\n this.root.next = head;\n tail.next!.prev = tail;\n }\n return this;\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (let node = this.root.next!; node !== this.root; node = node.next!) {\n yield node.value;\n }\n }\n\n unshift(value: T): number {\n const head = this.root.next!;\n const node = { next: head, prev: this.root, value };\n this.root.next = head.prev = node;\n return ++this.length;\n }\n\n update(callback: (element: T, index: number) => T): this;\n update(min: number | undefined, callback: (element: T, index: number) => T): this;\n update(\n min: number | undefined,\n max: number | undefined,\n callback: (element: T, index: number) => T,\n ): this;\n update(\n min: number | undefined | ((element: T, index: number) => T),\n max?: number | ((element: T, index: number) => T),\n callback?: (element: T, index: number) => T,\n ): this {\n if (callback == null) {\n if (arguments.length < 2) {\n callback = min as (element: T, index: number) => T;\n min = undefined;\n } else {\n callback = max as (element: T, index: number) => T;\n max = undefined;\n }\n }\n min = clamp(wrapLeft((min as number) ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft((max as number) ?? this.length, 0, this.length), 0, this.length);\n if (min < max) {\n let node = this._get(min);\n do {\n node.value = callback(node.value, min);\n node = node.next!;\n } while (++min < max);\n }\n return this;\n }\n\n *view(min?: number, max?: number): Iterable {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n\n let len: () => number;\n if (max == null) {\n len = () => this.length;\n } else if (max >= 0) {\n len = () => max;\n } else {\n len = () => this.length + max;\n }\n\n if (min < len()) {\n let node = this._get(min);\n do {\n yield node.value;\n node = node.next!;\n } while (++min < len() && node !== this.root);\n }\n }\n /**\n *\n */\n protected _addAll(next: DoublyLinkedNode, elements: Iterable): void {\n let prev = next.prev!;\n for (const value of elements) {\n const node = { prev, value };\n prev.next = node;\n prev = node;\n ++this.length;\n }\n prev.next = next;\n next.prev = prev;\n }\n /**\n * A helper method to iterate and return the node at the given index.\n *\n * Depending on the index, the list will be traversed from beginning or end; whichever is closest to the specified index.\n *\n * @param index - The index to retrieve\n *\n * @returns The node at the given index\n */\n protected _get(index: number): DoublyLinkedNode {\n let node = this.root;\n if (index < this.length / 2) {\n while (index-- >= 0) {\n node = node.next!;\n }\n } else {\n for (index = this.length - index; index > 0; --index) {\n node = node.prev!;\n }\n }\n return node;\n }\n}\n","import { clamp, wrapLeft } from 'src/math/numberUtils';\nimport { CompareFn } from '..';\nimport { LinkedNode } from './linkedNode';\nimport { List } from './list';\nimport { linkedMergeSort } from './utils';\n\n/**\n * A (circular) linked list implementation of the {@link List} interface.\n */\nexport class LinkedList implements List {\n /**\n * The number of elements in the list.\n */\n protected length: number;\n /**\n * The sentinel node at the front of the list.\n */\n protected root: LinkedNode;\n /**\n * The last node of the list.\n */\n protected tail: LinkedNode;\n /**\n * Instantiate the list.\n *\n * @param elements - A set of elements to initialize the list with.\n */\n constructor(elements?: Iterable) {\n this.length = 0;\n this.root = {} as LinkedNode;\n this.root.next = this.root;\n this.tail = this._addAll(this.root, elements ?? []);\n }\n\n add(index: number, value: T): number {\n if (index >= 0 && index < this.length) {\n const prev = this._get(index - 1);\n prev.next = { value, next: prev.next };\n ++this.length;\n } else if (index === this.length) {\n this.push(value);\n }\n return this.length;\n }\n\n addAll(index: number, elements: Iterable): number {\n if (index >= 0 && index < this.length) {\n this._addAll(this._get(index - 1), elements);\n } else if (index === this.length) {\n this.tail = this._addAll(this.tail, elements);\n }\n return this.length;\n }\n\n clear(): void {\n this.length = 0;\n this.tail = this.root.next = this.root;\n }\n\n concat(...lists: Iterable[]): LinkedList {\n const out = new LinkedList(this);\n for (const list of lists) {\n out.addAll(out.size, list);\n }\n return out;\n }\n\n copyWithin(index: number, min?: number, max?: number): this {\n // Check if copying to itself\n index = clamp(wrapLeft(index, 0, this.length), 0, this.length);\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n if (min === index) {\n return this;\n }\n\n // Check if the section to copy has no length\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n max = min + Math.min(max - min, this.length - index);\n if (min >= max) {\n return this;\n }\n\n // Copy to earlier in the list\n if (index < min) {\n const node = this._get(index - 1);\n this._copyWithin(this._get(min - index - 1, node), node, max - min);\n return this;\n }\n\n // Copy to later in the list\n if (index > max) {\n const node = this._get(min - 1);\n this._copyWithin(node, this._get(index - min - 1, node), max - min);\n return this;\n }\n\n // Copy to overlapping destination\n const nodeA = this._get(min - 1);\n const nodeC = this._get(max - min - 1, nodeA);\n const nodeD = this._copyWithin(nodeA, nodeC, index - min);\n if (index + (max - min) >= this.length) {\n this.tail = nodeC;\n }\n const temp = nodeA.next;\n nodeA.next = nodeC.next;\n nodeC.next = nodeD.next;\n nodeD.next = temp;\n return this;\n }\n\n fill(element: T, min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n if (min < max) {\n let node = this._get(min);\n do {\n node.value = element;\n node = node.next!;\n } while (++min < max);\n }\n return this;\n }\n\n get(index: number): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n return index < this.length - 1 ? this._get(index).value : this.tail.value;\n }\n\n getSet(index: number, callback: (element: T) => T): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = index < this.length - 1 ? this._get(index) : this.tail;\n const value = node.value;\n node.value = callback(node.value);\n return value;\n }\n\n pop(): T | undefined {\n if (this.length < 1) {\n return undefined;\n }\n const value = this.tail.value;\n this.tail = this._get(this.length - 2);\n this.tail.next = this.root;\n --this.length;\n return value;\n }\n\n push(value: T): number {\n const tail: LinkedNode = { next: this.root, value };\n this.tail.next = tail;\n this.tail = tail;\n return ++this.length;\n }\n\n remove(index: number): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const prev = this._get(index - 1);\n const node = prev.next!;\n prev.next = node.next;\n if (index === --this.length) {\n this.tail = prev;\n }\n return node.value;\n }\n\n reverse(min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n if (max - min < 2) {\n return this;\n }\n const root = this._get(min - 1);\n this.tail = max >= this.length ? root.next! : this.tail;\n const tail = root.next!;\n let prev = tail;\n let node = tail.next!;\n while (++min < max) {\n const next = node.next!;\n node.next = prev;\n prev = node;\n node = next;\n }\n root.next = prev;\n tail.next = node;\n return this;\n }\n\n set(index: number, element: T): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = this._get(index);\n const value = node.value;\n node.value = element;\n return value;\n }\n\n shift(): T | undefined {\n return this.remove(0);\n }\n\n get size(): number {\n return this.length;\n }\n\n slice(min?: number, max?: number): LinkedList {\n return new LinkedList(this.view(min, max));\n }\n\n splice(start?: number, count?: number, elements?: Iterable): List {\n start = clamp(wrapLeft(start ?? 0, 0, this.length), 0, this.length);\n count = clamp(count ?? this.size, 0, this.size - start);\n\n // If not modifying the list\n const deleted = new LinkedList();\n if (elements == null && count < 1) {\n return deleted;\n }\n\n // Delete elements\n let prev = this._get(start - 1);\n const newTail = start + count >= this.size;\n while (count-- > 0) {\n const node = prev.next!;\n deleted.push(node.value);\n prev.next = node.next;\n --this.length;\n }\n\n // Add elements\n prev = this._addAll(prev, elements ?? []);\n this.tail = newTail ? prev : this.tail;\n\n return deleted;\n }\n\n sort(compareFn: CompareFn): this {\n if (this.length > 1) {\n const [head, tail] = linkedMergeSort(this.root.next!, this.length, false, compareFn);\n this.root.next = head;\n this.tail = tail;\n }\n return this;\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (let node = this.root.next!; node !== this.root; node = node.next!) {\n yield node.value;\n }\n }\n\n unshift(value: T): number {\n return this.add(0, value);\n }\n\n update(callback: (element: T, index: number) => T): this;\n update(min: number | undefined, callback: (element: T, index: number) => T): this;\n update(\n min: number | undefined,\n max: number | undefined,\n callback: (element: T, index: number) => T,\n ): this;\n update(\n min: number | undefined | ((element: T, index: number) => T),\n max?: number | ((element: T, index: number) => T),\n callback?: (element: T, index: number) => T,\n ): this {\n if (callback == null) {\n if (arguments.length < 2) {\n callback = min as (element: T, index: number) => T;\n min = undefined;\n } else {\n callback = max as (element: T, index: number) => T;\n max = undefined;\n }\n }\n min = clamp(wrapLeft((min as number) ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft((max as number) ?? this.length, 0, this.length), 0, this.length);\n if (min < max) {\n let node = this._get(min);\n do {\n node.value = callback(node.value, min);\n node = node.next!;\n } while (++min < max);\n }\n return this;\n }\n\n *view(min?: number, max?: number): Iterable {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n\n let len: () => number;\n if (max == null) {\n len = () => this.length;\n } else if (max >= 0) {\n len = () => max;\n } else {\n len = () => this.length + max;\n }\n\n if (min < len()) {\n let node = this._get(min);\n do {\n yield node.value;\n node = node.next!;\n } while (++min < len() && node !== this.root);\n }\n }\n\n protected _addAll(prev: LinkedNode, elements: Iterable): LinkedNode {\n const next = prev.next!;\n for (const value of elements) {\n const node = { value };\n prev.next = node;\n prev = node;\n ++this.length;\n }\n prev.next = next;\n return prev;\n }\n /**\n * Copy values from 'from' to 'to'.\n *\n * @param from - The initial node to copy from\n * @param prev - The root of the initial node to copy to\n * @param count - The number of values to copy\n */\n protected _copyWithin(from: LinkedNode, to: LinkedNode, count: number): LinkedNode {\n while (count-- > 0) {\n from = from.next!;\n to = to.next!;\n to.value = from.value;\n }\n return to;\n }\n /**\n * Get the node at the given index.\n *\n * @param index - The index to retrieve\n *\n * @returns The node at the given index\n */\n protected _get(index: number, root: LinkedNode = this.root): LinkedNode {\n let node = root!;\n while (index-- >= 0) {\n node = node.next!;\n }\n return node;\n }\n}\n","/**\n * Bit hacks for 32-bit unsigned numbers.\n */\n\n/**\n * Get the number of bits set of a 32-bit unsigned number ([source](https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan))\n *\n * @param a\n */\nexport function bitsSet(a: number): number {\n let b = 0;\n while (a) {\n ++b;\n a &= a - 1;\n }\n return b;\n}\n/**\n * Invert the bits of a 32-bit unsigned number.\n *\n * Example: 11 (1011) -> 4 (0100)\n *\n * @param a The number to invert\n *\n * @returns The inverted number\n */\nexport function invert(a: number): number {\n const b = msp(a);\n return u32(a ^ (b | (b - 1)));\n}\n/**\n * Check whether a 32-bit unsigned number is a power of 2.\n *\n * Example: 8 (1000) -> true\n *\n * @param a The number to check\n */\nexport function isPow2(a: number): boolean {\n return (a & (a - 1)) === 0;\n}\n/**\n * Get the Least Significant Bit of a 32-bit unsigned number\n *\n * @param a\n *\n * @returns The lowest bit set\n */\nexport function lsb(a: number): number {\n let b = -1;\n for (a = lsp(a); a; a >>>= 1) {\n ++b;\n }\n return b;\n}\n/**\n * Get the Least Significant Power of a 32-bit unsigned number\n *\n * @param a\n *\n * @returns 2**lsb(a)\n */\nexport function lsp(a: number): number {\n return u32(a & -a);\n}\n/**\n * Get the Least Significant Power Set of a 32-bit unsigned number.\n *\n * Example: 54 (110110) -> 6 (000110)\n *\n * @param a\n */\nexport function lsps(a: number): number {\n return u32(a & (lsp(a + lsp(a)) - 1));\n}\n/**\n * Get the Most Significant Power of the Least Significant Power Set of a 32-bit unsigned number.\n *\n * Example: 54 (110110) -> 4 (000100)\n *\n * @param a\n */ /*\nexport function mlsp(a: number): number {\n return (lsp(a + lsp(a)) >>> 1) || u32(0x80000000 & a);\n}\n*/\n/**\n * Get the Most Significant Bit of a 32-bit unsigned number\n *\n * @param a\n *\n * @returns ⌊log2(a)⌋ : the highest bit set\n */\nexport function msb(a: number): number {\n let b = -1;\n while (a !== 0) {\n ++b;\n a >>>= 1;\n }\n return b;\n}\n/**\n * Get the Most Significant Power of a 32-bit unsigned number\n *\n * @param a\n *\n * @returns 2**msb(a)\n */\nexport function msp(a: number): number {\n let b = a & -a;\n while (a != b) {\n a ^= b;\n b = a & -a;\n }\n return u32(b);\n}\n/**\n * Get the Most Significant Power Set of a 32-bit unsigned number.\n *\n * Example: 50 (110010) -> 48 (110000)\n *\n * @param a\n */\nexport function msps(a: number): number {\n let b = a & -a;\n while (a & (a + b)) {\n a ^= b;\n b = a & -a;\n }\n return u32(a);\n}\n/**\n * Reverse a 32-bit unsigned number.\n *\n * Example: 50 (110010) -> 19 (010011)\n *\n * @param a\n */\nexport function reverse(a: number): number {\n a = ((a & 0xaaaaaaaa) >>> 1) | ((a & 0x55555555) << 1);\n a = ((a & 0xcccccccc) >>> 2) | ((a & 0x33333333) << 2);\n a = ((a & 0xf0f0f0f0) >>> 4) | ((a & 0x0f0f0f0f) << 4);\n a = ((a & 0xff00ff00) >>> 8) | ((a & 0x00ff00ff) << 8);\n return u32((a >>> 16) | (a << 16));\n}\n/**\n * Turn a number into an unsigned 32-bit number\n *\n * @param a\n */\nexport function u32(a: number): number {\n return a >>> 0;\n}\n","import { Queue } from './queue';\n\n/**\n * An implementation of the {@link Queue} interface using an array\n */\nexport class ArrayQueue implements Queue {\n /**\n * The array containing every element.\n */\n protected array: T[];\n /**\n * Instantiate the queue.\n *\n * @param elements - A set of elements to initialize the queue with.\n */\n constructor(elements?: Iterable) {\n this.array = elements ? Array.from(elements) : [];\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n dequeue(): T | undefined {\n return this.size < 1 ? undefined : this.array.shift();\n }\n\n enqueue(element: T): number {\n return this.array.push(element);\n }\n\n peek(): T | undefined {\n return this.size < 1 ? undefined : this.array[0];\n }\n\n get size(): number {\n return this.array.length;\n }\n /**\n * Receive an iterator through the queue.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the queue\n */\n [Symbol.iterator](): Iterator {\n return this.array[Symbol.iterator]();\n }\n}\n","import { LinkedList, List } from '../list';\nimport { Queue } from './queue';\n\n/**\n * A linked list implementation of the {@link Queue} interface\n */\nexport class LinkedQueue implements Queue {\n /**\n * The list containing every element.\n */\n protected list: List;\n /**\n * Instantiate the queue.\n *\n * @param elements - A set of elements to initialize the queue with.\n */\n constructor(elements?: Iterable) {\n this.list = new LinkedList(elements);\n }\n\n clear(): void {\n this.list.clear();\n }\n\n dequeue(): T | undefined {\n return this.list.shift();\n }\n\n enqueue(element: T): number {\n return this.list.push(element);\n }\n\n peek(): T | undefined {\n return this.list.get(0);\n }\n\n get size(): number {\n return this.list.size;\n }\n /**\n * Receive an iterator through the queue.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the queue\n */\n [Symbol.iterator](): Iterator {\n return this.list[Symbol.iterator]();\n }\n}\n","import { lsb, lsp, msb, msp } from '../math/u32';\nimport { CombineFn } from '..';\nimport { MAX_ARRAY_LENGTH } from 'src/collection/arrayUtils';\nimport { SegmentTree } from './segmentTree';\n\n/*\n mca(a, b) = lsp(a | msp(b - a)) ; // where a <= b\n left(i) = i - (lsp(i + 1) >>> 1)\n right(i) = i + (lsp(i + 1) >>> 1)\n parent(i) =\n offset = lsp(i + 1)\n i + offset - ((i & 2*offset) >>> 0)\n*/\n\n/**\n * A {@link SegmentTree} with entries stored in in-order traversal.\n * Inspired by [Tristan Hume's IForestIndex](https://thume.ca/2021/03/14/iforests) ([github](https://github.com/trishume/gigatrace))\n */\nexport class InOrderSegmentTree implements SegmentTree {\n /**\n * The maximum amount of elements that can be added.\n *\n * n elements require 2n memory.\n */\n static readonly MAX_SIZE: number = MAX_ARRAY_LENGTH >>> 1;\n /**\n * The set of elements and aggregation nodes for the tree\n */\n protected array: T[];\n /**\n * The function used to aggregate elements\n */\n protected combine: CombineFn;\n /**\n * Construct a new segment tree\n *\n * @param combine - The function used to aggregate segment information\n * @param elements - A set of elements to add into the initial tree\n */\n constructor(combine: CombineFn, elements: Iterable = []) {\n this.array = [];\n this.combine = combine;\n this.build(elements);\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n pop(): T | undefined {\n // Sanitize range\n if (this.size < 1) {\n return undefined;\n }\n\n // Un-complete aggregation nodes\n const i = this.array.length - 1;\n for (let mask = 2; i & mask; mask *= 2) {\n this.array[i - mask] = this.array[i - mask - (mask >>> 1)];\n }\n\n // Return element\n const out = this.array[i - 1];\n this.array.length -= 2;\n return out;\n }\n\n push(element: T): number {\n // Sanitize range\n if (this.size >= InOrderSegmentTree.MAX_SIZE) {\n throw new RangeError(`Invalid length`);\n }\n\n // Add element\n const i = this.array.length;\n this.array[i + 1] = this.set(i, element);\n\n return this.size;\n }\n\n query(min: number, max: number): T {\n // Sanitize range\n if (min >= max) {\n throw new RangeError(`Range [${min}..${max}) is empty`);\n }\n if (min < 0 || max > this.size) {\n throw new RangeError(`Range [${min}..${max}) not in [0..${this.size})`);\n }\n\n // Translate range to interior indices\n min *= 2;\n max *= 2;\n\n // Jump to min's highest aggregation node that is fully within the range\n let offset = lsp(min | msp(max - min));\n let value = this.array[min - 1 + (offset >>> 1)];\n\n // Continue jumping aggregation nodes until max is reached\n for (min += offset; min < max; min += offset) {\n offset = lsp(min | msp(max - min));\n value = this.combine(value, this.array[min - 1 + (offset >>> 1)]);\n }\n\n return value;\n }\n\n get size(): number {\n return this.array.length >>> 1;\n }\n\n /**\n * Return an iterator through the tree's elements\n */\n *[Symbol.iterator](): Iterator {\n for (let i = 0; i < this.array.length; i += 2) {\n yield this.array[i];\n }\n }\n\n update(min: number, max: number, operation: (element: T, index: number) => T): void {\n // Sanitize range\n if (min >= max) {\n return;\n }\n if (min < 0 || max > this.size) {\n throw new RangeError(`Range [${min}..${max}) not in [0..${this.size})`);\n }\n\n // Translate range to interior indices\n min *= 2;\n max *= 2;\n\n // Update the values\n let value: T;\n do {\n value = this.set(min, operation(this.array[min], min >>> 1));\n min += 2;\n } while (min < max);\n\n // Update remaining aggregation nodes\n let dc = 0;\n let dp = lsp(min);\n max = msb(min ^ this.array.length) - lsb(min);\n for (--min; max > 0; --max) {\n value = this.combine(value, this.array[min + (dp >>> 1) - dc]);\n this.array[min] = value;\n dc = (min & (2 * dp)) >>> 0;\n min += dp - dc;\n dp *= 2;\n }\n\n // Update the incomplete aggregation node\n this.array[min] = value;\n }\n /**\n * A helper method used to build the tree\n *\n * @param elements The initial set of elements to add into the tree\n */\n protected build(elements: Iterable) {\n for (const element of elements) {\n this.push(element);\n }\n }\n /**\n * A helper method to update complete aggregation nodes for an index\n */\n protected set(index: number, element: T): T {\n // Set the index\n this.array[index++] = element;\n\n // Update complete aggregation nodes, from lowest to highest\n for (let mask = 2; index & mask; mask *= 2) {\n element = this.combine(this.array[index - mask - (mask >>> 1)], element);\n this.array[index - mask] = element;\n }\n\n return element;\n }\n}\n","/**\n * Thanks to [Douglas Wilhelm Harder](https://ece.uwaterloo.ca/~dwharder/aads/Algorithms/Array_resizing/)\n * for their analysis on array resizing\n */\nimport { isArray, MAX_ARRAY_LENGTH } from 'src/collection/arrayUtils';\nimport { isCollection } from 'src/collection';\nimport { Collection } from 'src/collection/collection';\nimport { CombineFn } from '..';\nimport { isPow2, lsp, msp } from '../math/u32';\nimport { SegmentTree } from './segmentTree';\n\n/**\n * A {@link SegmentTree} with entries stored in level-order traversal.\n * Memory usage: n elements require between 2n-1 to 4(n-1)-1 entries\n *\n */\nexport class LevelOrderSegmentTree implements SegmentTree {\n /**\n * The maximum number of elements that can be added.\n *\n * n elements require 2^⌈log2(2n)⌉ - 1 memory:\n */\n static readonly MAX_SIZE: number = (MAX_ARRAY_LENGTH + 1) / 2;\n /**\n * The internal array used to store elements and aggregation nodes\n */\n protected array: Array;\n /**\n * The function used to aggregate elements\n */\n protected combine: CombineFn;\n /**\n * The used length (size) of our internal array\n */\n protected length: number;\n /**\n * The start index for the lowest level\n */\n protected level: number;\n /**\n * Construct a new {@link SegmentTree}\n *\n * @param combinFn - The function used to aggregate elements\n * @param elements - Initial elements to build into the tree\n */\n constructor(combine: CombineFn, elements: Iterable = []) {\n this.array = [];\n this.combine = combine;\n this.length = 0;\n this.level = 0;\n this.build(elements);\n }\n\n clear(): void {\n this.length = 0;\n this.level = 0;\n this.array.length = 0;\n }\n\n pop(): T | undefined {\n // Sanitize range\n if (this.length <= this.level) {\n return undefined;\n }\n\n // Remove element\n const out = this.array[--this.length];\n\n // If level is <= 1/4 full\n if (this.length <= (this.array.length + 1) >>> 2) {\n this.shrink();\n }\n\n return out;\n }\n\n push(element: T): number {\n // If array is full\n if (this.length >= this.array.length) {\n this.grow();\n }\n\n // Add the new element\n this.array[this.length++] = element;\n\n // Update aggregation nodes\n for (let i = this.length; i & 1; this.array[i - 1] = element) {\n element = this.combine(this.array[i - 2], element);\n i >>>= 1;\n }\n\n return this.size;\n }\n\n query(min: number, max: number): T {\n // Sanitize range\n if (min >= max) {\n throw new RangeError(`Range [${min}..${max}) is empty`);\n }\n if (min < 0 || max > this.size) {\n throw new RangeError(`Range [${min}..${max}) not in [0..${this.size})`);\n }\n\n // Translate range to interior indices and align with powers of 2\n min += this.level + 1;\n max += this.level + 1;\n\n // Take the longest possible jump from min\n let offset = lsp(min | msp(max - min));\n let value: T = this.array[min / offset - 1];\n min += offset;\n\n // Continue jumping until max\n while (min < max) {\n offset = lsp(min | msp(max - min));\n value = this.combine(value, this.array[min / offset - 1]);\n min += offset;\n }\n\n return value;\n }\n\n get size(): number {\n return this.length - this.level;\n }\n\n /**\n * Return an iterator through the elements\n */\n *[Symbol.iterator](): Iterator {\n for (let i = 0; i < this.size; ++i) {\n yield this.array[this.level + i];\n }\n }\n\n update(min: number, max: number, operation: (element: T, index: number) => T): void {\n // Sanitize range\n if (min >= max) {\n return;\n }\n if (min < 0 || max > this.size) {\n throw new RangeError(`Range [${min}..${max}) not in [0..${this.size})`);\n }\n\n // Translate range to interior indices\n min += this.level;\n max += this.level;\n\n // Update the range\n for (let i = min; i < max; ++i) {\n this.array[i] = operation(this.array[i], i - this.level);\n }\n\n // Update the range's aggregation nodes\n this.aggregate(min, max);\n }\n /**\n * A helper method to aggregate a range of elements\n */\n protected aggregate(min: number, max: number): void {\n // Align indices with powers of 2\n ++min;\n ++max;\n\n // Aggregate elements\n for (let cap = this.length + 1; min < max; cap >>>= 1) {\n max += max & ((max - cap) >>> 31);\n for (let i = (min | 1) >>> 0; i < max; i += 2) {\n this.array[(i >>> 1) - 1] = this.combine(this.array[i - 2], this.array[i - 1]);\n }\n min >>>= 1;\n max >>>= 1;\n }\n }\n /**\n * A helper method used to build the tree\n *\n * @param elements The initial set of elements to add into the tree\n */\n protected build(elements: Collection | Iterable): void {\n let key: string | undefined = undefined;\n\n // Check if the iterable's size can be known.\n if (isArray(elements)) {\n key = 'length';\n } else if (isCollection(elements)) {\n key = 'size';\n } else {\n for (const element of elements) {\n this.push(element);\n }\n return;\n }\n\n // Get the iterable's size\n const n: number = (elements as any)[key];\n\n // Check for base case\n if (n < 1) {\n this.array.length = 0;\n this.length = 0;\n this.level = 0;\n return;\n }\n\n // Check if max capacity reached\n if (n >= LevelOrderSegmentTree.MAX_SIZE) {\n throw new RangeError('Invalid length');\n }\n\n // Allocate the array\n this.level = 2 * msp(n - 1) - 1;\n this.length = this.level;\n this.array.length = 2 * this.level + 1;\n\n // Add the elements\n for (const element of elements) {\n this.array[this.length++] = element;\n }\n\n // Update aggregation nodes\n this.aggregate(this.level, this.length);\n }\n /**\n * Shift the tree down a level\n */\n protected grow(): void {\n // Check base case\n if (this.size < 1) {\n this.array.length = 1;\n return;\n }\n\n // Check if max capacity reached\n if (this.size >= LevelOrderSegmentTree.MAX_SIZE) {\n throw new RangeError('Invalid length');\n }\n\n // Extend capacity\n this.array.length += this.array.length + 1;\n\n // Shift the tree down a level\n let min = this.level + 1;\n for (let max = this.length + 1; min < max; max >>>= 1) {\n this.array.copyWithin(2 * min - 1, min - 1, max - 1);\n min >>>= 1;\n }\n\n // Update pointers\n this.length += this.level + 1;\n this.level += this.level + 1;\n }\n /**\n * Shift the tree to the highest non-full level\n */\n protected shrink(): void {\n const length = this.length - this.level;\n\n // Check base case\n if (length < 2) {\n this.array.copyWithin(0, this.level, this.length);\n this.level = 0;\n this.length = length;\n this.array.length = length;\n return;\n }\n\n // Get the highest node\n let min = this.level + 1;\n let mask = msp(length);\n min = min / lsp(min | mask) - 1;\n\n // Check if shrinking is possible\n if (min < 2) {\n return;\n }\n\n // Update the tree\n this.level = 1;\n for (let max = min + 1; mask; this.level += this.level + 1) {\n this.array.copyWithin(this.level, min, max);\n mask >>>= 1;\n min += min + 1;\n max += max + 2 + +((length & mask) > 0);\n }\n\n // Update pointers\n this.length = this.level + length;\n this.array.length = 2 * this.level + 1;\n }\n}\n","import { Stack } from './stack';\n\n/**\n * An implementation of the {@link Stack} interface using an array\n */\nexport class ArrayStack implements Stack {\n /**\n * The array containing every element.\n */\n protected array: T[];\n /**\n * Instantiate the stack.\n *\n * @param elements - A set of elements to initialize the stack with.\n */\n constructor(elements?: Iterable) {\n this.array = elements ? Array.from(elements) : [];\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n peek(): T | undefined {\n return this.array[this.array.length - 1];\n }\n\n pop(): T | undefined {\n return this.array.pop();\n }\n\n push(element: T): number {\n return this.array.push(element);\n }\n\n get size(): number {\n return this.array.length;\n }\n /**\n * Receive an iterator through the stack.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the stack\n */\n *[Symbol.iterator](): Iterator {\n const array = this.array;\n for (let i = array.length; i > 0; yield array[--i]) {}\n }\n}\n","import { LinkedList, List } from '../list';\nimport { Stack } from './stack';\n\n/**\n * A linked list implementation of the {@link Stack} interface\n */\nexport class LinkedStack implements Stack {\n /**\n * The list containing every element.\n */\n protected list: List;\n /**\n * Instantiate the stack.\n *\n * @param elements - A set of elements to initialize the stack with.\n */\n constructor(elements?: Iterable) {\n this.list = new LinkedList();\n for (const element of elements || []) {\n this.push(element);\n }\n }\n\n clear(): void {\n this.list.clear();\n }\n\n peek(): T | undefined {\n return this.list.get(0);\n }\n\n pop(): T | undefined {\n return this.list.shift();\n }\n\n push(element: T): number {\n return this.list.unshift(element);\n }\n\n get size(): number {\n return this.list.size;\n }\n /**\n * Receive an iterator through the stack.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the stack\n */\n [Symbol.iterator](): Iterator {\n return this.list[Symbol.iterator]();\n }\n}\n","import { CompareFn } from '..';\nimport { AATreeNode } from './aaTreeNode';\nimport {\n clone,\n search,\n Edge,\n inOrderTraverse,\n leftmost,\n leftmostStack,\n preOrderTraverse,\n removeStack,\n rightmost,\n rightmostStack,\n searchStack,\n debug,\n} from './binaryTreeUtils';\nimport { SortedTree } from './sortedTree';\nimport { isArray } from 'src/collection/arrayUtils';\nimport { LinkedNode } from 'src/list';\n\n/**\n * An AA tree is a form of balanced tree used for storing and retrieving ordered data efficiently\n * ([source](https://en.wikipedia.org/wiki/AA_tree)).\n *\n * AA trees are named for Arne Andersson, their inventor. They are a variation of the red–black tree,\n * which supports efficient addition and deletion of entries. Unlike red–black trees, additional\n * constraints on the balancing mechanism greatly simplifies the implementation as well as\n * maintenance operations; While a red–black tree needs to consider seven different shapes\n * to properly balance the tree, an AA tree only needs to consider two shapes.\n *\n * The performance of an AA tree is equivalent to the performance of a red–black tree.\n * While an AA tree makes more rotations than a red-black tree, the simpler algorithms\n * tend to be faster, which balances out to similar performance. A red-black tree is\n * more consistent in its performance, but an AA tree tends to be flatter, which results\n * in slightly faster search times.\n */\nexport class AATree implements SortedTree {\n /**\n * The function to determine the order of elements.\n */\n protected compare: CompareFn;\n /**\n * Indicates how to handle duplicates:\n * - < 0 : Add to left subtree\n * - = 0 : Do now allow duplicates\n * - > 0 : Add to right subtree\n */\n protected dupeWeight: number;\n /**\n * The number of elements in the list.\n */\n protected length: number;\n /**\n * The node at the \"top\" of the heap.\n */\n protected root: AATreeNode | undefined;\n /**\n * Instantiate a tree.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param elements - A set of elements to initialize the tree with.\n */\n constructor(compareFn: CompareFn, elements?: Iterable);\n /**\n * Instantiate a tree.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param allowDuplicates - Whether to allow duplicates\n * @param elements - A set of elements to initialize the tree with.\n */\n constructor(compareFn: CompareFn, allowDuplicates: boolean, elements?: Iterable);\n constructor(\n compareFn: CompareFn,\n allowDuplicates?: boolean | Iterable,\n elements?: Iterable,\n ) {\n if (typeof allowDuplicates !== 'boolean') {\n elements = allowDuplicates;\n allowDuplicates = true;\n }\n this.compare = compareFn;\n this.dupeWeight = +allowDuplicates;\n this.length = 0;\n this.build(elements ?? []);\n }\n\n add(element: T): this {\n // Find the element\n const sentinel = { left: this.root } as AATreeNode;\n let edge: Edge> = { from: sentinel, label: 'left', to: this.root };\n let stack = searchStack(element, { value: edge }, this.compare, this.dupeWeight);\n\n // If element already exists\n if (stack.value.to != null) {\n return this;\n }\n\n // Add element\n edge = stack.value;\n let label = edge.label;\n edge.from![label!] = { level: 1, value: element };\n\n // Balance the tree\n while (stack.next) {\n stack = stack.next;\n edge = stack.value;\n edge.to = split(skew(edge.to));\n edge.from![(label = edge.label!)] = edge.to;\n }\n\n // Update state\n ++this.length;\n this.root = sentinel.left;\n return this;\n }\n\n clear(): void {\n this.root = undefined;\n this.length = 0;\n }\n\n comparator(): CompareFn {\n return this.compare;\n }\n\n delete(element: T): boolean {\n // Remove the element if found\n const sentinel = { left: this.root } as AATreeNode;\n const edge: Edge> = { from: sentinel, label: 'left', to: this.root };\n const stack = searchStack(element, { value: edge }, this.compare, 0);\n const removed = remove(stack);\n\n // Update state\n this.root = sentinel.left;\n this.length -= +removed;\n return removed;\n }\n\n has(element: T): boolean {\n return search(element, this.root, this.compare) != null;\n }\n\n max(): T | undefined {\n return rightmost(this.root)?.value;\n }\n\n min(): T | undefined {\n return leftmost(this.root)?.value;\n }\n\n pop(): T | undefined {\n // Find the maximum value\n const sentinel = { left: this.root } as AATreeNode;\n const edge: Edge> = { from: sentinel, label: 'left', to: this.root };\n const stack = rightmostStack({ value: edge });\n const value = stack.value.to?.value;\n\n // Remove the value\n const removed = remove(stack);\n\n // Update state\n this.root = sentinel.left;\n this.length -= +removed;\n return value;\n }\n\n shift(): T | undefined {\n // Find the minimum value\n const sentinel = { left: this.root } as AATreeNode;\n const edge: Edge> = { from: sentinel, label: 'left', to: this.root };\n const stack = leftmostStack({ value: edge });\n const value = stack.value.to?.value;\n\n // Remove the value\n const removed = remove(stack);\n\n // Update state\n this.root = sentinel.left;\n this.length -= +removed;\n return value;\n }\n\n get size(): number {\n return this.length;\n }\n\n *sorted(): Iterable {\n for (const node of inOrderTraverse(this.root)) {\n yield node.value;\n }\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (const node of preOrderTraverse(this.root)) {\n yield node.value;\n }\n }\n\n update(curElement: T, newElement: T): boolean {\n if (this.delete(curElement)) {\n this.add(newElement);\n return true;\n }\n return false;\n }\n\n protected build(obj: Iterable): void {\n if (isArray(obj)) {\n for (let i = 0; i < obj.length; ++i) {\n this.add(obj[i]);\n }\n } else if (obj instanceof AATree && this.compare === obj.compare) {\n this.root = clone(obj.root);\n this.length = obj.size;\n } else {\n for (const element of obj) {\n this.add(element);\n }\n }\n }\n}\n/**\n * @internal\n */\nexport function remove(stack: LinkedNode>>): boolean {\n let edge = stack.value;\n let node = edge.to;\n\n // If not found\n if (node == null) {\n return false;\n }\n\n // Remove the node\n stack = removeStack(stack);\n\n // Update the tree\n while (stack.next) {\n stack = stack.next;\n edge = stack.value;\n node = edge.to!;\n\n // Decrease levels\n const level = 1 + Math.min(node.left?.level ?? 0, node.right?.level ?? 0);\n if (level < node.level) {\n node.level = level;\n if (node.right != null && level < node.right.level) {\n node.right.level = level;\n }\n }\n\n // Balance\n node = skew(node);\n node.right = skew(node.right);\n if (node.right != null) {\n node.right.right = skew(node.right.right);\n }\n node = split(node);\n node.right = split(node.right);\n\n // Make the update\n edge.from![edge.label!] = edge.to = node;\n }\n\n return true;\n}\n/**\n * @internal\n */\nexport function skew(node?: undefined): undefined;\nexport function skew(node: AATreeNode): AATreeNode;\nexport function skew(node?: AATreeNode): AATreeNode | undefined;\nexport function skew(node?: AATreeNode): AATreeNode | undefined {\n if (node == null || node.left == null || node.level != node.left.level) {\n return node;\n }\n const left = node.left;\n node.left = left.right;\n left.right = node;\n return left;\n}\n/**\n * @internal\n */\nexport function split(node?: undefined): undefined;\nexport function split(node: AATreeNode): AATreeNode;\nexport function split(node?: AATreeNode): AATreeNode | undefined;\nexport function split(node?: AATreeNode): AATreeNode | undefined {\n if (\n node == null ||\n node.right == null ||\n node.right.right == null ||\n node.level != node.right.right.level\n ) {\n return node;\n }\n const right = node.right;\n node.right = right.left;\n right.left = node;\n ++right.level;\n return right;\n}\n","import { CompareFn } from 'src';\nimport { AVLTreeNode } from './avlTreeNode';\nimport {\n clone,\n search,\n Edge,\n inOrderTraverse,\n leftmost,\n leftmostStack,\n preOrderTraverse,\n rightmost,\n rightmostStack,\n searchStack,\n removeStack,\n} from './binaryTreeUtils';\nimport { SortedTree } from './sortedTree';\nimport { isArray } from 'src/collection/arrayUtils';\nimport { LinkedNode } from 'src/list';\n\n/**\n * An AVL tree is a self-balancing binary search tree ([source](https://en.wikipedia.org/wiki/AVL_tree)).\n *\n * It is named after inventors Georgy Adelson-Velsky and Evgenii Landis and was the first such\n * data structure to be invented. In an AVL tree, the heights of the two child\n * subtrees of any node differ by at most one; if at any time they differ by more\n * than one, rebalancing is done to restore this property.\n *\n * Lookup, insertion, and deletion all take O(log(n)) time in both the average and worst cases,\n * where n is the number of nodes in the tree prior to the operation. Insertions and deletions\n * may require the tree to be rebalanced by one or more tree rotations.\n *\n * AVL trees are often compared with red–black trees as both take O(log(n))\n * time for the basic operations. For lookup-intensive applications, AVL trees are\n * faster than red–black trees because they are more strictly balanced.\n * Similar to red–black trees, AVL trees are height-balanced.\n */\nexport class AVLTree implements SortedTree {\n /**\n * The function to determine the order of elements.\n */\n protected compare: CompareFn;\n /**\n * Indicates how to handle duplicates:\n * - < 0 : Add to left subtree\n * - = 0 : Do now allow duplicates\n * - > 0 : Add to right subtree\n */\n protected dupeWeight: number;\n /**\n * The number of elements in the list.\n */\n protected length: number;\n /**\n * The root of the tree.\n */\n protected root: AVLTreeNode;\n /**\n * Instantiate a tree.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param elements - A set of elements to initialize the tree with.\n */\n constructor(compareFn: CompareFn, elements?: Iterable);\n /**\n * Instantiate a tree.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param allowDuplicates - Whether to allow duplicates\n * @param elements - A set of elements to initialize the tree with.\n */\n constructor(compareFn: CompareFn, allowDuplicates: boolean, elements?: Iterable);\n constructor(\n compareFn: CompareFn,\n allowDuplicates?: boolean | Iterable,\n elements?: Iterable,\n ) {\n if (typeof allowDuplicates !== 'boolean') {\n elements = allowDuplicates;\n allowDuplicates = true;\n }\n this.compare = compareFn;\n this.dupeWeight = +allowDuplicates;\n this.length = 0;\n this.root = {} as AVLTreeNode;\n this.build(elements ?? []);\n }\n\n add(element: T): this {\n // Find the element\n let edge: Edge> = { from: this.root, label: 'left', to: this.root.left };\n let stack = searchStack(element, { value: edge }, this.compare, this.dupeWeight);\n\n // If element already exists\n if (stack.value.to != null) {\n return this;\n }\n\n // Add element\n edge = stack.value;\n let label = edge.label;\n edge.from![label!] = { balanceFactor: 0, value: element };\n\n // Balance the tree\n while (stack.next) {\n stack = stack.next;\n edge = stack.value;\n edge.to!.balanceFactor += label === 'left' ? -1 : 1;\n edge.to = balance(edge.to!);\n edge.from![(label = edge.label!)] = edge.to;\n if (edge.to!.balanceFactor === 0) {\n break;\n }\n }\n\n // Update state\n ++this.length;\n return this;\n }\n\n clear(): void {\n this.root.left = undefined;\n this.length = 0;\n }\n\n comparator(): CompareFn {\n return this.compare;\n }\n\n delete(element: T): boolean {\n // Remove the element if found\n const edge: Edge> = { from: this.root, label: 'left', to: this.root.left };\n const stack = searchStack(element, { value: edge }, this.compare, 0);\n const removed = remove(stack);\n\n // Update state\n this.length -= +removed;\n return removed;\n }\n\n has(element: T): boolean {\n return search(element, this.root.left, this.compare) != null;\n }\n\n max(): T | undefined {\n return rightmost(this.root.left)?.value;\n }\n\n min(): T | undefined {\n return leftmost(this.root.left)?.value;\n }\n\n pop(): T | undefined {\n // Find the maximum value\n const edge: Edge> = { from: this.root, label: 'left', to: this.root.left };\n const stack = rightmostStack({ value: edge });\n const value = stack.value.to?.value;\n\n // Remove the value\n const removed = remove(stack);\n\n // Update state\n this.length -= +removed;\n return value;\n }\n\n shift(): T | undefined {\n // Find the minimum value\n const edge: Edge> = { from: this.root, label: 'left', to: this.root.left };\n const stack = leftmostStack({ value: edge });\n const value = stack.value.to?.value;\n\n // Remove the value\n const removed = remove(stack);\n\n // Update state\n this.length -= +removed;\n return value;\n }\n\n get size(): number {\n return this.length;\n }\n\n *sorted(): Iterable {\n for (const node of inOrderTraverse(this.root.left)) {\n yield node.value;\n }\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (const node of preOrderTraverse(this.root.left)) {\n yield node.value;\n }\n }\n\n update(curElement: T, newElement: T): boolean {\n if (this.delete(curElement)) {\n this.add(newElement);\n return true;\n }\n return false;\n }\n\n protected build(obj: Iterable): void {\n if (isArray(obj)) {\n for (let i = 0; i < obj.length; ++i) {\n this.add(obj[i]);\n }\n } else if (obj instanceof AVLTree && this.compare === obj.compare) {\n this.root = clone(obj.root);\n this.length = obj.size;\n } else {\n for (const element of obj) {\n this.add(element);\n }\n }\n }\n}\n/**\n * @internal\n */\nexport function balance(node: AVLTreeNode): AVLTreeNode {\n if (node.balanceFactor > 1) {\n if (node.right!.balanceFactor < 0) {\n node.right = rotateR(node.right!);\n }\n node = rotateL(node);\n } else if (node.balanceFactor < -1) {\n if (node.left!.balanceFactor > 0) {\n node.left = rotateL(node.left!);\n }\n node = rotateR(node);\n }\n return node;\n}\n/**\n * @internal\n */\nexport function remove(stack: LinkedNode>>): boolean {\n let edge = stack.value;\n const node = edge.to;\n\n // If not found\n if (node == null) {\n return false;\n }\n\n // Remove the node\n stack = removeStack(stack);\n\n // Balance the tree\n let label = stack.value.label;\n while (stack.next) {\n stack = stack.next;\n edge = stack.value;\n edge.to!.balanceFactor -= label === 'left' ? -1 : 1;\n edge.to = balance(edge.to!);\n edge.from![(label = edge.label)!] = edge.to;\n if (edge.to!.balanceFactor !== 0) {\n break;\n }\n }\n\n return true;\n}\n/**\n * @internal\n */\nexport function rotateL(P: AVLTreeNode): AVLTreeNode {\n const R = P.right!;\n P.right = R.left;\n R.left = P;\n P.balanceFactor -= 1 + Math.max(0, R.balanceFactor);\n R.balanceFactor -= 1 - Math.min(0, P.balanceFactor);\n return R;\n}\n/**\n * @internal\n */\nexport function rotateR(P: AVLTreeNode): AVLTreeNode {\n const L = P.left!;\n P.left = L.right;\n L.right = P;\n P.balanceFactor += 1 - Math.min(0, L.balanceFactor);\n L.balanceFactor += 1 + Math.max(0, P.balanceFactor);\n return L;\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Dastal/webpack/universalModuleDefinition","webpack://Dastal/webpack/bootstrap","webpack://Dastal/webpack/runtime/define property getters","webpack://Dastal/webpack/runtime/hasOwnProperty shorthand","webpack://Dastal/webpack/runtime/make namespace object","webpack://Dastal/./src/collection/iteratorUtils.ts","webpack://Dastal/./src/math/numberUtils.ts","webpack://Dastal/./src/collection/arrayUtils.ts","webpack://Dastal/./src/collection/stringUtils.ts","webpack://Dastal/./src/collection/index.ts","webpack://Dastal/./src/heap/utils.ts","webpack://Dastal/./src/heap/binaryHeap.ts","webpack://Dastal/./src/tree/binaryTreeUtils.ts","webpack://Dastal/./src/heap/skewHeap.ts","webpack://Dastal/./src/list/arrayList.ts","webpack://Dastal/./src/list/utils.ts","webpack://Dastal/./src/list/doublyLinkedList.ts","webpack://Dastal/./src/list/linkedList.ts","webpack://Dastal/./src/math/u32.ts","webpack://Dastal/./src/queue/arrayQueue.ts","webpack://Dastal/./src/queue/linkedQueue.ts","webpack://Dastal/./src/segmentTree/inOrderSegmentTree.ts","webpack://Dastal/./src/segmentTree/levelOrderSegmentTree.ts","webpack://Dastal/./src/stack/arrayStack.ts","webpack://Dastal/./src/stack/linkedStack.ts","webpack://Dastal/./src/tree/aaTree.ts","webpack://Dastal/./src/tree/avlTree.ts"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","always","fn","next","done","fill","length","undefined","first","n","iterator","res","join","iterators","res2","never","once","skip","bind","split","iter","clamp","num","min","max","Math","wrapLeft","wrapRight","wrap","MAX_ARRAY_LENGTH","MAX_SAFE_ARGUMENT_LENGTH","isArray","Array","isTypedArray","TypedArray","getPrototypeOf","Uint8Array","splice","array","start","count","elements","maxStepSize","stepSize","maxElems","out","RangeError","pad","str","maxLen","fillString","len","diff","padStart","padEnd","isCollection","bubbleUp","index","compareFn","parentIndex","floor","parent","heapify","i","sinkDown","childIndex","child","skewMerge","heaps","lists","push","list","tree","right","compare","a","b","tail","pop","mergeKSorted","heap","node","left","BinaryHeap","this","addAll","element","indexOf","last","size","curElement","newElement","inOrderTraverse","preOrderTraverse","removeStack","stack","dir","edge","to","temp","successorStack","predecessorStack","from","label","clone","assign","leftmost","leftmostStack","rightmostStack","rightmost","search","comp","searchStack","dupeWeight","paths","toBinaryTree","nodes","par","SkewHeap","merge","comparator","ArrayList","copyWithin","callback","prev","shift","slice","sort","unshift","arguments","linkedMergeSort","isDoubly","lens","ceil","heads","tails","linkedMergeSorted","DoublyLinkedList","_addAll","_get","nodeA","nodeB","head","view","LinkedList","_copyWithin","nodeC","nodeD","remove","deleted","newTail","add","bitsSet","invert","msp","u32","isPow2","lsb","lsp","lsps","msb","msps","reverse","ArrayQueue","LinkedQueue","clear","InOrderSegmentTree","combine","build","mask","MAX_SIZE","set","offset","operation","dc","dp","LevelOrderSegmentTree","level","shrink","grow","aggregate","cap","log2","ArrayStack","LinkedStack","AATree","allowDuplicates","sentinel","skew","removed","delete","AVLTree","balanceFactor","balance","rotateR","rotateL","P","R","L"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,SAAU,GAAIH,GACK,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,M,mBCTA,IAAIC,EAAsB,CCA1B,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3E,EAAwB,CAACM,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClF,EAAyBd,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,M,muBCFhD,SAASC,EAAgBC,GAC5B,MAAO,CAAEC,KAAM,iBAAO,CAAEC,MAAM,EAAOJ,MAAOE,OAKzC,SAASG,EAAcC,EAAgBJ,GAC1C,MAAO,CACHC,KAAM,WACF,OAAIG,EAAS,EACF,CAAEF,MAAM,EAAMJ,WAAOO,MAE9BD,EACK,CAAEF,MAAM,EAAOJ,MAAOE,QAYlC,SAASM,EAAeC,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BQ,EAAOkH,GAAQlH,IACRA,EAAK+G,eAAiB,IACzB/G,EAAKC,KAAM8G,cAAgB,IAC3B/G,EAAKC,KAAOiH,GAAQlH,EAAKC,OAE7BD,EAAOiH,GAAQjH,IAEZA,EAKJ,SAASmE,GAAUrD,GACtB,IAAIE,EAAOF,EAAM/F,MAIjB,GAAY,MAHCiG,EAAKC,GAId,OAAO,EAQX,IADA,IAAIK,GAHJR,EAAQD,EAAYC,IAGF/F,MAAMuG,MACjBR,EAAM5F,QAET8F,GADAF,EAAQA,EAAM5F,MACDH,OACRkG,GAAI8F,eAA2B,SAAVzF,GAAoB,EAAI,EAClDN,EAAKC,GAAK+F,GAAQhG,EAAKC,IACvBD,EAAKK,KAAOC,EAAQN,EAAKM,OAAWN,EAAKC,GACV,IAA3BD,EAAKC,GAAI8F,iBAKjB,OAAO,EAKJ,SAASG,GAAWC,GACvB,IAAMC,EAAID,EAAE3H,MAKZ,OAJA2H,EAAE3H,MAAQ4H,EAAEnH,KACZmH,EAAEnH,KAAOkH,EACTA,EAAEJ,eAAiB,EAAIvK,KAAKD,IAAI,EAAG6K,EAAEL,eACrCK,EAAEL,eAAiB,EAAIvK,KAAKF,IAAI,EAAG6K,EAAEJ,eAC9BK,EAKJ,SAASH,GAAWE,GACvB,IAAME,EAAIF,EAAElH,KAKZ,OAJAkH,EAAElH,KAAOoH,EAAE7H,MACX6H,EAAE7H,MAAQ2H,EACVA,EAAEJ,eAAiB,EAAIvK,KAAKF,IAAI,EAAG+K,EAAEN,eACrCM,EAAEN,eAAiB,EAAIvK,KAAKD,IAAI,EAAG4K,EAAEJ,eAC9BM,E","file":"dastal.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Dastal\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Dastal\"] = factory();\n\telse\n\t\troot[\"Dastal\"] = factory();\n})(self, function() {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Get an iterator that always returns a given value.\n */\nexport function always(fn: () => T): Iterator {\n return { next: () => ({ done: false, value: fn() }) };\n}\n/**\n * Get an iterator that returns a value a given amount of times.\n */\nexport function fill(length: number, fn: () => T): Iterator {\n return {\n next: () => {\n if (length < 1) {\n return { done: true, value: undefined };\n }\n --length;\n return { done: false, value: fn() };\n },\n };\n}\n/**\n * Iterate through the first num elements of an iterator.\n *\n * @param n - The number of elements to iterate.\n * @param iterator - The iterator.\n *\n * @returns - An iterator limited to the next n elements.\n */\nexport function first(n: number, iterator: Iterator): Iterator {\n return {\n next: () => {\n if (n < 1) {\n return { done: true, value: undefined };\n }\n const res = iterator.next();\n n = res.done ? 0 : n - 1;\n return res;\n },\n };\n}\n/**\n * Join multiple iterators into one.\n *\n * @param iterators - The iterators to join.\n */\nexport function join(iterators: Iterator>): Iterator {\n let iterator: Iterator | undefined = { next: () => ({ done: true, value: undefined }) };\n return {\n next: () => {\n if (iterator == null) {\n return { done: true, value: undefined };\n }\n let res = iterator.next();\n while (res.done) {\n const res2 = iterators.next();\n if (res2.done) {\n iterator = undefined;\n return { done: true, value: undefined };\n }\n iterator = res2.value;\n res = iterator.next();\n }\n return res;\n },\n };\n}\n/**\n * Get an empty iterator.\n */\nexport function never(): Iterator {\n return { next: () => ({ done: true, value: undefined }) };\n}\n/**\n * Wrap a value in an iterator.\n */\nexport function once(fn: () => T): Iterator {\n let done = false;\n return {\n next: () => {\n const res = { done, value: fn() };\n done = true;\n fn = () => undefined!;\n return res;\n },\n };\n}\n/**\n * Skip the next num elements of an iterator.\n *\n * @param n - The number of elements to skip.\n * @param iterator - The iterator.\n *\n * @returns - The iterator after skipping n elements.\n */\nexport function skip(n: number, iterator: Iterator): Iterator {\n let fn = () => {\n let res: IteratorResult = { done: false, value: undefined! };\n while (n-- > 0 && !res.done) {\n res = iterator.next();\n }\n fn = iterator.next.bind(iterator);\n return res;\n };\n return { next: () => fn() };\n}\n/**\n * Split an iterator into multiple iterators of a given length.\n *\n * @param length - The length of each iterator.\n * @param iterator - The iterator to split.\n *\n * @returns - An iterator of the resulting iterators.\n */\nexport function split(length: number, iterator: Iterator): Iterator> {\n if (length < 1) {\n return { next: () => ({ done: true, value: undefined }) };\n }\n let done = false;\n return {\n next: () => {\n if (done) {\n return { done, value: undefined };\n }\n const iter = first(length, iterator);\n const res = iter.next();\n if (res.done) {\n done = true;\n return { done, value: undefined };\n }\n return { done, value: join([once(() => res.value), iter][Symbol.iterator]()) };\n },\n };\n}\n","/**\n * Limits a number to be within a given range.\n *\n * f(x, min, max) = y, where min <= y <= max\n *\n * @param num - The number to clamp\n * @param min - The minimum result value, inclusive\n * @param max - The maximum result value, inclusive\n *\n * @returns The clamped number\n */\nexport function clamp(num: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, num));\n}\n/**\n * Wraps a number if below a given range\n *\n * f(x, min, max) = {\n * x, where x >= min\n * max - (min - x), where x < min\n * }\n *\n * @param num - The number to wrap\n * @param min - The minimum result value, inclusive\n * @param max - The maximum result value, inclusive\n *\n * @returns - The wrapped number\n */\nexport function wrapLeft(num: number, min: number, max: number): number {\n return num < min ? max - min + num : num;\n}\n/**\n * Wraps a number if above a given range\n *\n * f(x, min, max) = {\n * x, where x <= max\n * min + (x - max), where x > max\n * }\n *\n * @param num - The number to wrap\n * @param min - The minimum result value, inclusive\n * @param max - The maximum result value, inclusive\n *\n * @returns - The wrapped number\n */\nexport function wrapRight(num: number, min: number, max: number): number {\n return num > max ? min + (num - max) : num;\n}\n/**\n * Wraps a number if outside a given range\n *\n * @param num - The number to wrap\n * @param min - The minimum result value, inclusive\n * @param max - The maximum result value, inclusive\n *\n * @returns - The wrapped number\n */\nexport function wrap(num: number, min: number, max: number): number {\n return num < min ? max - min + num : wrapRight(num, min, max);\n}\n","import { first } from 'src/collection/iteratorUtils';\nimport { clamp, wrapLeft } from 'src/math/numberUtils';\n\n/**\n * The maximum length of an array.\n *\n * According to the [ECMA-262](https://tc39.es/ecma262/#array-index):\n * 0 <= array.length <= 2^32 - 1\n *\n * If this value should be updated, please\n * submit a pull request with details supporting a new max length.\n */\nexport const MAX_ARRAY_LENGTH = 4294967295;\n/**\n * The maximum number of arguments that can be safely accepted by a function.\n *\n * According to the [ECMA-262](https://tc39.es/ecma262/#sec-list-and-record-specification-type), there is no maximum. In practice, different\n * environments impose their own limit ([source](https://stackoverflow.com/questions/22747068/is-there-a-max-number-of-arguments-javascript-functions-can-accept)).\n *\n * This value was chosen through research, local testing and iteration. The actual number of arguments\n * accepted in an environment may be larger but hopefully not smaller. If errors are raised,\n * please submit a bug with your environment details and a new max length.\n */\nexport const MAX_SAFE_ARGUMENT_LENGTH = 32767;\n/**\n * Check if a value is an Array or TypedArray.\n *\n * @param obj - The value to check.\n *\n * @returns `true` if an Array or TypedArray, otherwise `false`.\n */\nexport function isArray(obj: unknown): obj is T[] {\n return obj instanceof Array || isTypedArray(obj);\n}\n/**\n * Check if a value is a TypedArray.\n *\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)\n * for more details.\n *\n * @param obj - The value to check.\n *\n * @returns `true` if a TypedArray, otherwise `false`.\n */\nexport const isTypedArray = (() => {\n const TypedArray = Object.getPrototypeOf(Uint8Array);\n return function isTypedArray(obj: unknown): obj is T[] {\n return obj instanceof TypedArray;\n };\n})();\n/**\n * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.\n *\n * Contrary to Array.splice, this will not throw an error if too many new elements are given as arguments.\n *\n * @param array - The array to splice.\n * @param start - The zero-based location in the array from which to start removing elements.\n * @param count - The number of elements to remove.\n * @param elements - The new elements to splice in.\n *\n * @returns - An array containing the elements that were deleted.\n */\nexport function splice(array: T[], start?: number, count?: number, elements?: Iterable): T[] {\n start = clamp(wrapLeft(start ?? 0, 0, array.length), 0, array.length);\n count = clamp(count ?? array.length, 0, array.length - start);\n\n // Base case\n if (elements == null) {\n return array.splice(start, count);\n }\n\n const maxStepSize = MAX_SAFE_ARGUMENT_LENGTH - 2;\n const iterator = elements[Symbol.iterator]();\n\n // Perform the initial splice\n let stepSize = array.length - count;\n const maxElems = MAX_ARRAY_LENGTH - stepSize;\n let n = Math.min(maxStepSize, maxElems);\n const out = array.splice(start, count, ...{ [Symbol.iterator]: () => first(n, iterator) });\n stepSize = array.length - stepSize;\n start += stepSize;\n\n // Splice in new elements as long as there is space in the array\n for (n = maxElems - stepSize; n >= maxStepSize && stepSize >= maxStepSize; n -= stepSize) {\n stepSize = array.length;\n array.splice(start, 0, ...{ [Symbol.iterator]: () => first(maxStepSize, iterator) });\n stepSize = array.length - stepSize;\n start += stepSize;\n }\n if (n > 0 && stepSize >= maxStepSize) {\n array.splice(start, 0, ...{ [Symbol.iterator]: () => first(n, iterator) });\n }\n\n // If maximum array capacity reached\n if (iterator.next().done != true) {\n throw new RangeError('Invalid array length');\n }\n\n return out;\n}\n","/**\n * Pad a string from both sides.\n */\nexport function pad(str: string, maxLen: number, fillString: string): string {\n const len = str.length;\n if (len >= maxLen) {\n return str;\n }\n const diff = maxLen - len;\n return str.padStart(len + diff / 2, fillString).padEnd(len + diff, fillString);\n}\n","import { Collection } from './collection';\n\nexport * as ArrayUtils from './arrayUtils';\nexport * from './collection';\nexport * as IteratorUtils from './iteratorUtils';\nexport * as StringUtils from './stringUtils';\n\n/**\n * Check if a value is a {@link Collection}.\n *\n * @param obj - The value to check.\n *\n * @returns - `true` if obj is a Collection, `false` otherwise.\n */\nexport function isCollection(obj: any): obj is Collection {\n return (\n obj != null && typeof obj['size'] === 'number' && typeof obj[Symbol.iterator] === 'function'\n );\n}\n","import { LinkedNode } from 'src/list';\nimport { BinaryTreeNode } from 'src/tree/binaryTreeNode';\nimport { CompareFn } from '..';\n\n/**\n * @internal\n */\nexport function bubbleUp(index: number, compareFn: CompareFn, array: Array): void {\n const value = array[index];\n\n // Until we reach the top of the heap\n while (index > 0) {\n // Get the parent\n const parentIndex = Math.floor((index + 1) / 2) - 1;\n const parent = array[parentIndex]!;\n\n // If the parent is above or equal to value, the heap is in order\n if (compareFn(parent, value) <= 0) {\n break;\n }\n\n // Swap the parent with value and continue\n array[parentIndex] = value;\n array[index] = parent;\n index = parentIndex;\n }\n}\n/**\n * @internal\n */\nexport function heapify(compareFn: CompareFn, array: T[]): void {\n for (let i = (array.length + 1) >>> 1; i > 0; sinkDown(--i, compareFn, array)) {}\n}\n/**\n * @internal\n */\nexport function mergeKSorted(compareFn: CompareFn, lists: LinkedNode[]): LinkedNode {\n // Heapify the list of lists based on\n // the value at the head of each list.\n const compare: CompareFn> = (a, b) => compareFn(a.value, b.value);\n heapify(compare, lists);\n\n // Combine the lists into a single list.\n const list: LinkedNode = lists[0];\n for (let tail = list; lists.length > 1; tail = tail.next) {\n lists[0] = lists[0].next ?? lists.pop()!;\n sinkDown(0, compare, lists);\n tail.next = lists[0];\n }\n\n return list;\n}\n/**\n * @internal\n */\nexport function sinkDown(index: number, compareFn: CompareFn, array: Array): void {\n const n = array.length;\n const value = array[index];\n do {\n // Compute the left child's index\n let childIndex = 2 * index + 1;\n\n // If no children exist\n if (childIndex >= n) {\n break;\n }\n\n // Decide which child to compare with\n let child = array[childIndex];\n if (childIndex + 1 < n && compareFn(array[childIndex + 1], child) <= 0) {\n child = array[++childIndex]!;\n }\n\n // If value <= child\n if (compareFn(value, child) <= 0) {\n break;\n }\n\n // Swap value and child\n array[index] = child;\n array[childIndex] = value;\n index = childIndex;\n } while (true);\n}\n/**\n * See: https://en.wikipedia.org/wiki/Skew_heap#Merging_two_heaps\n *\n * @param compareFn - A function used to determine the order of the heap.\n *\n * It is expected to return:\n * - A negative value if first argument < second argument\n * - Zero if first argument == second argument\n * - A positive value if first argument > second argument\n * @param heaps - An iterable of heaps to merge\n *\n * @returns The new heap\n */\nexport function skewMerge(\n compareFn: CompareFn,\n heaps: (BinaryTreeNode | undefined)[],\n): BinaryTreeNode | undefined {\n // Remove undefineds and initialize a list for each heap\n const lists: LinkedNode>[] = [];\n for (let i = 0; i < heaps.length; ++i) {\n if (heaps[i] != null) {\n lists.push({ value: heaps[i]! });\n }\n }\n\n // Check if nothing to merge with\n if (lists.length < 2) {\n return lists[0]?.value;\n }\n\n // Split each heap into subheaps by cutting every right path; From the root\n // node, sever the right node to make the right child its own heap. Repeat\n // until you can't go right. This will turn each heap into a list of heaps\n // where the root either only has a left child or no children at all. The\n // lists of heaps will be in desc order (from bottom to top).\n for (let i = 0; i < lists.length; ++i) {\n let list = lists[i];\n let tree: BinaryTreeNode | undefined = list.value;\n while ((tree = tree.right)) {\n list = { next: list, value: tree };\n }\n lists[i] = list;\n }\n\n // Combine the lists into a single list in desc order\n let list: LinkedNode> | undefined = mergeKSorted(\n (a, b) => compareFn(b.value, a.value),\n lists,\n );\n\n // While there are still multiple heaps, iteratively combine\n // the first two (from left to right). If the root of the second-to-first\n // subtree has a left child, swap it to be the right child. Link the root\n // of the last subtree as the left child of the second-to-first subtree.\n let heap = list.value;\n while ((list = list.next)) {\n const node = list.value;\n node.right = node.left;\n node.left = heap;\n heap = node;\n }\n\n return heap;\n}\n","import { isArray, MAX_ARRAY_LENGTH } from 'src/collection/arrayUtils';\nimport { CompareFn } from '..';\nimport { Heap } from './heap';\nimport { bubbleUp, heapify, sinkDown } from './utils';\n\n/**\n * A binary heap is a heap implemented as a binary tree with an additional shape property\n * ([source](https://en.wikipedia.org/wiki/Binary_heap)).\n *\n * **Shape property**: Must be a complete binary tree. This means all levels of the tree\n * (except possibly the last one) are fully filled. If the last level of the tree is incomplete,\n * the nodes of that level are filled from left to right.\n *\n * #### Complexity\n *\n * | Property | Average | Worst |\n * | :------- | :------ | :---- |\n * | Space | O(n) | O(n)\n * | Push | O(1) | O(log n)\n * | Peek | O(1)\t| O(1)\n * | Pop | O(log n)| O(log n)\n * | Search | O(n) | O(n)\n */\nexport class BinaryHeap implements Heap {\n /**\n * The array containing every element.\n */\n protected array: T[];\n /**\n * The function to determine the order of elements.\n */\n protected compare: CompareFn;\n /**\n * Instantiate a heap.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param elements - A set of elements to initialize the list with.\n */\n constructor(compareFn: CompareFn, elements?: Iterable) {\n this.compare = compareFn;\n this.array = [];\n this.addAll(elements ?? []);\n }\n\n addAll(elements: Iterable): number {\n const array = this.array;\n const length = array.length;\n\n if (isArray(elements)) {\n if (array.length + elements.length > MAX_ARRAY_LENGTH) {\n throw new RangeError('Invalid heap length');\n }\n for (let i = 0; i < elements.length; ++i) {\n array.push(elements[i]);\n }\n } else {\n for (const element of elements) {\n if (array.length >= MAX_ARRAY_LENGTH) {\n throw new RangeError('Invalid heap length');\n }\n array.push(element);\n }\n }\n\n // Update the heap\n if (length < array.length) {\n heapify(this.compare, array);\n }\n\n return array.length;\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n comparator(): CompareFn {\n return this.compare;\n }\n\n contains(element: T): boolean {\n return this.array.indexOf(element) >= 0;\n }\n\n delete(element: T): boolean {\n const index = this.array.indexOf(element);\n if (index < 0) {\n return false;\n }\n\n // If deleting the last value\n const last = this.array.pop()!;\n if (index >= this.array.length) {\n return true;\n }\n\n // Add the last value to the\n // deleted index and update the heap\n this.array[index] = last;\n sinkDown(index, this.compare, this.array);\n bubbleUp(index, this.compare, this.array);\n return true;\n }\n\n merge(heap: Heap): this {\n const array = this.array;\n\n if (heap.size < 1) {\n return this;\n }\n\n if (array.length + heap.size > MAX_ARRAY_LENGTH) {\n throw new RangeError('Invalid heap length');\n }\n\n for (const element of heap) {\n array.push(element);\n }\n\n heapify(this.compare, array);\n return this;\n }\n\n peek(): T | undefined {\n return this.array.length > 0 ? this.array[0] : undefined;\n }\n\n pop(): T | undefined {\n if (this.array.length < 1) {\n return undefined;\n }\n\n // Get the root and the last value\n const value = this.array[0];\n const last = this.array.pop();\n\n // If value != last\n if (this.array.length > 0) {\n // Move the last value to the root and update the heap\n this.array[0] = last!;\n sinkDown(0, this.compare, this.array);\n }\n\n return value;\n }\n\n push(value: T): number {\n // Add new value to the end of the heap\n this.array.push(value);\n\n // Update the heap\n bubbleUp(this.array.length - 1, this.compare, this.array);\n return this.size;\n }\n\n pushPop(value: T): T {\n // If empty or value is <= to root\n if (this.array.length < 1 || this.compare(value, this.array[0]) <= 0) {\n return value;\n }\n\n // Swap the root and value\n const root = this.array[0];\n this.array[0] = value;\n sinkDown(0, this.compare, this.array);\n return root;\n }\n\n replace(value: T): T | undefined {\n // If empty\n if (this.array.length < 1) {\n this.array.push(value);\n return undefined;\n }\n\n // Swap the root with value\n const root = this.array[0];\n this.array[0] = value;\n value = root;\n\n // Update the heap\n sinkDown(0, this.compare, this.array);\n return value;\n }\n\n get size(): number {\n return this.array.length;\n }\n\n *sorted(): Iterable {\n if (this.array.length < 1) {\n return;\n }\n const array = this.array;\n const heap = new BinaryHeap((a, b) => this.compare(array[a], array[b]), [0]);\n do {\n let index = heap.pop()!;\n if (index < array.length) {\n yield array[index];\n index = 2 * index + 1;\n index < array.length && heap.push(index);\n ++index < array.length && heap.push(index);\n }\n } while (heap.size > 0);\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n [Symbol.iterator](): Iterator {\n return this.array[Symbol.iterator]();\n }\n\n update(curElement: T, newElement: T): boolean {\n const index = this.array.indexOf(curElement);\n if (index < 0) {\n return false;\n }\n this.array[index] = newElement;\n sinkDown(index, this.compare, this.array);\n bubbleUp(index, this.compare, this.array);\n return true;\n }\n}\n","import { pad } from 'src/collection/stringUtils';\nimport { LinkedNode } from 'src/list';\nimport { CompareFn } from '..';\nimport { BinaryTreeNode } from './binaryTreeNode';\n\n/**\n * @internal\n */\nexport interface Edge> {\n label?: 'left' | 'right';\n from?: Node;\n to?: Node;\n}\n/**\n * [source](https://stackoverflow.com/questions/51419176/how-to-get-a-subset-of-keyof-t-whose-value-tk-are-callable-functions-in-typ)\n * \n * @internal\n *\nexport type KeyOfType = {[K in keyof T]: T[K] extends U ? K: never}[keyof T];\n*/\n/**\n * @internal\n */\nexport function debug, T = any>(\n root: N | undefined,\n mapFn?: (node: N) => any,\n): void {\n mapFn = mapFn == null ? (n) => n.value : mapFn;\n\n // Turn the tree into an array in level-order\n const array: string[] = [];\n for (const node of levelOrderTraverse(root, true)) {\n array.push(node ? `${mapFn(node)}` : '?');\n }\n\n // If empty\n if (array.length < 1) {\n console.log('\\n');\n return;\n }\n\n // Find the longest value string\n const lenV = array.reduce((p, c) => Math.max(p, c.length), 0);\n\n // Pad each value\n for (let i = 0; i < array.length; ++i) {\n array[i] = pad(array[i], lenV, ' ');\n }\n\n // Split values into levels\n const levels = [];\n for (let n = 1; array.length > 0; n *= 2) {\n levels.push(array.splice(0, n));\n }\n\n // Initialize formatting variables\n let branch = '_'.repeat(1 + lenV / 2);\n let offset = '';\n const offsetOffset = ' '.repeat(branch.length);\n let separator = ' '.repeat(1 + ((lenV - 1) & 1));\n const separatorOffset = ' '.repeat(lenV);\n\n // Build the last level\n array.length = levels.length;\n array[array.length - 1] = levels.pop()!.join(separator);\n\n // Build remaining levels in reverse\n for (let n = levels.length - 1; n >= 0; --n) {\n const level = levels.pop()!;\n for (let j = 0; j < level.length; ++j) {\n level[j] = branch + level[j] + branch;\n }\n array[n] = offset + level.join(separator);\n branch += branch;\n offset += offset + offsetOffset;\n separator += separator + separatorOffset;\n }\n\n // Output\n console.log(array.join('\\n'), '\\n');\n}\n/**\n * @internal\n */\nexport function removeStack>(\n stack: LinkedNode>,\n dir = true,\n): LinkedNode> {\n let edge = stack.value;\n let node = edge.to;\n\n // Input check\n if (node == null) {\n return stack;\n }\n\n // Find the replacement\n if (node.right == null) {\n // If no right child, replace with left\n node = node.left;\n } else if (node.left == null) {\n // If no left child, replace with right\n node = node.right;\n } else if (dir) {\n // Replace with the successor\n stack = successorStack(stack);\n edge = stack.value;\n const temp = edge.to!;\n node.value = temp.value;\n node = temp.right;\n } else {\n // Replace with the predecessor\n stack = predecessorStack(stack);\n edge = stack.value;\n const temp = edge.to!;\n node.value = temp.value;\n node = temp.left;\n }\n\n // Make the replacement / update the tree\n edge.to = node;\n if (edge.from) {\n edge.from[edge.label!] = edge.to = node;\n }\n\n return stack;\n}\n/**\n * @internal\n */\nexport function clone>(node: undefined): undefined;\nexport function clone>(node: Node): Node;\nexport function clone>(node: Node | undefined): Node | undefined;\nexport function clone>(node: Node | undefined): Node | undefined {\n if (node == null) {\n return undefined;\n }\n const out: Node = Object.assign({}, node);\n let stack: LinkedNode | undefined = { value: out };\n do {\n node = stack.value;\n stack = stack.next;\n if (node.left) {\n stack = { next: stack, value: (node.left = Object.assign({}, node.left)) };\n }\n if (node.right) {\n stack = { next: stack, value: (node.right = Object.assign({}, node.right)) };\n }\n } while (stack);\n return out;\n}\n/**\n * @internal\n */\nexport function leftmost>(node: undefined): undefined;\nexport function leftmost>(node: Node): Node;\nexport function leftmost>(\n node: Node | undefined,\n): Node | undefined;\nexport function leftmost>(\n node: Node | undefined,\n): Node | undefined {\n if (node == null) {\n return undefined;\n }\n while (node.left) {\n node = node.left;\n }\n return node;\n}\n/**\n * @internal\n */\nexport function leftmostStack>(\n stack: LinkedNode>,\n): LinkedNode> {\n let node = stack.value.to;\n if (node == null) {\n return stack;\n }\n while (node.left) {\n stack = { next: stack, value: { label: 'left', from: node, to: node.left } };\n node = node.left;\n }\n return stack;\n}\n/**\n * @internal\n */\nexport function* inOrderTraverse>(\n node: Node | undefined,\n): Generator {\n let stack: LinkedNode | undefined = undefined;\n\n while (node) {\n stack = { next: stack, value: node };\n node = node.left;\n }\n\n while (stack) {\n node = stack.value;\n stack = stack.next;\n yield node;\n node = node.right;\n while (node) {\n stack = { next: stack, value: node };\n node = node.left;\n }\n }\n}\n/**\n * @internal\n */\nexport function levelOrderTraverse>(\n node: Node | undefined,\n padded?: false,\n): Generator;\nexport function levelOrderTraverse>(\n node: Node | undefined,\n padded: true,\n): Generator;\nexport function* levelOrderTraverse>(\n node: Node | undefined,\n padded = false,\n): Generator {\n const nil = {} as LinkedNode;\n let head: LinkedNode = { value: node };\n let tail = head;\n for (let cont = node != null; cont; head = head.next!) {\n tail = tail.next = nil;\n for (cont = false; head !== nil; head = head.next!) {\n node = head.value;\n if (node) {\n yield node;\n cont ||= node.left != null || node.right != null;\n tail = tail.next = { value: node.left };\n tail = tail.next = { value: node.right };\n } else if (padded) {\n yield undefined;\n tail = tail.next = { value: undefined };\n tail = tail.next = { value: undefined };\n }\n }\n }\n}\n/**\n * @internal\n */\nexport function* postOrderTraverse>(\n node: Node | undefined,\n): Generator {\n interface Meta {\n seen: boolean;\n node?: Node;\n }\n let stack: LinkedNode | undefined = { value: { seen: false, node } };\n do {\n const meta = stack.value;\n stack = stack.next;\n if (meta.node) {\n if (meta.seen) {\n yield meta.node;\n } else {\n meta.seen = true;\n stack = { next: stack, value: meta };\n stack = { next: stack, value: { seen: false, node: meta.node.right } };\n stack = { next: stack, value: { seen: false, node: meta.node.left } };\n }\n }\n } while (stack);\n}\n/**\n * @internal\n */\nexport function predecessor>(\n node: Node | undefined,\n): Node | undefined {\n return node == null ? undefined : rightmost(node.left);\n}\n/**\n * @internal\n */\nexport function predecessorStack>(\n stack: LinkedNode>,\n): LinkedNode> {\n const node = stack.value.to;\n if (node == null) {\n return stack;\n }\n stack = { next: stack, value: { label: 'left', from: node, to: node.left } };\n return rightmostStack(stack);\n}\n/**\n * @internal\n */\nexport function* preOrderTraverse>(\n node: Node | undefined,\n): Generator {\n let stack: LinkedNode | undefined = { value: node };\n do {\n node = stack.value;\n stack = stack.next;\n if (node) {\n yield node;\n stack = { next: stack, value: node.right };\n stack = { next: stack, value: node.left };\n }\n } while (stack);\n}\n/**\n * @internal\n */\nexport function reverse>(root?: Node): void {\n if (root == null) {\n return;\n }\n for (const node of preOrderTraverse(root)) {\n const left = node.left;\n node.left = node.right;\n node.right = left;\n }\n}\n/**\n * @internal\n */\nexport function rightmost>(node: undefined): undefined;\nexport function rightmost>(node: Node): Node;\nexport function rightmost>(\n node: Node | undefined,\n): Node | undefined;\nexport function rightmost>(\n node: Node | undefined,\n): Node | undefined {\n if (node == null) {\n return undefined;\n }\n while (node.right) {\n node = node.right;\n }\n return node;\n}\n/**\n * @internal\n */\nexport function rightmostStack>(\n stack: LinkedNode>,\n): LinkedNode> {\n let node = stack.value.to;\n if (node == null) {\n return stack;\n }\n while (node.right) {\n stack = { next: stack, value: { label: 'right', from: node, to: node.right } };\n node = node.right;\n }\n return stack;\n}\n/**\n * Assumes sorted by compareFn\n * @internal\n */\nexport function search>(\n element: T,\n node: Node | undefined,\n compareFn: CompareFn,\n): Node | undefined {\n while (node) {\n const comp: number = compareFn(element, node.value);\n if (comp == 0) {\n break;\n }\n node = comp < 0 ? node.left : node.right;\n }\n return node;\n}\n/**\n * Assumes sorted by compareFn\n * @internal\n */\nexport function searchStack>(\n element: T,\n stack: LinkedNode>,\n compareFn: CompareFn,\n dupeWeight = 0,\n): LinkedNode> {\n const paths: ['left', 'right'] = ['left', 'right'];\n let node = stack.value.to;\n while (node) {\n const comp: number = compareFn(element, node.value) || dupeWeight;\n if (comp === 0) {\n break;\n }\n const label = paths[+(comp > 0)];\n stack = { next: stack, value: { label, from: node, to: node[label] } };\n node = node[label]!;\n }\n return stack;\n}\n/**\n * @internal\n */\nexport function successor>(\n node: Node | undefined,\n): Node | undefined {\n return node == null ? undefined : leftmost(node.right);\n}\n/**\n * @internal\n */\nexport function successorStack>(\n stack: LinkedNode>,\n): LinkedNode> {\n const node = stack.value.to;\n if (node == null) {\n return stack;\n }\n stack = { next: stack, value: { label: 'right', from: node, to: node.right } };\n return leftmostStack(stack);\n}\n/**\n * Turn an array into a binary tree. Assumes elements are in level-order.\n *\n * @internal\n */\nexport function toBinaryTree(\n elements: (T | undefined)[] | undefined,\n): BinaryTreeNode | undefined {\n if (elements == null || elements.length < 1 || elements[0] == null) {\n return undefined;\n }\n const n = elements.length;\n const nodes: BinaryTreeNode[] = new Array(n);\n nodes[0] = { value: elements[0] };\n for (let i = 1; i < n; ++i) {\n if (elements[i] == null) {\n continue;\n }\n const par = nodes[(i - 1) >>> 1];\n const node = { value: elements[i]! };\n nodes[i] = node;\n if (i & 1) {\n par.left = node;\n } else {\n par.right = node;\n }\n }\n return nodes[0];\n}\n","import { isArray } from 'src/collection/arrayUtils';\nimport { BinaryTreeNode } from 'src/tree/binaryTreeNode';\nimport { clone, preOrderTraverse, toBinaryTree } from 'src/tree/binaryTreeUtils';\nimport { CompareFn } from '..';\nimport { BinaryHeap } from './binaryHeap';\nimport { Heap } from './heap';\nimport { skewMerge } from './utils';\n\n/**\n * A skew heap is a heap implemented as a binary tree\n * ([source](https://en.wikipedia.org/wiki/Skew_heap)).\n *\n * A skew heap is a self-adjusting heap which attempts to maintain balance\n * by unconditionally swapping all nodes in the merge path when merging two heaps. Every\n * operation that modifies the heap (e.g. push, pop, merge) is considered a merge and is done\n * by using a skew heap merge.\n *\n * Skew heaps can merge more quickly than binary heaps. This can seem contradictory, since\n * skew heaps have no structural constraints and no guarantee that the height of the tree is\n * logarithmic (i.e. balanced). However, amortized complexity analysis can demonstrate that\n * all operations on a skew heap can be done in O(log(n). More specifically, the\n * amortized complexity is known to be logφ(n) where φ is the golden ratio. This is\n * approximately 1.44*log2(n).\n *\n * #### Complexity\n *\n * | Property | Average | Worst |\n * | :------- | :------ | :---- |\n * | Space | O(n) | O(n)\n * | Push | O(log n) | O(log n)\n * | Peek | O(1)\t | O(1)\n * | Pop | O(log n) | O(log n)\n * | Search | O(n) | O(n)\n */\nexport class SkewHeap implements Heap {\n /**\n * The function to determine the order of elements.\n */\n protected compare: CompareFn;\n /**\n * The number of elements in the list.\n */\n protected length: number;\n /**\n * The node at the \"top\" of the heap.\n */\n protected root: BinaryTreeNode | undefined;\n /**\n * Instantiate a heap.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param elements - A set of elements to initialize the heap with.\n */\n constructor(compareFn: CompareFn, elements?: Iterable) {\n this.compare = compareFn;\n this.length = 0;\n this.addAll(elements ?? []);\n }\n\n addAll(elements: Iterable): number {\n if (isArray(elements)) {\n for (let i = 0; i < elements.length; ++i) {\n this.push(elements[i]);\n }\n } else if (elements instanceof SkewHeap || elements instanceof BinaryHeap) {\n this.merge(elements);\n } else {\n for (const element of elements) {\n this.push(element);\n }\n }\n return this.length;\n }\n\n clear(): void {\n this.length = 0;\n this.root = undefined;\n }\n\n comparator(): CompareFn {\n return this.compare;\n }\n\n contains(element: T): boolean {\n for (const node of preOrderTraverse(this.root)) {\n if (element === node.value) {\n return true;\n }\n }\n return false;\n }\n\n delete(element: T): boolean {\n if (this.root == null) {\n return false;\n }\n if (this.root.value === element) {\n this.pop()!;\n return true;\n }\n for (const par of preOrderTraverse(this.root)) {\n const key: keyof BinaryTreeNode | undefined =\n par.left && par.left.value === element\n ? 'left'\n : par.right && par.right.value === element\n ? 'right'\n : undefined;\n if (key != null) {\n const node = par[key]!;\n par[key] = skewMerge(this.compare, [node.left, node.right]);\n --this.length;\n return true;\n }\n }\n return false;\n }\n\n merge(heap: Heap): this {\n if (this.compare !== heap.comparator()) {\n this.addAll(heap);\n } else if (heap instanceof SkewHeap) {\n this.root = skewMerge(this.compare, [this.root, clone(heap.root)]);\n this.length += heap.size;\n } else if (heap instanceof BinaryHeap) {\n this.root = skewMerge(this.compare, [this.root, toBinaryTree(heap['array'])!]);\n this.length += heap.size;\n } else {\n this.addAll(heap);\n }\n return this;\n }\n\n peek(): T | undefined {\n return this.root?.value;\n }\n\n pop(): T | undefined {\n if (this.root == null) {\n return undefined;\n }\n const value = this.root.value;\n this.root = skewMerge(this.compare, [this.root.left, this.root.right]);\n --this.length;\n return value;\n }\n\n push(value: T): number {\n this.root = skewMerge(this.compare, [this.root, { value }]);\n return ++this.length;\n }\n\n pushPop(value: T): T {\n this.push(value);\n return this.pop()!;\n }\n\n replace(value: T): T | undefined {\n if (this.root == null) {\n this.root = { value };\n this.length = 1;\n return undefined;\n }\n const out = this.root.value;\n this.root = skewMerge(this.compare, [this.root.left, this.root.right, { value }]);\n return out;\n }\n\n get size(): number {\n return this.length;\n }\n\n *sorted(): Iterable {\n if (this.root == null) {\n return;\n }\n const heap = new SkewHeap>(\n (a, b) => this.compare(a.value, b.value),\n [this.root],\n );\n do {\n const node = heap.pop()!;\n yield node.value;\n node.left && heap.push(node.left);\n node.right && heap.push(node.right);\n } while (heap.size > 0);\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (const node of preOrderTraverse(this.root)) {\n yield node.value;\n }\n }\n\n update(curElement: T, newElement: T): boolean {\n if (this.root == null) {\n return false;\n }\n\n if (this.root.value === curElement) {\n this.root = skewMerge(this.compare, [\n this.root.left,\n this.root.right,\n { value: newElement },\n ]);\n return true;\n }\n\n let node: BinaryTreeNode | undefined = undefined;\n for (const par of preOrderTraverse(this.root)) {\n if (par.left && par.left.value === curElement) {\n node = par.left;\n par.left = undefined;\n break;\n }\n if (par.right && par.right.value === curElement) {\n node = par.right;\n par.right = undefined;\n break;\n }\n }\n\n if (node == null) {\n return false;\n }\n\n this.root = skewMerge(this.compare, [\n this.root,\n node.left,\n node.right,\n { value: newElement },\n ]);\n return true;\n }\n}\n","import { splice } from 'src/collection/arrayUtils';\nimport { clamp, wrapLeft } from 'src/math/numberUtils';\nimport { CompareFn } from '..';\nimport { List } from './list';\n\n/**\n * An implementation of the {@link List} interface using an array\n */\nexport class ArrayList implements List {\n /**\n * The array containing every element.\n */\n protected array: Array;\n /**\n * Instantiate the list.\n *\n * @param elements - A set of elements to initialize the list with.\n */\n constructor(elements?: Iterable) {\n this.array = elements ? Array.from(elements) : [];\n }\n\n add(index: number, element: T): number {\n if (index >= 0 && index <= this.size) {\n this.array.splice(index, 0, element);\n }\n return this.size;\n }\n\n addAll(index: number, elements: Iterable): number {\n if (index >= 0 && index <= this.size) {\n splice(this.array, index, 0, elements);\n }\n return this.size;\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n concat(...lists: Iterable[]): ArrayList {\n const out = new ArrayList(this);\n for (const list of lists) {\n out.addAll(out.size, list);\n }\n return out;\n }\n\n copyWithin(index: number, min?: number, max?: number): this {\n index = clamp(wrapLeft(index, 0, this.size), 0, this.size);\n min = clamp(wrapLeft(min ?? 0, 0, this.size), 0, this.size);\n max = clamp(wrapLeft(max ?? this.size, 0, this.size), 0, this.size);\n this.array.copyWithin(index, min, max);\n return this;\n }\n\n fill(element: T, min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.size), 0, this.size);\n max = clamp(wrapLeft(max ?? this.size, 0, this.size), 0, this.size);\n this.array.fill(element, min, max);\n return this;\n }\n\n get(index: number): T | undefined {\n return index < 0 || index >= this.size ? undefined : this.array[index];\n }\n\n getSet(index: number, callback: (element: T) => T): T | undefined {\n let value: T | undefined = undefined;\n if (index >= 0 && index < this.size) {\n value = this.array[index];\n this.array[index] = callback(value);\n }\n return value;\n }\n\n pop(): T | undefined {\n return this.array.pop();\n }\n\n push(element: T): number {\n return this.array.push(element);\n }\n\n remove(index: number): T | undefined {\n return index < 0 || index >= this.size ? undefined : this.array.splice(index, 1)[0];\n }\n\n reverse(min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.size), 0, this.size);\n max = clamp(wrapLeft(max ?? this.size, 0, this.size), 0, this.size) - 1;\n while (min < max) {\n const temp = this.array[min];\n this.array[min++] = this.array[max];\n this.array[max--] = temp;\n }\n return this;\n }\n\n set(index: number, element: T): T | undefined {\n let prev: T | undefined = undefined;\n if (index >= 0 && index < this.size) {\n prev = this.array[index];\n this.array[index] = element;\n }\n return prev;\n }\n\n shift(): T | undefined {\n return this.array.shift();\n }\n\n get size(): number {\n return this.array.length;\n }\n\n slice(min?: number, max?: number): ArrayList {\n return new ArrayList(this.array.slice(min, max));\n }\n\n splice(start?: number, count?: number, elements?: Iterable): List {\n return new ArrayList(splice(this.array, start, count, elements));\n }\n\n sort(compareFn: CompareFn): this {\n this.array.sort(compareFn);\n return this;\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n [Symbol.iterator](): Iterator {\n return this.array[Symbol.iterator]();\n }\n\n unshift(element: T): number {\n return this.array.unshift(element);\n }\n\n update(callback: (element: T, index: number) => T): this;\n update(min: number | undefined, callback: (element: T, index: number) => T): this;\n update(\n min: number | undefined,\n max: number | undefined,\n callback: (element: T, index: number) => T,\n ): this;\n update(\n min: number | undefined | ((element: T, index: number) => T),\n max?: number | ((element: T, index: number) => T),\n callback?: (element: T, index: number) => T,\n ): this {\n if (callback == null) {\n if (arguments.length < 2) {\n callback = min as (element: T, index: number) => T;\n min = undefined;\n } else {\n callback = max as (element: T, index: number) => T;\n max = undefined;\n }\n }\n min = clamp(wrapLeft((min as number) ?? 0, 0, this.size), 0, this.size);\n max = clamp(wrapLeft((max as number) ?? this.size, 0, this.size), 0, this.size);\n while (min < max) {\n this.array[min] = callback(this.array[min], min);\n ++min;\n }\n return this;\n }\n\n *view(min?: number, max?: number): Iterable {\n min = clamp(wrapLeft(min ?? 0, 0, this.size), 0, this.size);\n\n let len: () => number;\n if (max == null) {\n len = () => this.size;\n } else if (max >= 0) {\n len = () => Math.min(max, this.size);\n } else {\n len = () => this.size + max;\n }\n\n while (min < len()) {\n yield this.array[min++];\n }\n }\n}\n","import { CompareFn } from '..';\nimport { DoublyLinkedNode } from './doublyLinkedNode';\nimport { LinkedNode } from './linkedNode';\n\n/**\n * Sorts a list in place.\n *\n * Works on complete lists as well as sublists and circular lists:\n * - Linked lists will keep the link to the next node beyond the sorted section\n * - Doubly linked lists will keep links to the prev and next nodes outside the sorted section\n *\n * @param node - The head of the list\n * @param len - The length of the list beginning from node\n * @param isDoubly - Whether node is a doubly linked node\n * @param compareFn - A function used to determine the order of elements.\n *\n * It is expected to return:\n * - A negative value if first argument < second argument\n * - Zero if first argument == second argument\n * - A positive value if first argument > second argument\n *\n * @returns The new head and tail of the sorted list\n *\n * @internal\n */\nexport function linkedMergeSort>(\n node: Node,\n len: number,\n isDoubly: boolean,\n compareFn: CompareFn,\n): [Node, Node] {\n // Base case\n if (len < 2) {\n return [node, node];\n }\n\n // Split the list into two halves and sort them\n len = len / 2;\n const lens: [number, number] = [Math.ceil(len), Math.floor(len)];\n const heads = linkedMergeSort(node, lens[0], isDoubly, compareFn);\n const tails = linkedMergeSort(heads[1].next as Node, lens[1], isDoubly, compareFn);\n\n // Group the heads and tails together\n node = heads[1];\n heads[1] = tails[0];\n tails[0] = node;\n tails[0].next = tails[1].next;\n\n // Merge the sorted halves\n const prev = (heads[0] as DoublyLinkedNode).prev;\n node = linkedMergeSorted(heads, lens, isDoubly, compareFn);\n if (isDoubly) {\n (node as DoublyLinkedNode).prev = prev;\n }\n\n // Return the head and tail\n return [node, tails[+(lens[0] < 1)]];\n}\n/**\n * Merges two sorted lists.\n *\n * @param nodes - The heads of the lists\n * @param lens - The lengths of the lists\n * @param isDoubly - Whether the lists are a doubly linked\n * @param compareFn - A function used to determine the order of elements.\n *\n * It is expected to return:\n * - A negative value if first argument < second argument\n * - Zero if first argument == second argument\n * - A positive value if first argument > second argument\n *\n * @returns The new head of the sorted list\n *\n * @internal\n */\nexport function linkedMergeSorted>(\n heads: [Node, Node],\n lens: [number, number],\n isDoubly: boolean,\n compareFn: CompareFn,\n): Node {\n const root = {} as Node;\n\n let node = root;\n do {\n const index = +(compareFn(heads[0].value, heads[1].value) > 0);\n node.next = heads[index];\n if (isDoubly) {\n (node.next as DoublyLinkedNode).prev = node;\n }\n node = node.next as Node;\n heads[index] = node.next as Node;\n --lens[index];\n } while (lens[0] > 0 && lens[1] > 0);\n\n // Add any remaining nodes\n node.next = heads[+(lens[0] < 1)];\n if (isDoubly && node.next) {\n (node.next as DoublyLinkedNode).prev = node;\n }\n return root.next as Node;\n}\n","import { clamp, wrapLeft } from 'src/math/numberUtils';\nimport { CompareFn } from '..';\nimport { DoublyLinkedNode } from './doublyLinkedNode';\nimport { List } from './list';\nimport { linkedMergeSort } from './utils';\n\n/**\n * A (circular) doubly-linked list implementation of the {@link List} interface.\n *\n * Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.\n */\nexport class DoublyLinkedList implements List {\n /**\n * The number of elements in the list\n */\n protected length: number;\n /**\n * The sentinel node at the fron of the list\n */\n protected root: DoublyLinkedNode;\n /**\n * Instantiate the list.\n *\n * @param elements - A set of elements to initialize the list with.\n */\n constructor(elements?: Iterable) {\n this.length = 0;\n this.root = {} as DoublyLinkedNode;\n this.root.prev = this.root.next = this.root;\n this._addAll(this.root, elements ?? []);\n }\n\n add(index: number, value: T): number {\n if (index < 0 || index > this.length) {\n return this.length;\n }\n const prev = this._get(index - 1);\n const node = { next: prev.next, prev, value };\n prev.next = node;\n node.next!.prev = node;\n return ++this.length;\n }\n\n addAll(index: number, elements: Iterable): number {\n if (index >= 0 && index <= this.length) {\n this._addAll(this._get(index), elements);\n }\n return this.length;\n }\n\n clear(): void {\n this.length = 0;\n this.root.prev = this.root.next = this.root;\n }\n\n concat(...lists: Iterable[]): DoublyLinkedList {\n const out = new DoublyLinkedList(this);\n for (const list of lists) {\n out.addAll(out.size, list);\n }\n return out;\n }\n\n copyWithin(index: number, min?: number, max?: number): this {\n // Check if copying to the same section\n index = clamp(wrapLeft(index, 0, this.length), 0, this.length);\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n if (min === index) {\n return this;\n }\n\n // Check if the section to copy has no length\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n max = min + Math.min(max - min, this.length - index);\n if (min >= max) {\n return this;\n }\n\n // Check for overlap edge case\n if (min < index && index < max) {\n let nodeA = this._get(max);\n let nodeB = this._get(index + (max - min));\n do {\n nodeA = nodeA.prev!;\n nodeB = nodeB.prev!;\n nodeB.value = nodeA.value;\n } while (++min < max);\n return this;\n }\n\n // Copy the section to the destination\n let nodeA = this._get(min);\n let nodeB = this._get(index);\n do {\n nodeB.value = nodeA.value;\n nodeA = nodeA.next!;\n nodeB = nodeB.next!;\n } while (++min < max);\n return this;\n }\n\n fill(element: T, min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n if (min < max) {\n let node = this._get(min);\n do {\n node.value = element;\n node = node.next!;\n } while (++min < max);\n }\n return this;\n }\n\n get(index: number): T | undefined {\n return index < 0 || index >= this.length ? undefined : this._get(index).value;\n }\n\n getSet(index: number, callback: (element: T) => T): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = this._get(index);\n const value = node.value;\n node.value = callback(node.value);\n return value;\n }\n\n pop(): T | undefined {\n if (this.length < 1) {\n return undefined;\n }\n const tail = this.root.prev!;\n tail.prev!.next = this.root;\n this.root.prev = tail.prev;\n --this.length;\n return tail.value;\n }\n\n push(value: T): number {\n const prev = this.root.prev!;\n const node = { next: this.root, prev, value };\n prev.next = this.root.prev = node;\n return ++this.length;\n }\n\n remove(index: number): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = this._get(index);\n node.prev!.next = node.next;\n node.next!.prev = node.prev;\n --this.length;\n return node.value;\n }\n\n reverse(min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n if (max - min < 2) {\n return this;\n }\n const root = this._get(min - 1);\n const tail = root.next!;\n let node = tail;\n do {\n const temp = node.next!;\n node.next = node.prev;\n node.prev = temp;\n root.next = node;\n node = temp;\n } while (++min < max);\n tail.next = node;\n node.prev = tail;\n root.next!.prev = root;\n return this;\n }\n\n set(index: number, element: T): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = this._get(index);\n const value = node.value;\n node.value = element;\n return value;\n }\n\n shift(): T | undefined {\n if (this.length < 1) {\n return undefined;\n }\n const head = this.root.next!;\n head.next!.prev = this.root;\n this.root.next = head.next;\n --this.length;\n return head.value;\n }\n\n get size(): number {\n return this.length;\n }\n\n slice(min?: number, max?: number): DoublyLinkedList {\n return new DoublyLinkedList(this.view(min, max));\n }\n\n splice(start?: number, count?: number, elements?: Iterable): List {\n start = clamp(wrapLeft(start ?? 0, 0, this.length), 0, this.length);\n count = clamp(count ?? this.size, 0, this.size - start);\n\n // If not modifying the list\n const list = new DoublyLinkedList();\n if (elements == null && count < 1) {\n return list;\n }\n\n // Delete elements\n let node = this._get(start);\n while (count-- > 0) {\n list.push(node.value);\n node.prev!.next = node.next!;\n node.next!.prev = node.prev!;\n node = node.next!;\n --this.length;\n }\n\n // Add elements\n this._addAll(node, elements ?? []);\n\n return list;\n }\n\n sort(compareFn: CompareFn): this {\n if (this.length > 1) {\n const [head, tail] = linkedMergeSort(this.root.next!, this.length, true, compareFn);\n this.root.next = head;\n tail.next!.prev = tail;\n }\n return this;\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (let node = this.root.next!; node !== this.root; node = node.next!) {\n yield node.value;\n }\n }\n\n unshift(value: T): number {\n const head = this.root.next!;\n const node = { next: head, prev: this.root, value };\n this.root.next = head.prev = node;\n return ++this.length;\n }\n\n update(callback: (element: T, index: number) => T): this;\n update(min: number | undefined, callback: (element: T, index: number) => T): this;\n update(\n min: number | undefined,\n max: number | undefined,\n callback: (element: T, index: number) => T,\n ): this;\n update(\n min: number | undefined | ((element: T, index: number) => T),\n max?: number | ((element: T, index: number) => T),\n callback?: (element: T, index: number) => T,\n ): this {\n if (callback == null) {\n if (arguments.length < 2) {\n callback = min as (element: T, index: number) => T;\n min = undefined;\n } else {\n callback = max as (element: T, index: number) => T;\n max = undefined;\n }\n }\n min = clamp(wrapLeft((min as number) ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft((max as number) ?? this.length, 0, this.length), 0, this.length);\n if (min < max) {\n let node = this._get(min);\n do {\n node.value = callback(node.value, min);\n node = node.next!;\n } while (++min < max);\n }\n return this;\n }\n\n *view(min?: number, max?: number): Iterable {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n\n let len: () => number;\n if (max == null) {\n len = () => this.length;\n } else if (max >= 0) {\n len = () => max;\n } else {\n len = () => this.length + max;\n }\n\n if (min < len()) {\n let node = this._get(min);\n do {\n yield node.value;\n node = node.next!;\n } while (++min < len() && node !== this.root);\n }\n }\n /**\n *\n */\n protected _addAll(next: DoublyLinkedNode, elements: Iterable): void {\n let prev = next.prev!;\n for (const value of elements) {\n const node = { prev, value };\n prev.next = node;\n prev = node;\n ++this.length;\n }\n prev.next = next;\n next.prev = prev;\n }\n /**\n * A helper method to iterate and return the node at the given index.\n *\n * Depending on the index, the list will be traversed from beginning or end; whichever is closest to the specified index.\n *\n * @param index - The index to retrieve\n *\n * @returns The node at the given index\n */\n protected _get(index: number): DoublyLinkedNode {\n let node = this.root;\n if (index < this.length / 2) {\n while (index-- >= 0) {\n node = node.next!;\n }\n } else {\n for (index = this.length - index; index > 0; --index) {\n node = node.prev!;\n }\n }\n return node;\n }\n}\n","import { clamp, wrapLeft } from 'src/math/numberUtils';\nimport { CompareFn } from '..';\nimport { LinkedNode } from './linkedNode';\nimport { List } from './list';\nimport { linkedMergeSort } from './utils';\n\n/**\n * A (circular) linked list implementation of the {@link List} interface.\n */\nexport class LinkedList implements List {\n /**\n * The number of elements in the list.\n */\n protected length: number;\n /**\n * The sentinel node at the front of the list.\n */\n protected root: LinkedNode;\n /**\n * The last node of the list.\n */\n protected tail: LinkedNode;\n /**\n * Instantiate the list.\n *\n * @param elements - A set of elements to initialize the list with.\n */\n constructor(elements?: Iterable) {\n this.length = 0;\n this.root = {} as LinkedNode;\n this.root.next = this.root;\n this.tail = this._addAll(this.root, elements ?? []);\n }\n\n add(index: number, value: T): number {\n if (index >= 0 && index < this.length) {\n const prev = this._get(index - 1);\n prev.next = { value, next: prev.next };\n ++this.length;\n } else if (index === this.length) {\n this.push(value);\n }\n return this.length;\n }\n\n addAll(index: number, elements: Iterable): number {\n if (index >= 0 && index < this.length) {\n this._addAll(this._get(index - 1), elements);\n } else if (index === this.length) {\n this.tail = this._addAll(this.tail, elements);\n }\n return this.length;\n }\n\n clear(): void {\n this.length = 0;\n this.tail = this.root.next = this.root;\n }\n\n concat(...lists: Iterable[]): LinkedList {\n const out = new LinkedList(this);\n for (const list of lists) {\n out.addAll(out.size, list);\n }\n return out;\n }\n\n copyWithin(index: number, min?: number, max?: number): this {\n // Check if copying to itself\n index = clamp(wrapLeft(index, 0, this.length), 0, this.length);\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n if (min === index) {\n return this;\n }\n\n // Check if the section to copy has no length\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n max = min + Math.min(max - min, this.length - index);\n if (min >= max) {\n return this;\n }\n\n // Copy to earlier in the list\n if (index < min) {\n const node = this._get(index - 1);\n this._copyWithin(this._get(min - index - 1, node), node, max - min);\n return this;\n }\n\n // Copy to later in the list\n if (index > max) {\n const node = this._get(min - 1);\n this._copyWithin(node, this._get(index - min - 1, node), max - min);\n return this;\n }\n\n // Copy to overlapping destination\n const nodeA = this._get(min - 1);\n const nodeC = this._get(max - min - 1, nodeA);\n const nodeD = this._copyWithin(nodeA, nodeC, index - min);\n if (index + (max - min) >= this.length) {\n this.tail = nodeC;\n }\n const temp = nodeA.next;\n nodeA.next = nodeC.next;\n nodeC.next = nodeD.next;\n nodeD.next = temp;\n return this;\n }\n\n fill(element: T, min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n if (min < max) {\n let node = this._get(min);\n do {\n node.value = element;\n node = node.next!;\n } while (++min < max);\n }\n return this;\n }\n\n get(index: number): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n return index < this.length - 1 ? this._get(index).value : this.tail.value;\n }\n\n getSet(index: number, callback: (element: T) => T): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = index < this.length - 1 ? this._get(index) : this.tail;\n const value = node.value;\n node.value = callback(node.value);\n return value;\n }\n\n pop(): T | undefined {\n if (this.length < 1) {\n return undefined;\n }\n const value = this.tail.value;\n this.tail = this._get(this.length - 2);\n this.tail.next = this.root;\n --this.length;\n return value;\n }\n\n push(value: T): number {\n const tail: LinkedNode = { next: this.root, value };\n this.tail.next = tail;\n this.tail = tail;\n return ++this.length;\n }\n\n remove(index: number): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const prev = this._get(index - 1);\n const node = prev.next!;\n prev.next = node.next;\n if (index === --this.length) {\n this.tail = prev;\n }\n return node.value;\n }\n\n reverse(min?: number, max?: number): this {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft(max ?? this.length, 0, this.length), 0, this.length);\n if (max - min < 2) {\n return this;\n }\n const root = this._get(min - 1);\n this.tail = max >= this.length ? root.next! : this.tail;\n const tail = root.next!;\n let prev = tail;\n let node = tail.next!;\n while (++min < max) {\n const next = node.next!;\n node.next = prev;\n prev = node;\n node = next;\n }\n root.next = prev;\n tail.next = node;\n return this;\n }\n\n set(index: number, element: T): T | undefined {\n if (index < 0 || index >= this.length) {\n return undefined;\n }\n const node = this._get(index);\n const value = node.value;\n node.value = element;\n return value;\n }\n\n shift(): T | undefined {\n return this.remove(0);\n }\n\n get size(): number {\n return this.length;\n }\n\n slice(min?: number, max?: number): LinkedList {\n return new LinkedList(this.view(min, max));\n }\n\n splice(start?: number, count?: number, elements?: Iterable): List {\n start = clamp(wrapLeft(start ?? 0, 0, this.length), 0, this.length);\n count = clamp(count ?? this.size, 0, this.size - start);\n\n // If not modifying the list\n const deleted = new LinkedList();\n if (elements == null && count < 1) {\n return deleted;\n }\n\n // Delete elements\n let prev = this._get(start - 1);\n const newTail = start + count >= this.size;\n while (count-- > 0) {\n const node = prev.next!;\n deleted.push(node.value);\n prev.next = node.next;\n --this.length;\n }\n\n // Add elements\n prev = this._addAll(prev, elements ?? []);\n this.tail = newTail ? prev : this.tail;\n\n return deleted;\n }\n\n sort(compareFn: CompareFn): this {\n if (this.length > 1) {\n const [head, tail] = linkedMergeSort(this.root.next!, this.length, false, compareFn);\n this.root.next = head;\n this.tail = tail;\n }\n return this;\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (let node = this.root.next!; node !== this.root; node = node.next!) {\n yield node.value;\n }\n }\n\n unshift(value: T): number {\n return this.add(0, value);\n }\n\n update(callback: (element: T, index: number) => T): this;\n update(min: number | undefined, callback: (element: T, index: number) => T): this;\n update(\n min: number | undefined,\n max: number | undefined,\n callback: (element: T, index: number) => T,\n ): this;\n update(\n min: number | undefined | ((element: T, index: number) => T),\n max?: number | ((element: T, index: number) => T),\n callback?: (element: T, index: number) => T,\n ): this {\n if (callback == null) {\n if (arguments.length < 2) {\n callback = min as (element: T, index: number) => T;\n min = undefined;\n } else {\n callback = max as (element: T, index: number) => T;\n max = undefined;\n }\n }\n min = clamp(wrapLeft((min as number) ?? 0, 0, this.length), 0, this.length);\n max = clamp(wrapLeft((max as number) ?? this.length, 0, this.length), 0, this.length);\n if (min < max) {\n let node = this._get(min);\n do {\n node.value = callback(node.value, min);\n node = node.next!;\n } while (++min < max);\n }\n return this;\n }\n\n *view(min?: number, max?: number): Iterable {\n min = clamp(wrapLeft(min ?? 0, 0, this.length), 0, this.length);\n\n let len: () => number;\n if (max == null) {\n len = () => this.length;\n } else if (max >= 0) {\n len = () => max;\n } else {\n len = () => this.length + max;\n }\n\n if (min < len()) {\n let node = this._get(min);\n do {\n yield node.value;\n node = node.next!;\n } while (++min < len() && node !== this.root);\n }\n }\n\n protected _addAll(prev: LinkedNode, elements: Iterable): LinkedNode {\n const next = prev.next!;\n for (const value of elements) {\n const node = { value };\n prev.next = node;\n prev = node;\n ++this.length;\n }\n prev.next = next;\n return prev;\n }\n /**\n * Copy values from 'from' to 'to'.\n *\n * @param from - The initial node to copy from\n * @param prev - The root of the initial node to copy to\n * @param count - The number of values to copy\n */\n protected _copyWithin(from: LinkedNode, to: LinkedNode, count: number): LinkedNode {\n while (count-- > 0) {\n from = from.next!;\n to = to.next!;\n to.value = from.value;\n }\n return to;\n }\n /**\n * Get the node at the given index.\n *\n * @param index - The index to retrieve\n *\n * @returns The node at the given index\n */\n protected _get(index: number, root: LinkedNode = this.root): LinkedNode {\n let node = root!;\n while (index-- >= 0) {\n node = node.next!;\n }\n return node;\n }\n}\n","/**\n * Bit hacks for 32-bit unsigned numbers.\n */\n\n/**\n * Get the number of bits set of a 32-bit unsigned number ([source](https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan))\n *\n * @param a\n */\nexport function bitsSet(a: number): number {\n let b = 0;\n while (a) {\n ++b;\n a &= a - 1;\n }\n return b;\n}\n/**\n * Invert the bits of a 32-bit unsigned number.\n *\n * Example: 11 (1011) -> 4 (0100)\n *\n * @param a The number to invert\n *\n * @returns The inverted number\n */\nexport function invert(a: number): number {\n const b = msp(a);\n return u32(a ^ (b | (b - 1)));\n}\n/**\n * Check whether a 32-bit unsigned number is a power of 2.\n *\n * Example: 8 (1000) -> true\n *\n * @param a The number to check\n */\nexport function isPow2(a: number): boolean {\n return (a & (a - 1)) === 0;\n}\n/**\n * Get the Least Significant Bit of a 32-bit unsigned number\n *\n * @param a\n *\n * @returns The lowest bit set\n */\nexport function lsb(a: number): number {\n let b = -1;\n for (a = lsp(a); a; a >>>= 1) {\n ++b;\n }\n return b;\n}\n/**\n * Get the Least Significant Power of a 32-bit unsigned number\n *\n * @param a\n *\n * @returns 2**lsb(a)\n */\nexport function lsp(a: number): number {\n return u32(a & -a);\n}\n/**\n * Get the Least Significant Power Set of a 32-bit unsigned number.\n *\n * Example: 54 (110110) -> 6 (000110)\n *\n * @param a\n */\nexport function lsps(a: number): number {\n return u32(a & (lsp(a + lsp(a)) - 1));\n}\n/**\n * Get the Most Significant Power of the Least Significant Power Set of a 32-bit unsigned number.\n *\n * Example: 54 (110110) -> 4 (000100)\n *\n * @param a\n */ /*\nexport function mlsp(a: number): number {\n return (lsp(a + lsp(a)) >>> 1) || u32(0x80000000 & a);\n}\n*/\n/**\n * Get the Most Significant Bit of a 32-bit unsigned number\n *\n * @param a\n *\n * @returns ⌊log2(a)⌋ : the highest bit set\n */\nexport function msb(a: number): number {\n let b = -1;\n while (a !== 0) {\n ++b;\n a >>>= 1;\n }\n return b;\n}\n/**\n * Get the Most Significant Power of a 32-bit unsigned number\n *\n * @param a\n *\n * @returns 2**msb(a)\n */\nexport function msp(a: number): number {\n let b = a & -a;\n while (a != b) {\n a ^= b;\n b = a & -a;\n }\n return u32(b);\n}\n/**\n * Get the Most Significant Power Set of a 32-bit unsigned number.\n *\n * Example: 50 (110010) -> 48 (110000)\n *\n * @param a\n */\nexport function msps(a: number): number {\n let b = a & -a;\n while (a & (a + b)) {\n a ^= b;\n b = a & -a;\n }\n return u32(a);\n}\n/**\n * Reverse a 32-bit unsigned number.\n *\n * Example: 50 (110010) -> 19 (010011)\n *\n * @param a\n */\nexport function reverse(a: number): number {\n a = ((a & 0xaaaaaaaa) >>> 1) | ((a & 0x55555555) << 1);\n a = ((a & 0xcccccccc) >>> 2) | ((a & 0x33333333) << 2);\n a = ((a & 0xf0f0f0f0) >>> 4) | ((a & 0x0f0f0f0f) << 4);\n a = ((a & 0xff00ff00) >>> 8) | ((a & 0x00ff00ff) << 8);\n return u32((a >>> 16) | (a << 16));\n}\n/**\n * Turn a number into an unsigned 32-bit number\n *\n * @param a\n */\nexport function u32(a: number): number {\n return a >>> 0;\n}\n","import { Queue } from './queue';\n\n/**\n * An implementation of the {@link Queue} interface using an array\n */\nexport class ArrayQueue implements Queue {\n /**\n * The array containing every element.\n */\n protected array: T[];\n /**\n * Instantiate the queue.\n *\n * @param elements - A set of elements to initialize the queue with.\n */\n constructor(elements?: Iterable) {\n this.array = elements ? Array.from(elements) : [];\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n dequeue(): T | undefined {\n return this.size < 1 ? undefined : this.array.shift();\n }\n\n enqueue(element: T): number {\n return this.array.push(element);\n }\n\n peek(): T | undefined {\n return this.size < 1 ? undefined : this.array[0];\n }\n\n get size(): number {\n return this.array.length;\n }\n /**\n * Receive an iterator through the queue.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the queue\n */\n [Symbol.iterator](): Iterator {\n return this.array[Symbol.iterator]();\n }\n}\n","import { LinkedList, List } from '../list';\nimport { Queue } from './queue';\n\n/**\n * A linked list implementation of the {@link Queue} interface\n */\nexport class LinkedQueue implements Queue {\n /**\n * The list containing every element.\n */\n protected list: List;\n /**\n * Instantiate the queue.\n *\n * @param elements - A set of elements to initialize the queue with.\n */\n constructor(elements?: Iterable) {\n this.list = new LinkedList(elements);\n }\n\n clear(): void {\n this.list.clear();\n }\n\n dequeue(): T | undefined {\n return this.list.shift();\n }\n\n enqueue(element: T): number {\n return this.list.push(element);\n }\n\n peek(): T | undefined {\n return this.list.get(0);\n }\n\n get size(): number {\n return this.list.size;\n }\n /**\n * Receive an iterator through the queue.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the queue\n */\n [Symbol.iterator](): Iterator {\n return this.list[Symbol.iterator]();\n }\n}\n","import { lsb, lsp, msb, msp } from '../math/u32';\nimport { CombineFn } from '..';\nimport { MAX_ARRAY_LENGTH } from 'src/collection/arrayUtils';\nimport { SegmentTree } from './segmentTree';\n\n/*\n mca(a, b) = lsp(a | msp(b - a)) ; // where a <= b\n left(i) = i - (lsp(i + 1) >>> 1)\n right(i) = i + (lsp(i + 1) >>> 1)\n parent(i) =\n offset = lsp(i + 1)\n i + offset - ((i & 2*offset) >>> 0)\n*/\n\n/**\n * A {@link SegmentTree} with entries stored in in-order traversal.\n * Inspired by [Tristan Hume's IForestIndex](https://thume.ca/2021/03/14/iforests) ([github](https://github.com/trishume/gigatrace))\n */\nexport class InOrderSegmentTree implements SegmentTree {\n /**\n * The maximum amount of elements that can be added.\n *\n * n elements require 2n memory.\n */\n static readonly MAX_SIZE: number = Math.floor(MAX_ARRAY_LENGTH / 2);\n /**\n * The set of elements and aggregation nodes for the tree\n */\n protected array: T[];\n /**\n * The function used to aggregate elements\n */\n protected combine: CombineFn;\n /**\n * Construct a new segment tree\n *\n * @param combine - The function used to aggregate segment information\n * @param elements - A set of elements to add into the initial tree\n */\n constructor(combine: CombineFn, elements: Iterable = []) {\n this.array = [];\n this.combine = combine;\n this.build(elements);\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n pop(): T | undefined {\n // Sanitize range\n if (this.size < 1) {\n return undefined;\n }\n\n // Un-complete aggregation nodes\n const i = this.array.length - 1;\n for (let mask = 2; i & mask; mask *= 2) {\n this.array[i - mask] = this.array[i - mask - (mask >>> 1)];\n }\n\n // Return element\n const out = this.array[i - 1];\n this.array.length -= 2;\n return out;\n }\n\n push(element: T): number {\n // Sanitize range\n if (this.size >= InOrderSegmentTree.MAX_SIZE) {\n throw new RangeError(`Invalid length`);\n }\n\n // Add element\n const i = this.array.length;\n this.array[i + 1] = this.set(i, element);\n\n return this.size;\n }\n\n query(min: number, max: number): T {\n // Sanitize range\n if (min >= max) {\n throw new RangeError(`Range [${min}..${max}) is empty`);\n }\n if (min < 0 || max > this.size) {\n throw new RangeError(`Range [${min}..${max}) not in [0..${this.size})`);\n }\n\n // Translate range to interior indices\n min *= 2;\n max *= 2;\n\n // Jump to min's highest aggregation node that is fully within the range\n let offset = lsp(min | msp(max - min));\n let value = this.array[min - 1 + (offset >>> 1)];\n\n // Continue jumping aggregation nodes until max is reached\n for (min += offset; min < max; min += offset) {\n offset = lsp(min | msp(max - min));\n value = this.combine(value, this.array[min - 1 + (offset >>> 1)]);\n }\n\n return value;\n }\n\n get size(): number {\n return this.array.length >>> 1;\n }\n\n /**\n * Return an iterator through the tree's elements\n */\n *[Symbol.iterator](): Iterator {\n for (let i = 0; i < this.array.length; i += 2) {\n yield this.array[i];\n }\n }\n\n update(min: number, max: number, operation: (element: T, index: number) => T): void {\n // Sanitize range\n if (min >= max) {\n return;\n }\n if (min < 0 || max > this.size) {\n throw new RangeError(`Range [${min}..${max}) not in [0..${this.size})`);\n }\n\n // Translate range to interior indices\n min *= 2;\n max *= 2;\n\n // Update the values\n let value: T;\n do {\n value = this.set(min, operation(this.array[min], min >>> 1));\n min += 2;\n } while (min < max);\n\n // Update remaining aggregation nodes\n let dc = 0;\n let dp = lsp(min);\n max = msb(min ^ this.array.length) - lsb(min);\n for (--min; max > 0; --max) {\n value = this.combine(value, this.array[min + (dp >>> 1) - dc]);\n this.array[min] = value;\n dc = (min & (2 * dp)) >>> 0;\n min += dp - dc;\n dp *= 2;\n }\n\n // Update the incomplete aggregation node\n this.array[min] = value;\n }\n /**\n * A helper method used to build the tree\n *\n * @param elements The initial set of elements to add into the tree\n */\n protected build(elements: Iterable) {\n for (const element of elements) {\n this.push(element);\n }\n }\n /**\n * A helper method to update complete aggregation nodes for an index\n */\n protected set(index: number, element: T): T {\n // Set the index\n this.array[index++] = element;\n\n // Update complete aggregation nodes, from lowest to highest\n for (let mask = 2; index & mask; mask *= 2) {\n element = this.combine(this.array[index - mask - (mask >>> 1)], element);\n this.array[index - mask] = element;\n }\n\n return element;\n }\n}\n","/**\n * Thanks to [Douglas Wilhelm Harder](https://ece.uwaterloo.ca/~dwharder/aads/Algorithms/Array_resizing/)\n * for their analysis on array resizing\n */\nimport { isArray, MAX_ARRAY_LENGTH } from 'src/collection/arrayUtils';\nimport { isCollection } from 'src/collection';\nimport { Collection } from 'src/collection/collection';\nimport { CombineFn } from '..';\nimport { lsp, msp } from '../math/u32';\nimport { SegmentTree } from './segmentTree';\n\n/**\n * A {@link SegmentTree} with entries stored in level-order traversal.\n * Memory usage: n elements require between 2n-1 to 4(n-1)-1 entries\n *\n */\nexport class LevelOrderSegmentTree implements SegmentTree {\n /**\n * The maximum number of elements that can be added.\n *\n * n elements require 2^⌈log2(2n)⌉ - 1 memory:\n */\n static readonly MAX_SIZE: number = 2 ** Math.floor(Math.log2(MAX_ARRAY_LENGTH + 1) - 1);\n /**\n * The internal array used to store elements and aggregation nodes\n */\n protected array: Array;\n /**\n * The function used to aggregate elements\n */\n protected combine: CombineFn;\n /**\n * The used length (size) of our internal array\n */\n protected length: number;\n /**\n * The start index for the lowest level\n */\n protected level: number;\n /**\n * Construct a new {@link SegmentTree}\n *\n * @param combinFn - The function used to aggregate elements\n * @param elements - Initial elements to build into the tree\n */\n constructor(combine: CombineFn, elements: Iterable = []) {\n this.array = [];\n this.combine = combine;\n this.length = 0;\n this.level = 0;\n this.build(elements);\n }\n\n clear(): void {\n this.length = 0;\n this.level = 0;\n this.array.length = 0;\n }\n\n pop(): T | undefined {\n // Sanitize range\n if (this.length <= this.level) {\n return undefined;\n }\n\n // Remove element\n const out = this.array[--this.length];\n\n // If level is <= 1/4 full\n if (this.size <= (this.level + 1) >>> 2) {\n this.shrink();\n }\n\n return out;\n }\n\n push(element: T): number {\n // If array is full\n if (this.length >= this.array.length) {\n this.grow();\n }\n\n // Add the new element\n this.array[this.length++] = element;\n\n // Update aggregation nodes\n for (let i = this.length; i & 1; this.array[i - 1] = element) {\n element = this.combine(this.array[i - 2], element);\n i >>>= 1;\n }\n\n return this.size;\n }\n\n query(min: number, max: number): T {\n // Sanitize range\n if (min >= max) {\n throw new RangeError(`Range [${min}..${max}) is empty`);\n }\n if (min < 0 || max > this.size) {\n throw new RangeError(`Range [${min}..${max}) not in [0..${this.size})`);\n }\n\n // Translate range to interior indices and align with powers of 2\n min += this.level + 1;\n max += this.level + 1;\n\n // Take the longest possible jump from min\n let offset = lsp(min | msp(max - min));\n let value: T = this.array[min / offset - 1];\n min += offset;\n\n // Continue jumping until max\n while (min < max) {\n offset = lsp(min | msp(max - min));\n value = this.combine(value, this.array[min / offset - 1]);\n min += offset;\n }\n\n return value;\n }\n\n get size(): number {\n return this.length - this.level;\n }\n\n /**\n * Return an iterator through the elements\n */\n *[Symbol.iterator](): Iterator {\n for (let i = 0; i < this.size; ++i) {\n yield this.array[this.level + i];\n }\n }\n\n update(min: number, max: number, operation: (element: T, index: number) => T): void {\n // Sanitize range\n if (min >= max) {\n return;\n }\n if (min < 0 || max > this.size) {\n throw new RangeError(`Range [${min}..${max}) not in [0..${this.size})`);\n }\n\n // Translate range to interior indices\n min += this.level;\n max += this.level;\n\n // Update the range\n for (let i = min; i < max; ++i) {\n this.array[i] = operation(this.array[i], i - this.level);\n }\n\n // Update the range's aggregation nodes\n this.aggregate(min, max);\n }\n /**\n * A helper method to aggregate a range of elements\n */\n protected aggregate(min: number, max: number): void {\n // Align indices with powers of 2\n ++min;\n ++max;\n\n // Aggregate elements\n for (let cap = this.length + 1; min < max; cap >>>= 1) {\n max += max & ((max - cap) >>> 31);\n for (let i = (min | 1) >>> 0; i < max; i += 2) {\n this.array[(i >>> 1) - 1] = this.combine(this.array[i - 2], this.array[i - 1]);\n }\n min >>>= 1;\n max >>>= 1;\n }\n }\n /**\n * A helper method used to build the tree\n *\n * @param elements The initial set of elements to add into the tree\n */\n protected build(elements: Collection | Iterable): void {\n let key: string | undefined = undefined;\n\n // Check if the iterable's size can be known.\n if (isArray(elements)) {\n key = 'length';\n } else if (isCollection(elements)) {\n key = 'size';\n } else {\n for (const element of elements) {\n this.push(element);\n }\n return;\n }\n\n // Get the iterable's size\n const n: number = (elements as any)[key];\n\n // Check for base case\n if (n < 1) {\n this.array.length = 0;\n this.length = 0;\n this.level = 0;\n return;\n }\n\n // Check if max capacity reached\n if (n >= LevelOrderSegmentTree.MAX_SIZE) {\n throw new RangeError('Invalid length');\n }\n\n // Allocate the array\n this.level = 2 * msp(n - 1) - 1;\n this.length = this.level;\n this.array.length = 2 * this.level + 1;\n\n // Add the elements\n for (const element of elements) {\n this.array[this.length++] = element;\n }\n\n // Update aggregation nodes\n this.aggregate(this.level, this.length);\n }\n /**\n * Shift the tree down a level\n */\n protected grow(): void {\n // Check base case\n if (this.size < 1) {\n this.array.length = 1;\n return;\n }\n\n // Check if max capacity reached\n if (this.size >= LevelOrderSegmentTree.MAX_SIZE) {\n throw new RangeError('Invalid length');\n }\n\n // Extend capacity\n this.array.length += this.array.length + 1;\n\n // Shift the tree down a level\n let min = this.level + 1;\n for (let max = this.length + 1; min < max; max >>>= 1) {\n this.array.copyWithin(2 * min - 1, min - 1, max - 1);\n min >>>= 1;\n }\n\n // Update pointers\n this.length += this.level + 1;\n this.level += this.level + 1;\n }\n /**\n * Shift the tree to the highest non-full level\n */\n protected shrink(): void {\n const length = this.length - this.level;\n\n // Check base case\n if (length < 2) {\n this.array.copyWithin(0, this.level, this.length);\n this.level = 0;\n this.length = length;\n this.array.length = length;\n return;\n }\n\n // Get the highest node\n let min = this.level + 1;\n let mask = msp(length);\n min = min / lsp(min | mask) - 1;\n\n // Check if shrinking is possible\n if (min < 2) {\n return;\n }\n\n // Update the tree\n this.level = 0;\n for (let max = min + 1; mask; min += min + 1) {\n this.level += this.level + 1;\n this.array.copyWithin(this.level, min, max);\n mask >>>= 1;\n max += max + 2 + +((length & mask) > 0);\n }\n\n // Update pointers\n this.length = this.level + length;\n this.array.length = 2 * this.level + 1;\n }\n}\n","import { Stack } from './stack';\n\n/**\n * An implementation of the {@link Stack} interface using an array\n */\nexport class ArrayStack implements Stack {\n /**\n * The array containing every element.\n */\n protected array: T[];\n /**\n * Instantiate the stack.\n *\n * @param elements - A set of elements to initialize the stack with.\n */\n constructor(elements?: Iterable) {\n this.array = elements ? Array.from(elements) : [];\n }\n\n clear(): void {\n this.array.length = 0;\n }\n\n peek(): T | undefined {\n return this.array[this.array.length - 1];\n }\n\n pop(): T | undefined {\n return this.array.pop();\n }\n\n push(element: T): number {\n return this.array.push(element);\n }\n\n get size(): number {\n return this.array.length;\n }\n /**\n * Receive an iterator through the stack.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the stack\n */\n *[Symbol.iterator](): Iterator {\n const array = this.array;\n for (let i = array.length; i > 0; yield array[--i]) {}\n }\n}\n","import { LinkedList, List } from '../list';\nimport { Stack } from './stack';\n\n/**\n * A linked list implementation of the {@link Stack} interface\n */\nexport class LinkedStack implements Stack {\n /**\n * The list containing every element.\n */\n protected list: List;\n /**\n * Instantiate the stack.\n *\n * @param elements - A set of elements to initialize the stack with.\n */\n constructor(elements?: Iterable) {\n this.list = new LinkedList();\n for (const element of elements || []) {\n this.push(element);\n }\n }\n\n clear(): void {\n this.list.clear();\n }\n\n peek(): T | undefined {\n return this.list.get(0);\n }\n\n pop(): T | undefined {\n return this.list.shift();\n }\n\n push(element: T): number {\n return this.list.unshift(element);\n }\n\n get size(): number {\n return this.list.size;\n }\n /**\n * Receive an iterator through the stack.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the stack\n */\n [Symbol.iterator](): Iterator {\n return this.list[Symbol.iterator]();\n }\n}\n","import { CompareFn } from '..';\nimport { AATreeNode } from './aaTreeNode';\nimport {\n clone,\n search,\n Edge,\n inOrderTraverse,\n leftmost,\n leftmostStack,\n preOrderTraverse,\n removeStack,\n rightmost,\n rightmostStack,\n searchStack,\n debug,\n} from './binaryTreeUtils';\nimport { SortedTree } from './sortedTree';\nimport { isArray } from 'src/collection/arrayUtils';\nimport { LinkedNode } from 'src/list';\n\n/**\n * An AA tree is a form of balanced tree used for storing and retrieving ordered data efficiently\n * ([source](https://en.wikipedia.org/wiki/AA_tree)).\n *\n * AA trees are named for Arne Andersson, their inventor. They are a variation of the red–black tree,\n * which supports efficient addition and deletion of entries. Unlike red–black trees, additional\n * constraints on the balancing mechanism greatly simplifies the implementation as well as\n * maintenance operations; While a red–black tree needs to consider seven different shapes\n * to properly balance the tree, an AA tree only needs to consider two shapes.\n *\n * The performance of an AA tree is equivalent to the performance of a red–black tree.\n * While an AA tree makes more rotations than a red-black tree, the simpler algorithms\n * tend to be faster, which balances out to similar performance. A red-black tree is\n * more consistent in its performance, but an AA tree tends to be flatter, which results\n * in slightly faster search times.\n */\nexport class AATree implements SortedTree {\n /**\n * The function to determine the order of elements.\n */\n protected compare: CompareFn;\n /**\n * Indicates how to handle duplicates:\n * - < 0 : Add to left subtree\n * - = 0 : Do now allow duplicates\n * - > 0 : Add to right subtree\n */\n protected dupeWeight: number;\n /**\n * The number of elements in the list.\n */\n protected length: number;\n /**\n * The node at the \"top\" of the heap.\n */\n protected root: AATreeNode | undefined;\n /**\n * Instantiate a tree.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param elements - A set of elements to initialize the tree with.\n */\n constructor(compareFn: CompareFn, elements?: Iterable);\n /**\n * Instantiate a tree.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param allowDuplicates - Whether to allow duplicates\n * @param elements - A set of elements to initialize the tree with.\n */\n constructor(compareFn: CompareFn, allowDuplicates: boolean, elements?: Iterable);\n constructor(\n compareFn: CompareFn,\n allowDuplicates?: boolean | Iterable,\n elements?: Iterable,\n ) {\n if (typeof allowDuplicates !== 'boolean') {\n elements = allowDuplicates;\n allowDuplicates = true;\n }\n this.compare = compareFn;\n this.dupeWeight = +allowDuplicates;\n this.length = 0;\n this.build(elements ?? []);\n }\n\n add(element: T): this {\n // Find the element\n const sentinel = { left: this.root } as AATreeNode;\n let edge: Edge> = { from: sentinel, label: 'left', to: this.root };\n let stack = searchStack(element, { value: edge }, this.compare, this.dupeWeight);\n\n // If element already exists\n if (stack.value.to != null) {\n return this;\n }\n\n // Add element\n edge = stack.value;\n let label = edge.label;\n edge.from![label!] = { level: 1, value: element };\n\n // Balance the tree\n while (stack.next) {\n stack = stack.next;\n edge = stack.value;\n edge.to = split(skew(edge.to));\n edge.from![(label = edge.label!)] = edge.to;\n }\n\n // Update state\n ++this.length;\n this.root = sentinel.left;\n return this;\n }\n\n clear(): void {\n this.root = undefined;\n this.length = 0;\n }\n\n comparator(): CompareFn {\n return this.compare;\n }\n\n delete(element: T): boolean {\n // Remove the element if found\n const sentinel = { left: this.root } as AATreeNode;\n const edge: Edge> = { from: sentinel, label: 'left', to: this.root };\n const stack = searchStack(element, { value: edge }, this.compare, 0);\n const removed = remove(stack);\n\n // Update state\n this.root = sentinel.left;\n this.length -= +removed;\n return removed;\n }\n\n has(element: T): boolean {\n return search(element, this.root, this.compare) != null;\n }\n\n max(): T | undefined {\n return rightmost(this.root)?.value;\n }\n\n min(): T | undefined {\n return leftmost(this.root)?.value;\n }\n\n pop(): T | undefined {\n // Find the maximum value\n const sentinel = { left: this.root } as AATreeNode;\n const edge: Edge> = { from: sentinel, label: 'left', to: this.root };\n const stack = rightmostStack({ value: edge });\n const value = stack.value.to?.value;\n\n // Remove the value\n const removed = remove(stack);\n\n // Update state\n this.root = sentinel.left;\n this.length -= +removed;\n return value;\n }\n\n shift(): T | undefined {\n // Find the minimum value\n const sentinel = { left: this.root } as AATreeNode;\n const edge: Edge> = { from: sentinel, label: 'left', to: this.root };\n const stack = leftmostStack({ value: edge });\n const value = stack.value.to?.value;\n\n // Remove the value\n const removed = remove(stack);\n\n // Update state\n this.root = sentinel.left;\n this.length -= +removed;\n return value;\n }\n\n get size(): number {\n return this.length;\n }\n\n *sorted(): Iterable {\n for (const node of inOrderTraverse(this.root)) {\n yield node.value;\n }\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (const node of preOrderTraverse(this.root)) {\n yield node.value;\n }\n }\n\n update(curElement: T, newElement: T): boolean {\n if (this.delete(curElement)) {\n this.add(newElement);\n return true;\n }\n return false;\n }\n\n protected build(obj: Iterable): void {\n if (isArray(obj)) {\n for (let i = 0; i < obj.length; ++i) {\n this.add(obj[i]);\n }\n } else if (obj instanceof AATree && this.compare === obj.compare) {\n this.root = clone(obj.root);\n this.length = obj.size;\n } else {\n for (const element of obj) {\n this.add(element);\n }\n }\n }\n}\n/**\n * @internal\n */\nexport function remove(stack: LinkedNode>>): boolean {\n let edge = stack.value;\n let node = edge.to;\n\n // If not found\n if (node == null) {\n return false;\n }\n\n // Remove the node\n stack = removeStack(stack);\n\n // Update the tree\n while (stack.next) {\n stack = stack.next;\n edge = stack.value;\n node = edge.to!;\n\n // Decrease levels\n const level = 1 + Math.min(node.left?.level ?? 0, node.right?.level ?? 0);\n if (level < node.level) {\n node.level = level;\n if (node.right != null && level < node.right.level) {\n node.right.level = level;\n }\n }\n\n // Balance\n node = skew(node);\n node.right = skew(node.right);\n if (node.right != null) {\n node.right.right = skew(node.right.right);\n }\n node = split(node);\n node.right = split(node.right);\n\n // Make the update\n edge.from![edge.label!] = edge.to = node;\n }\n\n return true;\n}\n/**\n * @internal\n */\nexport function skew(node?: undefined): undefined;\nexport function skew(node: AATreeNode): AATreeNode;\nexport function skew(node?: AATreeNode): AATreeNode | undefined;\nexport function skew(node?: AATreeNode): AATreeNode | undefined {\n if (node == null || node.left == null || node.level != node.left.level) {\n return node;\n }\n const left = node.left;\n node.left = left.right;\n left.right = node;\n return left;\n}\n/**\n * @internal\n */\nexport function split(node?: undefined): undefined;\nexport function split(node: AATreeNode): AATreeNode;\nexport function split(node?: AATreeNode): AATreeNode | undefined;\nexport function split(node?: AATreeNode): AATreeNode | undefined {\n if (\n node == null ||\n node.right == null ||\n node.right.right == null ||\n node.level != node.right.right.level\n ) {\n return node;\n }\n const right = node.right;\n node.right = right.left;\n right.left = node;\n ++right.level;\n return right;\n}\n","import { CompareFn } from 'src';\nimport { AVLTreeNode } from './avlTreeNode';\nimport {\n clone,\n search,\n Edge,\n inOrderTraverse,\n leftmost,\n leftmostStack,\n preOrderTraverse,\n rightmost,\n rightmostStack,\n searchStack,\n removeStack,\n} from './binaryTreeUtils';\nimport { SortedTree } from './sortedTree';\nimport { isArray } from 'src/collection/arrayUtils';\nimport { LinkedNode } from 'src/list';\n\n/**\n * An AVL tree is a self-balancing binary search tree ([source](https://en.wikipedia.org/wiki/AVL_tree)).\n *\n * It is named after inventors Georgy Adelson-Velsky and Evgenii Landis and was the first such\n * data structure to be invented. In an AVL tree, the heights of the two child\n * subtrees of any node differ by at most one; if at any time they differ by more\n * than one, rebalancing is done to restore this property.\n *\n * Lookup, insertion, and deletion all take O(log(n)) time in both the average and worst cases,\n * where n is the number of nodes in the tree prior to the operation. Insertions and deletions\n * may require the tree to be rebalanced by one or more tree rotations.\n *\n * AVL trees are often compared with red–black trees as both take O(log(n))\n * time for the basic operations. For lookup-intensive applications, AVL trees are\n * faster than red–black trees because they are more strictly balanced.\n * Similar to red–black trees, AVL trees are height-balanced.\n */\nexport class AVLTree implements SortedTree {\n /**\n * The function to determine the order of elements.\n */\n protected compare: CompareFn;\n /**\n * Indicates how to handle duplicates:\n * - < 0 : Add to left subtree\n * - = 0 : Do now allow duplicates\n * - > 0 : Add to right subtree\n */\n protected dupeWeight: number;\n /**\n * The number of elements in the list.\n */\n protected length: number;\n /**\n * The root of the tree.\n */\n protected root: AVLTreeNode;\n /**\n * Instantiate a tree.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param elements - A set of elements to initialize the tree with.\n */\n constructor(compareFn: CompareFn, elements?: Iterable);\n /**\n * Instantiate a tree.\n *\n * @param compareFn - The function to determine the order of elements.\n * @param allowDuplicates - Whether to allow duplicates\n * @param elements - A set of elements to initialize the tree with.\n */\n constructor(compareFn: CompareFn, allowDuplicates: boolean, elements?: Iterable);\n constructor(\n compareFn: CompareFn,\n allowDuplicates?: boolean | Iterable,\n elements?: Iterable,\n ) {\n if (typeof allowDuplicates !== 'boolean') {\n elements = allowDuplicates;\n allowDuplicates = true;\n }\n this.compare = compareFn;\n this.dupeWeight = +allowDuplicates;\n this.length = 0;\n this.root = {} as AVLTreeNode;\n this.build(elements ?? []);\n }\n\n add(element: T): this {\n // Find the element\n let edge: Edge> = { from: this.root, label: 'left', to: this.root.left };\n let stack = searchStack(element, { value: edge }, this.compare, this.dupeWeight);\n\n // If element already exists\n if (stack.value.to != null) {\n return this;\n }\n\n // Add element\n edge = stack.value;\n let label = edge.label;\n edge.from![label!] = { balanceFactor: 0, value: element };\n\n // Balance the tree\n while (stack.next) {\n stack = stack.next;\n edge = stack.value;\n edge.to!.balanceFactor += label === 'left' ? -1 : 1;\n edge.to = balance(edge.to!);\n edge.from![(label = edge.label!)] = edge.to;\n if (edge.to!.balanceFactor === 0) {\n break;\n }\n }\n\n // Update state\n ++this.length;\n return this;\n }\n\n clear(): void {\n this.root.left = undefined;\n this.length = 0;\n }\n\n comparator(): CompareFn {\n return this.compare;\n }\n\n delete(element: T): boolean {\n // Remove the element if found\n const edge: Edge> = { from: this.root, label: 'left', to: this.root.left };\n const stack = searchStack(element, { value: edge }, this.compare, 0);\n const removed = remove(stack);\n\n // Update state\n this.length -= +removed;\n return removed;\n }\n\n has(element: T): boolean {\n return search(element, this.root.left, this.compare) != null;\n }\n\n max(): T | undefined {\n return rightmost(this.root.left)?.value;\n }\n\n min(): T | undefined {\n return leftmost(this.root.left)?.value;\n }\n\n pop(): T | undefined {\n // Find the maximum value\n const edge: Edge> = { from: this.root, label: 'left', to: this.root.left };\n const stack = rightmostStack({ value: edge });\n const value = stack.value.to?.value;\n\n // Remove the value\n const removed = remove(stack);\n\n // Update state\n this.length -= +removed;\n return value;\n }\n\n shift(): T | undefined {\n // Find the minimum value\n const edge: Edge> = { from: this.root, label: 'left', to: this.root.left };\n const stack = leftmostStack({ value: edge });\n const value = stack.value.to?.value;\n\n // Remove the value\n const removed = remove(stack);\n\n // Update state\n this.length -= +removed;\n return value;\n }\n\n get size(): number {\n return this.length;\n }\n\n *sorted(): Iterable {\n for (const node of inOrderTraverse(this.root.left)) {\n yield node.value;\n }\n }\n /**\n * Receive an iterator through the list.\n *\n * **Note:** Unexpected behavior can occur if the collection is modified during iteration.\n *\n * @returns An iterator through the list\n */\n *[Symbol.iterator](): Iterator {\n for (const node of preOrderTraverse(this.root.left)) {\n yield node.value;\n }\n }\n\n update(curElement: T, newElement: T): boolean {\n if (this.delete(curElement)) {\n this.add(newElement);\n return true;\n }\n return false;\n }\n\n protected build(obj: Iterable): void {\n if (isArray(obj)) {\n for (let i = 0; i < obj.length; ++i) {\n this.add(obj[i]);\n }\n } else if (obj instanceof AVLTree && this.compare === obj.compare) {\n this.root = clone(obj.root);\n this.length = obj.size;\n } else {\n for (const element of obj) {\n this.add(element);\n }\n }\n }\n}\n/**\n * @internal\n */\nexport function balance(node: AVLTreeNode): AVLTreeNode {\n if (node.balanceFactor > 1) {\n if (node.right!.balanceFactor < 0) {\n node.right = rotateR(node.right!);\n }\n node = rotateL(node);\n } else if (node.balanceFactor < -1) {\n if (node.left!.balanceFactor > 0) {\n node.left = rotateL(node.left!);\n }\n node = rotateR(node);\n }\n return node;\n}\n/**\n * @internal\n */\nexport function remove(stack: LinkedNode>>): boolean {\n let edge = stack.value;\n const node = edge.to;\n\n // If not found\n if (node == null) {\n return false;\n }\n\n // Remove the node\n stack = removeStack(stack);\n\n // Balance the tree\n let label = stack.value.label;\n while (stack.next) {\n stack = stack.next;\n edge = stack.value;\n edge.to!.balanceFactor -= label === 'left' ? -1 : 1;\n edge.to = balance(edge.to!);\n edge.from![(label = edge.label)!] = edge.to;\n if (edge.to!.balanceFactor !== 0) {\n break;\n }\n }\n\n return true;\n}\n/**\n * @internal\n */\nexport function rotateL(P: AVLTreeNode): AVLTreeNode {\n const R = P.right!;\n P.right = R.left;\n R.left = P;\n P.balanceFactor -= 1 + Math.max(0, R.balanceFactor);\n R.balanceFactor -= 1 - Math.min(0, P.balanceFactor);\n return R;\n}\n/**\n * @internal\n */\nexport function rotateR(P: AVLTreeNode): AVLTreeNode {\n const L = P.left!;\n P.left = L.right;\n L.right = P;\n P.balanceFactor += 1 - Math.min(0, L.balanceFactor);\n L.balanceFactor += 1 + Math.max(0, P.balanceFactor);\n return L;\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index e30be22..2b6a317 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ -dastal - v4.1.0 +dastal - v4.1.1 -# dastal - v4.1.0 +# dastal - v4.1.1 ## Table of contents @@ -95,7 +95,7 @@ the inputs, depending on the use case. #### Defined in -[src/index.ts:21](https://github.com/havelessbemore/dastal/blob/d5a812e/src/index.ts#L21) +[src/index.ts:21](https://github.com/havelessbemore/dastal/blob/351eddf/src/index.ts#L21) ___ @@ -137,7 +137,7 @@ A function used to determine the order of a set of elements. #### Defined in -[src/index.ts:33](https://github.com/havelessbemore/dastal/blob/d5a812e/src/index.ts#L33) +[src/index.ts:33](https://github.com/havelessbemore/dastal/blob/351eddf/src/index.ts#L33) ## Functions @@ -161,4 +161,4 @@ obj is Collection #### Defined in -[src/collection/index.ts:15](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/index.ts#L15) +[src/collection/index.ts:15](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/index.ts#L15) diff --git a/docs/classes/aatree.md b/docs/classes/aatree.md index 83b0d63..bd625d0 100644 --- a/docs/classes/aatree.md +++ b/docs/classes/aatree.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / AATree +[dastal - v4.1.1](../README.md) / AATree # Class: AATree @@ -75,7 +75,7 @@ Instantiate a tree. #### Defined in -[src/tree/aaTree.ts:56](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L56) +[src/tree/aaTree.ts:56](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L56) • **new AATree**(`compareFn`, `allowDuplicates`, `elements?`) @@ -97,7 +97,7 @@ Instantiate a tree. #### Defined in -[src/tree/aaTree.ts:63](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L63) +[src/tree/aaTree.ts:63](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L63) ## Accessors @@ -117,7 +117,7 @@ The number of elements in the collection. #### Defined in -[src/tree/aaTree.ts:183](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L183) +[src/tree/aaTree.ts:183](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L183) ## Methods @@ -141,7 +141,7 @@ An iterator through the list #### Defined in -[src/tree/aaTree.ts:199](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L199) +[src/tree/aaTree.ts:199](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L199) ___ @@ -167,7 +167,7 @@ Inserts an element into the tree. #### Defined in -[src/tree/aaTree.ts:87](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L87) +[src/tree/aaTree.ts:87](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L87) ___ @@ -187,7 +187,7 @@ Removes all elements. #### Defined in -[src/tree/aaTree.ts:117](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L117) +[src/tree/aaTree.ts:117](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L117) ___ @@ -205,7 +205,7 @@ ___ #### Defined in -[src/tree/aaTree.ts:122](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L122) +[src/tree/aaTree.ts:122](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L122) ___ @@ -231,7 +231,7 @@ Delete an element from the tree. #### Defined in -[src/tree/aaTree.ts:126](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L126) +[src/tree/aaTree.ts:126](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L126) ___ @@ -257,7 +257,7 @@ Check if an element is in the tree. #### Defined in -[src/tree/aaTree.ts:139](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L139) +[src/tree/aaTree.ts:139](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L139) ___ @@ -277,7 +277,7 @@ Get the maximum element. #### Defined in -[src/tree/aaTree.ts:143](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L143) +[src/tree/aaTree.ts:143](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L143) ___ @@ -297,7 +297,7 @@ Get the minimum element. #### Defined in -[src/tree/aaTree.ts:147](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L147) +[src/tree/aaTree.ts:147](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L147) ___ @@ -317,7 +317,7 @@ Remove the maximum element. #### Defined in -[src/tree/aaTree.ts:151](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L151) +[src/tree/aaTree.ts:151](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L151) ___ @@ -337,7 +337,7 @@ Remove the minimum element. #### Defined in -[src/tree/aaTree.ts:167](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L167) +[src/tree/aaTree.ts:167](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L167) ___ @@ -359,7 +359,7 @@ Iterate through the tree in sorted order (i.e in-order traversal). #### Defined in -[src/tree/aaTree.ts:187](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L187) +[src/tree/aaTree.ts:187](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L187) ___ @@ -386,4 +386,4 @@ Update a specific element. #### Defined in -[src/tree/aaTree.ts:205](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTree.ts#L205) +[src/tree/aaTree.ts:205](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTree.ts#L205) diff --git a/docs/classes/arraylist.md b/docs/classes/arraylist.md index 7eb409f..169c31e 100644 --- a/docs/classes/arraylist.md +++ b/docs/classes/arraylist.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / ArrayList +[dastal - v4.1.1](../README.md) / ArrayList # Class: ArrayList @@ -70,7 +70,7 @@ Instantiate the list. #### Defined in -[src/list/arrayList.ts:13](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L13) +[src/list/arrayList.ts:13](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L13) ## Accessors @@ -90,7 +90,7 @@ The number of elements in the collection. #### Defined in -[src/list/arrayList.ts:113](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L113) +[src/list/arrayList.ts:113](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L113) ## Methods @@ -114,7 +114,7 @@ An iterator through the list #### Defined in -[src/list/arrayList.ts:136](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L136) +[src/list/arrayList.ts:136](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L136) ___ @@ -141,7 +141,7 @@ Add the element at the specified index. #### Defined in -[src/list/arrayList.ts:23](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L23) +[src/list/arrayList.ts:23](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L23) ___ @@ -168,7 +168,7 @@ Add elements at the specified index. #### Defined in -[src/list/arrayList.ts:30](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L30) +[src/list/arrayList.ts:30](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L30) ___ @@ -188,7 +188,7 @@ Removes all elements. #### Defined in -[src/list/arrayList.ts:37](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L37) +[src/list/arrayList.ts:37](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L37) ___ @@ -214,7 +214,7 @@ Combines the list with multiple iterables into a new list. Does not modify the e #### Defined in -[src/list/arrayList.ts:41](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L41) +[src/list/arrayList.ts:41](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L41) ___ @@ -248,7 +248,7 @@ the copied sequence will be trimmed to fit list.size #### Defined in -[src/list/arrayList.ts:49](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L49) +[src/list/arrayList.ts:49](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L49) ___ @@ -279,7 +279,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/arrayList.ts:57](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L57) +[src/list/arrayList.ts:57](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L57) ___ @@ -305,7 +305,7 @@ Return the element at the specified index. #### Defined in -[src/list/arrayList.ts:64](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L64) +[src/list/arrayList.ts:64](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L64) ___ @@ -332,7 +332,7 @@ Update the element at the specified index. #### Defined in -[src/list/arrayList.ts:68](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L68) +[src/list/arrayList.ts:68](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L68) ___ @@ -352,7 +352,7 @@ Retrieves and removes the end of the list. #### Defined in -[src/list/arrayList.ts:77](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L77) +[src/list/arrayList.ts:77](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L77) ___ @@ -378,7 +378,7 @@ Inserts the specified value into the end of the list #### Defined in -[src/list/arrayList.ts:81](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L81) +[src/list/arrayList.ts:81](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L81) ___ @@ -407,7 +407,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/arrayList.ts:85](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L85) +[src/list/arrayList.ts:85](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L85) ___ @@ -437,7 +437,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/arrayList.ts:89](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L89) +[src/list/arrayList.ts:89](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L89) ___ @@ -464,7 +464,7 @@ Update the element at the specified index. #### Defined in -[src/list/arrayList.ts:100](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L100) +[src/list/arrayList.ts:100](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L100) ___ @@ -484,7 +484,7 @@ Retrieves and removes the first element in the list. #### Defined in -[src/list/arrayList.ts:109](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L109) +[src/list/arrayList.ts:109](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L109) ___ @@ -514,7 +514,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/arrayList.ts:117](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L117) +[src/list/arrayList.ts:117](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L117) ___ @@ -540,7 +540,7 @@ Sorts the elements in place. #### Defined in -[src/list/arrayList.ts:125](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L125) +[src/list/arrayList.ts:125](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L125) ___ @@ -569,7 +569,7 @@ Returns any deleted elements. #### Defined in -[src/list/arrayList.ts:121](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L121) +[src/list/arrayList.ts:121](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L121) ___ @@ -595,7 +595,7 @@ Inserts the specified value into the front of the list #### Defined in -[src/list/arrayList.ts:140](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L140) +[src/list/arrayList.ts:140](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L140) ___ @@ -621,7 +621,7 @@ Update the elements of the list #### Defined in -[src/list/arrayList.ts:144](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L144) +[src/list/arrayList.ts:144](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L144) ▸ **update**(`min`, `callback`): [ArrayList](arraylist.md) @@ -647,7 +647,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/arrayList.ts:145](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L145) +[src/list/arrayList.ts:145](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L145) ▸ **update**(`min`, `max`, `callback`): [ArrayList](arraylist.md) @@ -674,7 +674,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/arrayList.ts:146](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L146) +[src/list/arrayList.ts:146](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L146) ___ @@ -706,4 +706,4 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/arrayList.ts:174](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/arrayList.ts#L174) +[src/list/arrayList.ts:174](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/arrayList.ts#L174) diff --git a/docs/classes/arrayqueue.md b/docs/classes/arrayqueue.md index f69bdda..66a4a68 100644 --- a/docs/classes/arrayqueue.md +++ b/docs/classes/arrayqueue.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / ArrayQueue +[dastal - v4.1.1](../README.md) / ArrayQueue # Class: ArrayQueue @@ -54,7 +54,7 @@ Instantiate the queue. #### Defined in -[src/queue/arrayQueue.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/arrayQueue.ts#L10) +[src/queue/arrayQueue.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/arrayQueue.ts#L10) ## Accessors @@ -74,7 +74,7 @@ The number of elements in the collection. #### Defined in -[src/queue/arrayQueue.ts:36](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/arrayQueue.ts#L36) +[src/queue/arrayQueue.ts:36](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/arrayQueue.ts#L36) ## Methods @@ -98,7 +98,7 @@ An iterator through the queue #### Defined in -[src/queue/arrayQueue.ts:46](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/arrayQueue.ts#L46) +[src/queue/arrayQueue.ts:46](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/arrayQueue.ts#L46) ___ @@ -118,7 +118,7 @@ Removes all elements. #### Defined in -[src/queue/arrayQueue.ts:20](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/arrayQueue.ts#L20) +[src/queue/arrayQueue.ts:20](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/arrayQueue.ts#L20) ___ @@ -138,7 +138,7 @@ Retrieves and removes the head of this queue #### Defined in -[src/queue/arrayQueue.ts:24](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/arrayQueue.ts#L24) +[src/queue/arrayQueue.ts:24](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/arrayQueue.ts#L24) ___ @@ -164,7 +164,7 @@ Inserts the specified value into this queue #### Defined in -[src/queue/arrayQueue.ts:28](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/arrayQueue.ts#L28) +[src/queue/arrayQueue.ts:28](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/arrayQueue.ts#L28) ___ @@ -184,4 +184,4 @@ Retrieves, but does not remove, the head of this queue #### Defined in -[src/queue/arrayQueue.ts:32](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/arrayQueue.ts#L32) +[src/queue/arrayQueue.ts:32](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/arrayQueue.ts#L32) diff --git a/docs/classes/arraystack.md b/docs/classes/arraystack.md index 1a32173..03b11c8 100644 --- a/docs/classes/arraystack.md +++ b/docs/classes/arraystack.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / ArrayStack +[dastal - v4.1.1](../README.md) / ArrayStack # Class: ArrayStack @@ -54,7 +54,7 @@ Instantiate the stack. #### Defined in -[src/stack/arrayStack.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/arrayStack.ts#L10) +[src/stack/arrayStack.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/arrayStack.ts#L10) ## Accessors @@ -74,7 +74,7 @@ The number of elements in the collection. #### Defined in -[src/stack/arrayStack.ts:36](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/arrayStack.ts#L36) +[src/stack/arrayStack.ts:36](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/arrayStack.ts#L36) ## Methods @@ -98,7 +98,7 @@ An iterator through the stack #### Defined in -[src/stack/arrayStack.ts:46](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/arrayStack.ts#L46) +[src/stack/arrayStack.ts:46](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/arrayStack.ts#L46) ___ @@ -118,7 +118,7 @@ Removes all elements. #### Defined in -[src/stack/arrayStack.ts:20](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/arrayStack.ts#L20) +[src/stack/arrayStack.ts:20](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/arrayStack.ts#L20) ___ @@ -138,7 +138,7 @@ Retrieves, but does not remove, the top of the stack #### Defined in -[src/stack/arrayStack.ts:24](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/arrayStack.ts#L24) +[src/stack/arrayStack.ts:24](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/arrayStack.ts#L24) ___ @@ -158,7 +158,7 @@ Retrieves and removes the top of the stack #### Defined in -[src/stack/arrayStack.ts:28](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/arrayStack.ts#L28) +[src/stack/arrayStack.ts:28](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/arrayStack.ts#L28) ___ @@ -184,4 +184,4 @@ Inserts an element into the stack #### Defined in -[src/stack/arrayStack.ts:32](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/arrayStack.ts#L32) +[src/stack/arrayStack.ts:32](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/arrayStack.ts#L32) diff --git a/docs/classes/avltree.md b/docs/classes/avltree.md index a197741..09520f2 100644 --- a/docs/classes/avltree.md +++ b/docs/classes/avltree.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / AVLTree +[dastal - v4.1.1](../README.md) / AVLTree # Class: AVLTree @@ -76,7 +76,7 @@ Instantiate a tree. #### Defined in -[src/tree/avlTree.ts:56](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L56) +[src/tree/avlTree.ts:56](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L56) • **new AVLTree**(`compareFn`, `allowDuplicates`, `elements?`) @@ -98,7 +98,7 @@ Instantiate a tree. #### Defined in -[src/tree/avlTree.ts:63](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L63) +[src/tree/avlTree.ts:63](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L63) ## Accessors @@ -118,7 +118,7 @@ The number of elements in the collection. #### Defined in -[src/tree/avlTree.ts:180](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L180) +[src/tree/avlTree.ts:180](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L180) ## Methods @@ -142,7 +142,7 @@ An iterator through the list #### Defined in -[src/tree/avlTree.ts:196](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L196) +[src/tree/avlTree.ts:196](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L196) ___ @@ -168,7 +168,7 @@ Inserts an element into the tree. #### Defined in -[src/tree/avlTree.ts:88](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L88) +[src/tree/avlTree.ts:88](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L88) ___ @@ -188,7 +188,7 @@ Removes all elements. #### Defined in -[src/tree/avlTree.ts:120](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L120) +[src/tree/avlTree.ts:120](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L120) ___ @@ -206,7 +206,7 @@ ___ #### Defined in -[src/tree/avlTree.ts:125](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L125) +[src/tree/avlTree.ts:125](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L125) ___ @@ -232,7 +232,7 @@ Delete an element from the tree. #### Defined in -[src/tree/avlTree.ts:129](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L129) +[src/tree/avlTree.ts:129](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L129) ___ @@ -258,7 +258,7 @@ Check if an element is in the tree. #### Defined in -[src/tree/avlTree.ts:140](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L140) +[src/tree/avlTree.ts:140](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L140) ___ @@ -278,7 +278,7 @@ Get the maximum element. #### Defined in -[src/tree/avlTree.ts:144](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L144) +[src/tree/avlTree.ts:144](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L144) ___ @@ -298,7 +298,7 @@ Get the minimum element. #### Defined in -[src/tree/avlTree.ts:148](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L148) +[src/tree/avlTree.ts:148](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L148) ___ @@ -318,7 +318,7 @@ Remove the maximum element. #### Defined in -[src/tree/avlTree.ts:152](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L152) +[src/tree/avlTree.ts:152](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L152) ___ @@ -338,7 +338,7 @@ Remove the minimum element. #### Defined in -[src/tree/avlTree.ts:166](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L166) +[src/tree/avlTree.ts:166](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L166) ___ @@ -360,7 +360,7 @@ Iterate through the tree in sorted order (i.e in-order traversal). #### Defined in -[src/tree/avlTree.ts:184](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L184) +[src/tree/avlTree.ts:184](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L184) ___ @@ -387,4 +387,4 @@ Update a specific element. #### Defined in -[src/tree/avlTree.ts:202](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTree.ts#L202) +[src/tree/avlTree.ts:202](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTree.ts#L202) diff --git a/docs/classes/binaryheap.md b/docs/classes/binaryheap.md index 01225ab..6f9bc59 100644 --- a/docs/classes/binaryheap.md +++ b/docs/classes/binaryheap.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / BinaryHeap +[dastal - v4.1.1](../README.md) / BinaryHeap # Class: BinaryHeap @@ -79,7 +79,7 @@ Instantiate a heap. #### Defined in -[src/heap/binaryHeap.ts:32](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L32) +[src/heap/binaryHeap.ts:32](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L32) ## Accessors @@ -99,7 +99,7 @@ The number of elements in the collection. #### Defined in -[src/heap/binaryHeap.ts:186](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L186) +[src/heap/binaryHeap.ts:186](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L186) ## Methods @@ -123,7 +123,7 @@ An iterator through the list #### Defined in -[src/heap/binaryHeap.ts:213](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L213) +[src/heap/binaryHeap.ts:213](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L213) ___ @@ -149,7 +149,7 @@ Insert a set of elements into the heap. #### Defined in -[src/heap/binaryHeap.ts:45](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L45) +[src/heap/binaryHeap.ts:45](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L45) ___ @@ -169,7 +169,7 @@ Removes all elements. #### Defined in -[src/heap/binaryHeap.ts:73](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L73) +[src/heap/binaryHeap.ts:73](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L73) ___ @@ -187,7 +187,7 @@ ___ #### Defined in -[src/heap/binaryHeap.ts:77](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L77) +[src/heap/binaryHeap.ts:77](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L77) ___ @@ -213,7 +213,7 @@ Check if an element is in the heap. #### Defined in -[src/heap/binaryHeap.ts:81](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L81) +[src/heap/binaryHeap.ts:81](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L81) ___ @@ -239,7 +239,7 @@ Delete an element from the heap. #### Defined in -[src/heap/binaryHeap.ts:85](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L85) +[src/heap/binaryHeap.ts:85](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L85) ___ @@ -266,7 +266,7 @@ contain elements of both. Does not modify the input. #### Defined in -[src/heap/binaryHeap.ts:105](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L105) +[src/heap/binaryHeap.ts:105](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L105) ___ @@ -286,7 +286,7 @@ Retrieves, but does not remove, the top of the heap. #### Defined in -[src/heap/binaryHeap.ts:124](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L124) +[src/heap/binaryHeap.ts:124](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L124) ___ @@ -306,7 +306,7 @@ Remove the top of the heap (AKA extract). #### Defined in -[src/heap/binaryHeap.ts:128](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L128) +[src/heap/binaryHeap.ts:128](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L128) ___ @@ -332,7 +332,7 @@ Inserts an element into the heap (AKA insert, add). #### Defined in -[src/heap/binaryHeap.ts:147](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L147) +[src/heap/binaryHeap.ts:147](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L147) ___ @@ -358,7 +358,7 @@ Insert an element and then remove the top of the heap. #### Defined in -[src/heap/binaryHeap.ts:156](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L156) +[src/heap/binaryHeap.ts:156](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L156) ___ @@ -384,7 +384,7 @@ Remove the top of the heap and then insert a new element (AKA popPush). #### Defined in -[src/heap/binaryHeap.ts:169](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L169) +[src/heap/binaryHeap.ts:169](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L169) ___ @@ -406,7 +406,7 @@ Iterate through the heap in sorted order. #### Defined in -[src/heap/binaryHeap.ts:190](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L190) +[src/heap/binaryHeap.ts:190](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L190) ___ @@ -433,4 +433,4 @@ Update a specific element. #### Defined in -[src/heap/binaryHeap.ts:217](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/binaryHeap.ts#L217) +[src/heap/binaryHeap.ts:217](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/binaryHeap.ts#L217) diff --git a/docs/classes/doublylinkedlist.md b/docs/classes/doublylinkedlist.md index 4b23729..9b1f19b 100644 --- a/docs/classes/doublylinkedlist.md +++ b/docs/classes/doublylinkedlist.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / DoublyLinkedList +[dastal - v4.1.1](../README.md) / DoublyLinkedList # Class: DoublyLinkedList @@ -72,7 +72,7 @@ Instantiate the list. #### Defined in -[src/list/doublyLinkedList.ts:20](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L20) +[src/list/doublyLinkedList.ts:20](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L20) ## Accessors @@ -92,7 +92,7 @@ The number of elements in the collection. #### Defined in -[src/list/doublyLinkedList.ts:201](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L201) +[src/list/doublyLinkedList.ts:201](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L201) ## Methods @@ -116,7 +116,7 @@ An iterator through the list #### Defined in -[src/list/doublyLinkedList.ts:250](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L250) +[src/list/doublyLinkedList.ts:250](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L250) ___ @@ -143,7 +143,7 @@ Add the element at the specified index. #### Defined in -[src/list/doublyLinkedList.ts:33](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L33) +[src/list/doublyLinkedList.ts:33](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L33) ___ @@ -170,7 +170,7 @@ Add elements at the specified index. #### Defined in -[src/list/doublyLinkedList.ts:44](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L44) +[src/list/doublyLinkedList.ts:44](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L44) ___ @@ -190,7 +190,7 @@ Removes all elements. #### Defined in -[src/list/doublyLinkedList.ts:51](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L51) +[src/list/doublyLinkedList.ts:51](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L51) ___ @@ -216,7 +216,7 @@ Combines the list with multiple iterables into a new list. Does not modify the e #### Defined in -[src/list/doublyLinkedList.ts:56](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L56) +[src/list/doublyLinkedList.ts:56](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L56) ___ @@ -250,7 +250,7 @@ the copied sequence will be trimmed to fit list.size #### Defined in -[src/list/doublyLinkedList.ts:64](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L64) +[src/list/doublyLinkedList.ts:64](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L64) ___ @@ -281,7 +281,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/doublyLinkedList.ts:102](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L102) +[src/list/doublyLinkedList.ts:102](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L102) ___ @@ -307,7 +307,7 @@ Return the element at the specified index. #### Defined in -[src/list/doublyLinkedList.ts:115](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L115) +[src/list/doublyLinkedList.ts:115](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L115) ___ @@ -334,7 +334,7 @@ Update the element at the specified index. #### Defined in -[src/list/doublyLinkedList.ts:119](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L119) +[src/list/doublyLinkedList.ts:119](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L119) ___ @@ -354,7 +354,7 @@ Retrieves and removes the end of the list. #### Defined in -[src/list/doublyLinkedList.ts:129](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L129) +[src/list/doublyLinkedList.ts:129](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L129) ___ @@ -380,7 +380,7 @@ Inserts the specified value into the end of the list #### Defined in -[src/list/doublyLinkedList.ts:140](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L140) +[src/list/doublyLinkedList.ts:140](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L140) ___ @@ -409,7 +409,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/doublyLinkedList.ts:147](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L147) +[src/list/doublyLinkedList.ts:147](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L147) ___ @@ -439,7 +439,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/doublyLinkedList.ts:158](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L158) +[src/list/doublyLinkedList.ts:158](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L158) ___ @@ -466,7 +466,7 @@ Update the element at the specified index. #### Defined in -[src/list/doublyLinkedList.ts:180](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L180) +[src/list/doublyLinkedList.ts:180](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L180) ___ @@ -486,7 +486,7 @@ Retrieves and removes the first element in the list. #### Defined in -[src/list/doublyLinkedList.ts:190](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L190) +[src/list/doublyLinkedList.ts:190](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L190) ___ @@ -516,7 +516,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/doublyLinkedList.ts:205](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L205) +[src/list/doublyLinkedList.ts:205](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L205) ___ @@ -542,7 +542,7 @@ Sorts the elements in place. #### Defined in -[src/list/doublyLinkedList.ts:235](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L235) +[src/list/doublyLinkedList.ts:235](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L235) ___ @@ -571,7 +571,7 @@ Returns any deleted elements. #### Defined in -[src/list/doublyLinkedList.ts:209](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L209) +[src/list/doublyLinkedList.ts:209](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L209) ___ @@ -597,7 +597,7 @@ Inserts the specified value into the front of the list #### Defined in -[src/list/doublyLinkedList.ts:256](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L256) +[src/list/doublyLinkedList.ts:256](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L256) ___ @@ -623,7 +623,7 @@ Update the elements of the list #### Defined in -[src/list/doublyLinkedList.ts:263](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L263) +[src/list/doublyLinkedList.ts:263](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L263) ▸ **update**(`min`, `callback`): [DoublyLinkedList](doublylinkedlist.md) @@ -649,7 +649,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/doublyLinkedList.ts:264](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L264) +[src/list/doublyLinkedList.ts:264](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L264) ▸ **update**(`min`, `max`, `callback`): [DoublyLinkedList](doublylinkedlist.md) @@ -676,7 +676,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/doublyLinkedList.ts:265](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L265) +[src/list/doublyLinkedList.ts:265](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L265) ___ @@ -708,4 +708,4 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/doublyLinkedList.ts:296](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedList.ts#L296) +[src/list/doublyLinkedList.ts:296](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedList.ts#L296) diff --git a/docs/classes/inordersegmenttree.md b/docs/classes/inordersegmenttree.md index dc29396..7248933 100644 --- a/docs/classes/inordersegmenttree.md +++ b/docs/classes/inordersegmenttree.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / InOrderSegmentTree +[dastal - v4.1.1](../README.md) / InOrderSegmentTree # Class: InOrderSegmentTree @@ -61,7 +61,7 @@ Construct a new segment tree #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:33](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L33) +[src/segmentTree/inOrderSegmentTree.ts:33](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L33) ## Properties @@ -75,7 +75,7 @@ n elements require 2n memory. #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:25](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L25) +[src/segmentTree/inOrderSegmentTree.ts:25](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L25) ## Accessors @@ -95,7 +95,7 @@ The number of elements in the collection. #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:107](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L107) +[src/segmentTree/inOrderSegmentTree.ts:107](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L107) ## Methods @@ -115,7 +115,7 @@ Return an iterator through the tree's elements #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:114](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L114) +[src/segmentTree/inOrderSegmentTree.ts:114](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L114) ___ @@ -135,7 +135,7 @@ Removes all elements. #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:46](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L46) +[src/segmentTree/inOrderSegmentTree.ts:46](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L46) ___ @@ -155,7 +155,7 @@ Retrieves and removes the last element #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:50](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L50) +[src/segmentTree/inOrderSegmentTree.ts:50](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L50) ___ @@ -181,7 +181,7 @@ Appends an element to the tree #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:68](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L68) +[src/segmentTree/inOrderSegmentTree.ts:68](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L68) ___ @@ -208,7 +208,7 @@ Get the aggregated result of a given range in the tree #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:81](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L81) +[src/segmentTree/inOrderSegmentTree.ts:81](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L81) ___ @@ -236,4 +236,4 @@ Update the elements of a given range in the tree #### Defined in -[src/segmentTree/inOrderSegmentTree.ts:120](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/inOrderSegmentTree.ts#L120) +[src/segmentTree/inOrderSegmentTree.ts:120](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/inOrderSegmentTree.ts#L120) diff --git a/docs/classes/levelordersegmenttree.md b/docs/classes/levelordersegmenttree.md index 36ca80b..3de0500 100644 --- a/docs/classes/levelordersegmenttree.md +++ b/docs/classes/levelordersegmenttree.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / LevelOrderSegmentTree +[dastal - v4.1.1](../README.md) / LevelOrderSegmentTree # Class: LevelOrderSegmentTree @@ -61,7 +61,7 @@ Construct a new [SegmentTree](../interfaces/segmenttree.md) #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:39](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L39) +[src/segmentTree/levelOrderSegmentTree.ts:39](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L39) ## Properties @@ -75,7 +75,7 @@ n elements require 2^⌈log2(2n)⌉ - 1 memory: #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:23](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L23) +[src/segmentTree/levelOrderSegmentTree.ts:23](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L23) ## Accessors @@ -95,7 +95,7 @@ The number of elements in the collection. #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:123](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L123) +[src/segmentTree/levelOrderSegmentTree.ts:123](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L123) ## Methods @@ -115,7 +115,7 @@ Return an iterator through the elements #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:130](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L130) +[src/segmentTree/levelOrderSegmentTree.ts:130](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L130) ___ @@ -135,7 +135,7 @@ Removes all elements. #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:54](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L54) +[src/segmentTree/levelOrderSegmentTree.ts:54](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L54) ___ @@ -155,7 +155,7 @@ Retrieves and removes the last element #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:60](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L60) +[src/segmentTree/levelOrderSegmentTree.ts:60](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L60) ___ @@ -181,7 +181,7 @@ Appends an element to the tree #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:77](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L77) +[src/segmentTree/levelOrderSegmentTree.ts:77](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L77) ___ @@ -208,7 +208,7 @@ Get the aggregated result of a given range in the tree #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:95](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L95) +[src/segmentTree/levelOrderSegmentTree.ts:95](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L95) ___ @@ -236,4 +236,4 @@ Update the elements of a given range in the tree #### Defined in -[src/segmentTree/levelOrderSegmentTree.ts:136](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/levelOrderSegmentTree.ts#L136) +[src/segmentTree/levelOrderSegmentTree.ts:136](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/levelOrderSegmentTree.ts#L136) diff --git a/docs/classes/linkedlist.md b/docs/classes/linkedlist.md index 5d46929..2d95748 100644 --- a/docs/classes/linkedlist.md +++ b/docs/classes/linkedlist.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / LinkedList +[dastal - v4.1.1](../README.md) / LinkedList # Class: LinkedList @@ -70,7 +70,7 @@ Instantiate the list. #### Defined in -[src/list/linkedList.ts:22](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L22) +[src/list/linkedList.ts:22](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L22) ## Accessors @@ -90,7 +90,7 @@ The number of elements in the collection. #### Defined in -[src/list/linkedList.ts:208](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L208) +[src/list/linkedList.ts:208](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L208) ## Methods @@ -114,7 +114,7 @@ An iterator through the list #### Defined in -[src/list/linkedList.ts:258](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L258) +[src/list/linkedList.ts:258](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L258) ___ @@ -141,7 +141,7 @@ Add the element at the specified index. #### Defined in -[src/list/linkedList.ts:35](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L35) +[src/list/linkedList.ts:35](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L35) ___ @@ -168,7 +168,7 @@ Add elements at the specified index. #### Defined in -[src/list/linkedList.ts:46](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L46) +[src/list/linkedList.ts:46](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L46) ___ @@ -188,7 +188,7 @@ Removes all elements. #### Defined in -[src/list/linkedList.ts:55](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L55) +[src/list/linkedList.ts:55](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L55) ___ @@ -214,7 +214,7 @@ Combines the list with multiple iterables into a new list. Does not modify the e #### Defined in -[src/list/linkedList.ts:60](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L60) +[src/list/linkedList.ts:60](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L60) ___ @@ -248,7 +248,7 @@ the copied sequence will be trimmed to fit list.size #### Defined in -[src/list/linkedList.ts:68](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L68) +[src/list/linkedList.ts:68](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L68) ___ @@ -279,7 +279,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/linkedList.ts:111](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L111) +[src/list/linkedList.ts:111](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L111) ___ @@ -305,7 +305,7 @@ Return the element at the specified index. #### Defined in -[src/list/linkedList.ts:124](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L124) +[src/list/linkedList.ts:124](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L124) ___ @@ -332,7 +332,7 @@ Update the element at the specified index. #### Defined in -[src/list/linkedList.ts:131](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L131) +[src/list/linkedList.ts:131](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L131) ___ @@ -352,7 +352,7 @@ Retrieves and removes the end of the list. #### Defined in -[src/list/linkedList.ts:141](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L141) +[src/list/linkedList.ts:141](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L141) ___ @@ -378,7 +378,7 @@ Inserts the specified value into the end of the list #### Defined in -[src/list/linkedList.ts:152](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L152) +[src/list/linkedList.ts:152](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L152) ___ @@ -407,7 +407,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/linkedList.ts:159](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L159) +[src/list/linkedList.ts:159](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L159) ___ @@ -437,7 +437,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/linkedList.ts:172](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L172) +[src/list/linkedList.ts:172](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L172) ___ @@ -464,7 +464,7 @@ Update the element at the specified index. #### Defined in -[src/list/linkedList.ts:194](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L194) +[src/list/linkedList.ts:194](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L194) ___ @@ -484,7 +484,7 @@ Retrieves and removes the first element in the list. #### Defined in -[src/list/linkedList.ts:204](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L204) +[src/list/linkedList.ts:204](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L204) ___ @@ -514,7 +514,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/linkedList.ts:212](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L212) +[src/list/linkedList.ts:212](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L212) ___ @@ -540,7 +540,7 @@ Sorts the elements in place. #### Defined in -[src/list/linkedList.ts:243](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L243) +[src/list/linkedList.ts:243](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L243) ___ @@ -569,7 +569,7 @@ Returns any deleted elements. #### Defined in -[src/list/linkedList.ts:216](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L216) +[src/list/linkedList.ts:216](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L216) ___ @@ -595,7 +595,7 @@ Inserts the specified value into the front of the list #### Defined in -[src/list/linkedList.ts:264](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L264) +[src/list/linkedList.ts:264](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L264) ___ @@ -621,7 +621,7 @@ Update the elements of the list #### Defined in -[src/list/linkedList.ts:268](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L268) +[src/list/linkedList.ts:268](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L268) ▸ **update**(`min`, `callback`): [LinkedList](linkedlist.md) @@ -647,7 +647,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/linkedList.ts:269](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L269) +[src/list/linkedList.ts:269](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L269) ▸ **update**(`min`, `max`, `callback`): [LinkedList](linkedlist.md) @@ -674,7 +674,7 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/linkedList.ts:270](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L270) +[src/list/linkedList.ts:270](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L270) ___ @@ -706,4 +706,4 @@ end of the list. For example, -2 refers to the second to last element of the lis #### Defined in -[src/list/linkedList.ts:301](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedList.ts#L301) +[src/list/linkedList.ts:301](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedList.ts#L301) diff --git a/docs/classes/linkedqueue.md b/docs/classes/linkedqueue.md index d2b14bb..6a1a544 100644 --- a/docs/classes/linkedqueue.md +++ b/docs/classes/linkedqueue.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / LinkedQueue +[dastal - v4.1.1](../README.md) / LinkedQueue # Class: LinkedQueue @@ -54,7 +54,7 @@ Instantiate the queue. #### Defined in -[src/queue/linkedQueue.ts:11](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/linkedQueue.ts#L11) +[src/queue/linkedQueue.ts:11](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/linkedQueue.ts#L11) ## Accessors @@ -74,7 +74,7 @@ The number of elements in the collection. #### Defined in -[src/queue/linkedQueue.ts:37](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/linkedQueue.ts#L37) +[src/queue/linkedQueue.ts:37](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/linkedQueue.ts#L37) ## Methods @@ -98,7 +98,7 @@ An iterator through the queue #### Defined in -[src/queue/linkedQueue.ts:47](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/linkedQueue.ts#L47) +[src/queue/linkedQueue.ts:47](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/linkedQueue.ts#L47) ___ @@ -118,7 +118,7 @@ Removes all elements. #### Defined in -[src/queue/linkedQueue.ts:21](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/linkedQueue.ts#L21) +[src/queue/linkedQueue.ts:21](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/linkedQueue.ts#L21) ___ @@ -138,7 +138,7 @@ Retrieves and removes the head of this queue #### Defined in -[src/queue/linkedQueue.ts:25](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/linkedQueue.ts#L25) +[src/queue/linkedQueue.ts:25](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/linkedQueue.ts#L25) ___ @@ -164,7 +164,7 @@ Inserts the specified value into this queue #### Defined in -[src/queue/linkedQueue.ts:29](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/linkedQueue.ts#L29) +[src/queue/linkedQueue.ts:29](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/linkedQueue.ts#L29) ___ @@ -184,4 +184,4 @@ Retrieves, but does not remove, the head of this queue #### Defined in -[src/queue/linkedQueue.ts:33](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/linkedQueue.ts#L33) +[src/queue/linkedQueue.ts:33](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/linkedQueue.ts#L33) diff --git a/docs/classes/linkedstack.md b/docs/classes/linkedstack.md index be50ba9..aee4895 100644 --- a/docs/classes/linkedstack.md +++ b/docs/classes/linkedstack.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / LinkedStack +[dastal - v4.1.1](../README.md) / LinkedStack # Class: LinkedStack @@ -54,7 +54,7 @@ Instantiate the stack. #### Defined in -[src/stack/linkedStack.ts:11](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/linkedStack.ts#L11) +[src/stack/linkedStack.ts:11](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/linkedStack.ts#L11) ## Accessors @@ -74,7 +74,7 @@ The number of elements in the collection. #### Defined in -[src/stack/linkedStack.ts:40](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/linkedStack.ts#L40) +[src/stack/linkedStack.ts:40](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/linkedStack.ts#L40) ## Methods @@ -98,7 +98,7 @@ An iterator through the stack #### Defined in -[src/stack/linkedStack.ts:50](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/linkedStack.ts#L50) +[src/stack/linkedStack.ts:50](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/linkedStack.ts#L50) ___ @@ -118,7 +118,7 @@ Removes all elements. #### Defined in -[src/stack/linkedStack.ts:24](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/linkedStack.ts#L24) +[src/stack/linkedStack.ts:24](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/linkedStack.ts#L24) ___ @@ -138,7 +138,7 @@ Retrieves, but does not remove, the top of the stack #### Defined in -[src/stack/linkedStack.ts:28](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/linkedStack.ts#L28) +[src/stack/linkedStack.ts:28](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/linkedStack.ts#L28) ___ @@ -158,7 +158,7 @@ Retrieves and removes the top of the stack #### Defined in -[src/stack/linkedStack.ts:32](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/linkedStack.ts#L32) +[src/stack/linkedStack.ts:32](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/linkedStack.ts#L32) ___ @@ -184,4 +184,4 @@ Inserts an element into the stack #### Defined in -[src/stack/linkedStack.ts:36](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/linkedStack.ts#L36) +[src/stack/linkedStack.ts:36](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/linkedStack.ts#L36) diff --git a/docs/classes/skewheap.md b/docs/classes/skewheap.md index 08c902a..07c98ba 100644 --- a/docs/classes/skewheap.md +++ b/docs/classes/skewheap.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / SkewHeap +[dastal - v4.1.1](../README.md) / SkewHeap # Class: SkewHeap @@ -87,7 +87,7 @@ Instantiate a heap. #### Defined in -[src/heap/skewHeap.ts:47](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L47) +[src/heap/skewHeap.ts:47](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L47) ## Accessors @@ -107,7 +107,7 @@ The number of elements in the collection. #### Defined in -[src/heap/skewHeap.ts:168](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L168) +[src/heap/skewHeap.ts:168](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L168) ## Methods @@ -131,7 +131,7 @@ An iterator through the list #### Defined in -[src/heap/skewHeap.ts:194](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L194) +[src/heap/skewHeap.ts:194](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L194) ___ @@ -159,7 +159,7 @@ The new size of the list. #### Defined in -[src/heap/skewHeap.ts:60](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L60) +[src/heap/skewHeap.ts:60](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L60) ___ @@ -179,7 +179,7 @@ Removes all elements. #### Defined in -[src/heap/skewHeap.ts:75](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L75) +[src/heap/skewHeap.ts:75](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L75) ___ @@ -199,7 +199,7 @@ The function with which elements are sorted #### Defined in -[src/heap/skewHeap.ts:80](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L80) +[src/heap/skewHeap.ts:80](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L80) ___ @@ -227,7 +227,7 @@ Check if an element is in the heap. #### Defined in -[src/heap/skewHeap.ts:84](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L84) +[src/heap/skewHeap.ts:84](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L84) ___ @@ -255,7 +255,7 @@ Delete an element from the heap. #### Defined in -[src/heap/skewHeap.ts:93](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L93) +[src/heap/skewHeap.ts:93](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L93) ___ @@ -284,7 +284,7 @@ The heap. #### Defined in -[src/heap/skewHeap.ts:118](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L118) +[src/heap/skewHeap.ts:118](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L118) ___ @@ -306,7 +306,7 @@ The element at the top of the heap or `undefined` if empty. #### Defined in -[src/heap/skewHeap.ts:133](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L133) +[src/heap/skewHeap.ts:133](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L133) ___ @@ -328,7 +328,7 @@ The element at the top of the heap or `undefined` if empty. #### Defined in -[src/heap/skewHeap.ts:137](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L137) +[src/heap/skewHeap.ts:137](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L137) ___ @@ -356,7 +356,7 @@ The new size of the heap. #### Defined in -[src/heap/skewHeap.ts:147](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L147) +[src/heap/skewHeap.ts:147](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L147) ___ @@ -384,7 +384,7 @@ The element at the top of the heap. #### Defined in -[src/heap/skewHeap.ts:152](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L152) +[src/heap/skewHeap.ts:152](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L152) ___ @@ -412,7 +412,7 @@ The element at the top of the heap or `undefined` if empty. #### Defined in -[src/heap/skewHeap.ts:157](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L157) +[src/heap/skewHeap.ts:157](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L157) ___ @@ -434,7 +434,7 @@ Iterate through the heap in sorted order. #### Defined in -[src/heap/skewHeap.ts:172](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L172) +[src/heap/skewHeap.ts:172](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L172) ___ @@ -463,4 +463,4 @@ Update a specific element. #### Defined in -[src/heap/skewHeap.ts:200](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/skewHeap.ts#L200) +[src/heap/skewHeap.ts:200](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/skewHeap.ts#L200) diff --git a/docs/interfaces/aatreenode.md b/docs/interfaces/aatreenode.md index fe4e87c..f36a4eb 100644 --- a/docs/interfaces/aatreenode.md +++ b/docs/interfaces/aatreenode.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / AATreeNode +[dastal - v4.1.1](../README.md) / AATreeNode # Interface: AATreeNode @@ -48,7 +48,7 @@ A link to the node's left child. #### Defined in -[src/tree/binaryTreeNode.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L10) +[src/tree/binaryTreeNode.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L10) ___ @@ -60,7 +60,7 @@ The level of the node. #### Defined in -[src/tree/aaTreeNode.ts:19](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/aaTreeNode.ts#L19) +[src/tree/aaTreeNode.ts:19](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/aaTreeNode.ts#L19) ___ @@ -76,7 +76,7 @@ A link to the node's right child. #### Defined in -[src/tree/binaryTreeNode.ts:14](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L14) +[src/tree/binaryTreeNode.ts:14](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L14) ___ @@ -92,4 +92,4 @@ The value of the node #### Defined in -[src/tree/binaryTreeNode.ts:18](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L18) +[src/tree/binaryTreeNode.ts:18](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L18) diff --git a/docs/interfaces/avltreenode.md b/docs/interfaces/avltreenode.md index e6aee43..97ff3c5 100644 --- a/docs/interfaces/avltreenode.md +++ b/docs/interfaces/avltreenode.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / AVLTreeNode +[dastal - v4.1.1](../README.md) / AVLTreeNode # Interface: AVLTreeNode @@ -38,7 +38,7 @@ The delta rank of the node. #### Defined in -[src/tree/avlTreeNode.ts:13](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/avlTreeNode.ts#L13) +[src/tree/avlTreeNode.ts:13](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/avlTreeNode.ts#L13) ___ @@ -54,7 +54,7 @@ A link to the node's left child. #### Defined in -[src/tree/binaryTreeNode.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L10) +[src/tree/binaryTreeNode.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L10) ___ @@ -70,7 +70,7 @@ A link to the node's right child. #### Defined in -[src/tree/binaryTreeNode.ts:14](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L14) +[src/tree/binaryTreeNode.ts:14](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L14) ___ @@ -86,4 +86,4 @@ The value of the node #### Defined in -[src/tree/binaryTreeNode.ts:18](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L18) +[src/tree/binaryTreeNode.ts:18](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L18) diff --git a/docs/interfaces/binarytreenode.md b/docs/interfaces/binarytreenode.md index 3c80062..fddf8db 100644 --- a/docs/interfaces/binarytreenode.md +++ b/docs/interfaces/binarytreenode.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / BinaryTreeNode +[dastal - v4.1.1](../README.md) / BinaryTreeNode # Interface: BinaryTreeNode @@ -38,7 +38,7 @@ A link to the node's left child. #### Defined in -[src/tree/binaryTreeNode.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L10) +[src/tree/binaryTreeNode.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L10) ___ @@ -50,7 +50,7 @@ A link to the node's right child. #### Defined in -[src/tree/binaryTreeNode.ts:14](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L14) +[src/tree/binaryTreeNode.ts:14](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L14) ___ @@ -62,4 +62,4 @@ The value of the node #### Defined in -[src/tree/binaryTreeNode.ts:18](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/binaryTreeNode.ts#L18) +[src/tree/binaryTreeNode.ts:18](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/binaryTreeNode.ts#L18) diff --git a/docs/interfaces/collection.md b/docs/interfaces/collection.md index e418393..d3dae95 100644 --- a/docs/interfaces/collection.md +++ b/docs/interfaces/collection.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / Collection +[dastal - v4.1.1](../README.md) / Collection # Interface: Collection @@ -46,7 +46,7 @@ The number of elements in the collection. #### Defined in -[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/collection.ts#L5) +[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/collection.ts#L5) ## Methods diff --git a/docs/interfaces/doublylinkednode.md b/docs/interfaces/doublylinkednode.md index 606975d..325020b 100644 --- a/docs/interfaces/doublylinkednode.md +++ b/docs/interfaces/doublylinkednode.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / DoublyLinkedNode +[dastal - v4.1.1](../README.md) / DoublyLinkedNode # Interface: DoublyLinkedNode @@ -30,7 +30,7 @@ A link to the node's next (right) neighbor #### Defined in -[src/list/doublyLinkedNode.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedNode.ts#L10) +[src/list/doublyLinkedNode.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedNode.ts#L10) ___ @@ -42,7 +42,7 @@ A link to the node's previous (left) neighbor #### Defined in -[src/list/doublyLinkedNode.ts:14](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedNode.ts#L14) +[src/list/doublyLinkedNode.ts:14](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedNode.ts#L14) ___ @@ -54,4 +54,4 @@ The value of the node #### Defined in -[src/list/doublyLinkedNode.ts:18](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/doublyLinkedNode.ts#L18) +[src/list/doublyLinkedNode.ts:18](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/doublyLinkedNode.ts#L18) diff --git a/docs/interfaces/heap.md b/docs/interfaces/heap.md index 69b4d6f..44b1d64 100644 --- a/docs/interfaces/heap.md +++ b/docs/interfaces/heap.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / Heap +[dastal - v4.1.1](../README.md) / Heap # Interface: Heap @@ -102,7 +102,7 @@ The number of elements in the collection. #### Defined in -[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/collection.ts#L5) +[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/collection.ts#L5) ## Methods @@ -144,7 +144,7 @@ The new size of the list. #### Defined in -[src/heap/heap.ts:57](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L57) +[src/heap/heap.ts:57](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L57) ___ @@ -160,7 +160,7 @@ Removes all elements. #### Defined in -[src/heap/heap.ts:61](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L61) +[src/heap/heap.ts:61](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L61) ___ @@ -180,7 +180,7 @@ The function with which elements are sorted #### Defined in -[src/index.ts:59](https://github.com/havelessbemore/dastal/blob/d5a812e/src/index.ts#L59) +[src/index.ts:59](https://github.com/havelessbemore/dastal/blob/351eddf/src/index.ts#L59) ___ @@ -204,7 +204,7 @@ Check if an element is in the heap. #### Defined in -[src/heap/heap.ts:69](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L69) +[src/heap/heap.ts:69](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L69) ___ @@ -228,7 +228,7 @@ Delete an element from the heap. #### Defined in -[src/heap/heap.ts:77](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L77) +[src/heap/heap.ts:77](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L77) ___ @@ -253,7 +253,7 @@ The heap. #### Defined in -[src/heap/heap.ts:86](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L86) +[src/heap/heap.ts:86](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L86) ___ @@ -271,7 +271,7 @@ The element at the top of the heap or `undefined` if empty. #### Defined in -[src/heap/heap.ts:92](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L92) +[src/heap/heap.ts:92](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L92) ___ @@ -289,7 +289,7 @@ The element at the top of the heap or `undefined` if empty. #### Defined in -[src/heap/heap.ts:98](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L98) +[src/heap/heap.ts:98](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L98) ___ @@ -313,7 +313,7 @@ The new size of the heap. #### Defined in -[src/heap/heap.ts:106](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L106) +[src/heap/heap.ts:106](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L106) ___ @@ -337,7 +337,7 @@ The element at the top of the heap. #### Defined in -[src/heap/heap.ts:114](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L114) +[src/heap/heap.ts:114](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L114) ___ @@ -361,7 +361,7 @@ The element at the top of the heap or `undefined` if empty. #### Defined in -[src/heap/heap.ts:122](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L122) +[src/heap/heap.ts:122](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L122) ___ @@ -379,7 +379,7 @@ Iterate through the heap in sorted order. #### Defined in -[src/heap/heap.ts:128](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L128) +[src/heap/heap.ts:128](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L128) ___ @@ -404,4 +404,4 @@ Update a specific element. #### Defined in -[src/heap/heap.ts:137](https://github.com/havelessbemore/dastal/blob/d5a812e/src/heap/heap.ts#L137) +[src/heap/heap.ts:137](https://github.com/havelessbemore/dastal/blob/351eddf/src/heap/heap.ts#L137) diff --git a/docs/interfaces/linkednode.md b/docs/interfaces/linkednode.md index 45cf07e..8fa7a75 100644 --- a/docs/interfaces/linkednode.md +++ b/docs/interfaces/linkednode.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / LinkedNode +[dastal - v4.1.1](../README.md) / LinkedNode # Interface: LinkedNode @@ -29,7 +29,7 @@ A link to the node's neighbor. #### Defined in -[src/list/linkedNode.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedNode.ts#L10) +[src/list/linkedNode.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedNode.ts#L10) ___ @@ -41,4 +41,4 @@ The value of the node. #### Defined in -[src/list/linkedNode.ts:14](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/linkedNode.ts#L14) +[src/list/linkedNode.ts:14](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/linkedNode.ts#L14) diff --git a/docs/interfaces/list.md b/docs/interfaces/list.md index 34446b7..302df58 100644 --- a/docs/interfaces/list.md +++ b/docs/interfaces/list.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / List +[dastal - v4.1.1](../README.md) / List # Interface: List @@ -101,7 +101,7 @@ The number of elements in the collection. #### Defined in -[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/collection.ts#L5) +[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/collection.ts#L5) ## Methods @@ -144,7 +144,7 @@ The new size of the list #### Defined in -[src/list/list.ts:49](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L49) +[src/list/list.ts:49](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L49) ___ @@ -169,7 +169,7 @@ The new size of the list #### Defined in -[src/list/list.ts:58](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L58) +[src/list/list.ts:58](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L58) ___ @@ -185,7 +185,7 @@ Removes all elements. #### Defined in -[src/list/list.ts:62](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L62) +[src/list/list.ts:62](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L62) ___ @@ -211,7 +211,7 @@ or the argument itself. It does not recurse into nested iterable arguments #### Defined in -[src/list/list.ts:72](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L72) +[src/list/list.ts:72](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L72) ___ @@ -243,7 +243,7 @@ The list #### Defined in -[src/list/list.ts:88](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L88) +[src/list/list.ts:88](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L88) ___ @@ -272,7 +272,7 @@ The list on which this method was called #### Defined in -[src/list/list.ts:101](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L101) +[src/list/list.ts:101](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L101) ___ @@ -296,7 +296,7 @@ The element at the index, or `undefined` if index is invalid #### Defined in -[src/list/list.ts:109](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L109) +[src/list/list.ts:109](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L109) ___ @@ -321,7 +321,7 @@ The previous element at the index, or `undefined` if index is invalid #### Defined in -[src/list/list.ts:119](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L119) +[src/list/list.ts:119](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L119) ___ @@ -339,7 +339,7 @@ The value at the end of the list, or `undefined` if empty. #### Defined in -[src/list/list.ts:125](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L125) +[src/list/list.ts:125](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L125) ___ @@ -363,7 +363,7 @@ The new size of the list #### Defined in -[src/list/list.ts:133](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L133) +[src/list/list.ts:133](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L133) ___ @@ -390,7 +390,7 @@ The value at the index, or `undefined` if the index is invalid #### Defined in -[src/list/list.ts:144](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L144) +[src/list/list.ts:144](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L144) ___ @@ -418,7 +418,7 @@ a reference to the same list #### Defined in -[src/list/list.ts:156](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L156) +[src/list/list.ts:156](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L156) ___ @@ -443,7 +443,7 @@ The previous element in the index, or undefined if the index is invalid #### Defined in -[src/list/list.ts:165](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L165) +[src/list/list.ts:165](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L165) ___ @@ -461,7 +461,7 @@ The value at the front of the list or `undefined` if this list is empty. #### Defined in -[src/list/list.ts:171](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L171) +[src/list/list.ts:171](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L171) ___ @@ -489,7 +489,7 @@ A new list with a copy of the indicated section of the original list #### Defined in -[src/list/list.ts:183](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L183) +[src/list/list.ts:183](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L183) ___ @@ -517,7 +517,7 @@ The object this method was called on #### Defined in -[src/index.ts:50](https://github.com/havelessbemore/dastal/blob/d5a812e/src/index.ts#L50) +[src/index.ts:50](https://github.com/havelessbemore/dastal/blob/351eddf/src/index.ts#L50) ___ @@ -544,7 +544,7 @@ A new list of deleted elements #### Defined in -[src/list/list.ts:208](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L208) +[src/list/list.ts:208](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L208) ___ @@ -568,7 +568,7 @@ The new size of the list #### Defined in -[src/list/list.ts:216](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L216) +[src/list/list.ts:216](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L216) ___ @@ -592,7 +592,7 @@ The list on which this method was called #### Defined in -[src/list/list.ts:224](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L224) +[src/list/list.ts:224](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L224) ▸ **update**(`min`, `callback`): [List](list.md) @@ -616,7 +616,7 @@ The list on which this method was called #### Defined in -[src/list/list.ts:236](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L236) +[src/list/list.ts:236](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L236) ▸ **update**(`min`, `max`, `callback`): [List](list.md) @@ -641,7 +641,7 @@ The list on which this method was called #### Defined in -[src/list/list.ts:249](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L249) +[src/list/list.ts:249](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L249) ___ @@ -671,4 +671,4 @@ An iterator through the indicated section of the list #### Defined in -[src/list/list.ts:267](https://github.com/havelessbemore/dastal/blob/d5a812e/src/list/list.ts#L267) +[src/list/list.ts:267](https://github.com/havelessbemore/dastal/blob/351eddf/src/list/list.ts#L267) diff --git a/docs/interfaces/queue.md b/docs/interfaces/queue.md index b6e4d6c..479c4ff 100644 --- a/docs/interfaces/queue.md +++ b/docs/interfaces/queue.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / Queue +[dastal - v4.1.1](../README.md) / Queue # Interface: Queue @@ -58,7 +58,7 @@ The number of elements in the collection. #### Defined in -[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/collection.ts#L5) +[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/collection.ts#L5) ## Methods @@ -92,7 +92,7 @@ Removes all elements. #### Defined in -[src/queue/queue.ts:19](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/queue.ts#L19) +[src/queue/queue.ts:19](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/queue.ts#L19) ___ @@ -110,7 +110,7 @@ The value at the head of the queue or `undefined` if this queue is empty. #### Defined in -[src/queue/queue.ts:25](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/queue.ts#L25) +[src/queue/queue.ts:25](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/queue.ts#L25) ___ @@ -134,7 +134,7 @@ The new size of the queue #### Defined in -[src/queue/queue.ts:33](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/queue.ts#L33) +[src/queue/queue.ts:33](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/queue.ts#L33) ___ @@ -152,4 +152,4 @@ The value at the head of the queue or `undefined` if this queue is empty. #### Defined in -[src/queue/queue.ts:39](https://github.com/havelessbemore/dastal/blob/d5a812e/src/queue/queue.ts#L39) +[src/queue/queue.ts:39](https://github.com/havelessbemore/dastal/blob/351eddf/src/queue/queue.ts#L39) diff --git a/docs/interfaces/segmenttree.md b/docs/interfaces/segmenttree.md index a3142d3..0f8dc4a 100644 --- a/docs/interfaces/segmenttree.md +++ b/docs/interfaces/segmenttree.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / SegmentTree +[dastal - v4.1.1](../README.md) / SegmentTree # Interface: SegmentTree @@ -48,7 +48,7 @@ The number of elements in the collection. #### Defined in -[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/collection.ts#L5) +[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/collection.ts#L5) ## Methods @@ -82,7 +82,7 @@ Removes all elements. #### Defined in -[src/segmentTree/segmentTree.ts:7](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/segmentTree.ts#L7) +[src/segmentTree/segmentTree.ts:7](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/segmentTree.ts#L7) ___ @@ -100,7 +100,7 @@ The last element or `undefined` if empty. #### Defined in -[src/segmentTree/segmentTree.ts:13](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/segmentTree.ts#L13) +[src/segmentTree/segmentTree.ts:13](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/segmentTree.ts#L13) ___ @@ -124,7 +124,7 @@ The new size of the tree #### Defined in -[src/segmentTree/segmentTree.ts:21](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/segmentTree.ts#L21) +[src/segmentTree/segmentTree.ts:21](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/segmentTree.ts#L21) ___ @@ -149,7 +149,7 @@ The aggregated result for range [min, max) #### Defined in -[src/segmentTree/segmentTree.ts:30](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/segmentTree.ts#L30) +[src/segmentTree/segmentTree.ts:30](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/segmentTree.ts#L30) ___ @@ -173,4 +173,4 @@ Update the elements of a given range in the tree #### Defined in -[src/segmentTree/segmentTree.ts:38](https://github.com/havelessbemore/dastal/blob/d5a812e/src/segmentTree/segmentTree.ts#L38) +[src/segmentTree/segmentTree.ts:38](https://github.com/havelessbemore/dastal/blob/351eddf/src/segmentTree/segmentTree.ts#L38) diff --git a/docs/interfaces/sortable.md b/docs/interfaces/sortable.md index 23a0ae6..d2cc77f 100644 --- a/docs/interfaces/sortable.md +++ b/docs/interfaces/sortable.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / Sortable +[dastal - v4.1.1](../README.md) / Sortable # Interface: Sortable @@ -44,4 +44,4 @@ The object this method was called on #### Defined in -[src/index.ts:50](https://github.com/havelessbemore/dastal/blob/d5a812e/src/index.ts#L50) +[src/index.ts:50](https://github.com/havelessbemore/dastal/blob/351eddf/src/index.ts#L50) diff --git a/docs/interfaces/sorted.md b/docs/interfaces/sorted.md index 5c13e81..f92bc7c 100644 --- a/docs/interfaces/sorted.md +++ b/docs/interfaces/sorted.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / Sorted +[dastal - v4.1.1](../README.md) / Sorted # Interface: Sorted @@ -38,4 +38,4 @@ The function with which elements are sorted #### Defined in -[src/index.ts:59](https://github.com/havelessbemore/dastal/blob/d5a812e/src/index.ts#L59) +[src/index.ts:59](https://github.com/havelessbemore/dastal/blob/351eddf/src/index.ts#L59) diff --git a/docs/interfaces/sortedtree.md b/docs/interfaces/sortedtree.md index e14c92e..b8c646f 100644 --- a/docs/interfaces/sortedtree.md +++ b/docs/interfaces/sortedtree.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / SortedTree +[dastal - v4.1.1](../README.md) / SortedTree # Interface: SortedTree @@ -58,7 +58,7 @@ The number of elements in the collection. #### Defined in -[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/collection.ts#L5) +[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/collection.ts#L5) ## Methods @@ -104,7 +104,7 @@ The tree object. #### Defined in -[src/tree/tree.ts:38](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L38) +[src/tree/tree.ts:38](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L38) ___ @@ -124,7 +124,7 @@ Removes all elements. #### Defined in -[src/tree/tree.ts:42](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L42) +[src/tree/tree.ts:42](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L42) ___ @@ -144,7 +144,7 @@ The function with which elements are sorted #### Defined in -[src/index.ts:59](https://github.com/havelessbemore/dastal/blob/d5a812e/src/index.ts#L59) +[src/index.ts:59](https://github.com/havelessbemore/dastal/blob/351eddf/src/index.ts#L59) ___ @@ -172,7 +172,7 @@ Delete an element from the tree. #### Defined in -[src/tree/tree.ts:50](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L50) +[src/tree/tree.ts:50](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L50) ___ @@ -200,7 +200,7 @@ Check if an element is in the tree. #### Defined in -[src/tree/tree.ts:58](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L58) +[src/tree/tree.ts:58](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L58) ___ @@ -216,7 +216,7 @@ Get the maximum element. #### Defined in -[src/tree/sortedTree.ts:11](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/sortedTree.ts#L11) +[src/tree/sortedTree.ts:11](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/sortedTree.ts#L11) ___ @@ -232,7 +232,7 @@ Get the minimum element. #### Defined in -[src/tree/sortedTree.ts:15](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/sortedTree.ts#L15) +[src/tree/sortedTree.ts:15](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/sortedTree.ts#L15) ___ @@ -248,7 +248,7 @@ Remove the maximum element. #### Defined in -[src/tree/sortedTree.ts:19](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/sortedTree.ts#L19) +[src/tree/sortedTree.ts:19](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/sortedTree.ts#L19) ___ @@ -264,7 +264,7 @@ Remove the minimum element. #### Defined in -[src/tree/sortedTree.ts:23](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/sortedTree.ts#L23) +[src/tree/sortedTree.ts:23](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/sortedTree.ts#L23) ___ @@ -282,7 +282,7 @@ Iterate through the tree in sorted order (i.e in-order traversal). #### Defined in -[src/tree/sortedTree.ts:29](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/sortedTree.ts#L29) +[src/tree/sortedTree.ts:29](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/sortedTree.ts#L29) ___ @@ -311,4 +311,4 @@ Update a specific element. #### Defined in -[src/tree/tree.ts:67](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L67) +[src/tree/tree.ts:67](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L67) diff --git a/docs/interfaces/stack.md b/docs/interfaces/stack.md index 46093cf..1a93bf5 100644 --- a/docs/interfaces/stack.md +++ b/docs/interfaces/stack.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / Stack +[dastal - v4.1.1](../README.md) / Stack # Interface: Stack @@ -56,7 +56,7 @@ The number of elements in the collection. #### Defined in -[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/collection.ts#L5) +[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/collection.ts#L5) ## Methods @@ -90,7 +90,7 @@ Removes all elements. #### Defined in -[src/stack/stack.ts:17](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/stack.ts#L17) +[src/stack/stack.ts:17](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/stack.ts#L17) ___ @@ -108,7 +108,7 @@ The element at the top of the stack or `undefined` if empty. #### Defined in -[src/stack/stack.ts:23](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/stack.ts#L23) +[src/stack/stack.ts:23](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/stack.ts#L23) ___ @@ -126,7 +126,7 @@ The element at the top of the stack or `undefined` if empty. #### Defined in -[src/stack/stack.ts:29](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/stack.ts#L29) +[src/stack/stack.ts:29](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/stack.ts#L29) ___ @@ -150,4 +150,4 @@ The new size of the stack #### Defined in -[src/stack/stack.ts:37](https://github.com/havelessbemore/dastal/blob/d5a812e/src/stack/stack.ts#L37) +[src/stack/stack.ts:37](https://github.com/havelessbemore/dastal/blob/351eddf/src/stack/stack.ts#L37) diff --git a/docs/interfaces/tree.md b/docs/interfaces/tree.md index b90b3c9..ff53430 100644 --- a/docs/interfaces/tree.md +++ b/docs/interfaces/tree.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / Tree +[dastal - v4.1.1](../README.md) / Tree # Interface: Tree @@ -71,7 +71,7 @@ The number of elements in the collection. #### Defined in -[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/collection.ts#L5) +[src/collection/collection.ts:5](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/collection.ts#L5) ## Methods @@ -113,7 +113,7 @@ The tree object. #### Defined in -[src/tree/tree.ts:38](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L38) +[src/tree/tree.ts:38](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L38) ___ @@ -129,7 +129,7 @@ Removes all elements. #### Defined in -[src/tree/tree.ts:42](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L42) +[src/tree/tree.ts:42](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L42) ___ @@ -153,7 +153,7 @@ Delete an element from the tree. #### Defined in -[src/tree/tree.ts:50](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L50) +[src/tree/tree.ts:50](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L50) ___ @@ -177,7 +177,7 @@ Check if an element is in the tree. #### Defined in -[src/tree/tree.ts:58](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L58) +[src/tree/tree.ts:58](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L58) ___ @@ -202,4 +202,4 @@ Update a specific element. #### Defined in -[src/tree/tree.ts:67](https://github.com/havelessbemore/dastal/blob/d5a812e/src/tree/tree.ts#L67) +[src/tree/tree.ts:67](https://github.com/havelessbemore/dastal/blob/351eddf/src/tree/tree.ts#L67) diff --git a/docs/modules/arrayutils.md b/docs/modules/arrayutils.md index 8dd356b..47b6aaa 100644 --- a/docs/modules/arrayutils.md +++ b/docs/modules/arrayutils.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / ArrayUtils +[dastal - v4.1.1](../README.md) / ArrayUtils # Namespace: ArrayUtils @@ -31,7 +31,7 @@ submit a pull request with details supporting a new max length. #### Defined in -[src/collection/arrayUtils.ts:13](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/arrayUtils.ts#L13) +[src/collection/arrayUtils.ts:13](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/arrayUtils.ts#L13) ___ @@ -50,7 +50,7 @@ please submit a bug with your environment details and a new max length. #### Defined in -[src/collection/arrayUtils.ts:24](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/arrayUtils.ts#L24) +[src/collection/arrayUtils.ts:24](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/arrayUtils.ts#L24) ## Functions @@ -80,7 +80,7 @@ obj is T[] #### Defined in -[src/collection/arrayUtils.ts:32](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/arrayUtils.ts#L32) +[src/collection/arrayUtils.ts:32](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/arrayUtils.ts#L32) ___ @@ -113,7 +113,7 @@ obj is T[] #### Defined in -[src/collection/arrayUtils.ts:45](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/arrayUtils.ts#L45) +[src/collection/arrayUtils.ts:45](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/arrayUtils.ts#L45) ___ @@ -148,4 +148,4 @@ Contrary to Array.splice, this will not throw an error if too many new elements #### Defined in -[src/collection/arrayUtils.ts:63](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/arrayUtils.ts#L63) +[src/collection/arrayUtils.ts:63](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/arrayUtils.ts#L63) diff --git a/docs/modules/iteratorutils.md b/docs/modules/iteratorutils.md index b2599c7..51b3828 100644 --- a/docs/modules/iteratorutils.md +++ b/docs/modules/iteratorutils.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / IteratorUtils +[dastal - v4.1.1](../README.md) / IteratorUtils # Namespace: IteratorUtils @@ -41,7 +41,7 @@ Get an iterator that always returns a given value. #### Defined in -[src/collection/iteratorUtils.ts:4](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/iteratorUtils.ts#L4) +[src/collection/iteratorUtils.ts:4](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/iteratorUtils.ts#L4) ___ @@ -70,7 +70,7 @@ Get an iterator that returns a value a given amount of times. #### Defined in -[src/collection/iteratorUtils.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/iteratorUtils.ts#L10) +[src/collection/iteratorUtils.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/iteratorUtils.ts#L10) ___ @@ -101,7 +101,7 @@ Iterate through the first num elements of an iterator. #### Defined in -[src/collection/iteratorUtils.ts:29](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/iteratorUtils.ts#L29) +[src/collection/iteratorUtils.ts:29](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/iteratorUtils.ts#L29) ___ @@ -129,7 +129,7 @@ Join multiple iterators into one. #### Defined in -[src/collection/iteratorUtils.ts:46](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/iteratorUtils.ts#L46) +[src/collection/iteratorUtils.ts:46](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/iteratorUtils.ts#L46) ___ @@ -151,7 +151,7 @@ Get an empty iterator. #### Defined in -[src/collection/iteratorUtils.ts:70](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/iteratorUtils.ts#L70) +[src/collection/iteratorUtils.ts:70](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/iteratorUtils.ts#L70) ___ @@ -179,7 +179,7 @@ Wrap a value in an iterator. #### Defined in -[src/collection/iteratorUtils.ts:76](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/iteratorUtils.ts#L76) +[src/collection/iteratorUtils.ts:76](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/iteratorUtils.ts#L76) ___ @@ -210,7 +210,7 @@ Skip the next num elements of an iterator. #### Defined in -[src/collection/iteratorUtils.ts:95](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/iteratorUtils.ts#L95) +[src/collection/iteratorUtils.ts:95](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/iteratorUtils.ts#L95) ___ @@ -241,4 +241,4 @@ Split an iterator into multiple iterators of a given length. #### Defined in -[src/collection/iteratorUtils.ts:114](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/iteratorUtils.ts#L114) +[src/collection/iteratorUtils.ts:114](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/iteratorUtils.ts#L114) diff --git a/docs/modules/numberutils.md b/docs/modules/numberutils.md index df23ca5..fc1e2e7 100644 --- a/docs/modules/numberutils.md +++ b/docs/modules/numberutils.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / NumberUtils +[dastal - v4.1.1](../README.md) / NumberUtils # Namespace: NumberUtils @@ -37,7 +37,7 @@ The clamped number #### Defined in -[src/math/numberUtils.ts:12](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/numberUtils.ts#L12) +[src/math/numberUtils.ts:12](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/numberUtils.ts#L12) ___ @@ -63,7 +63,7 @@ Wraps a number if outside a given range #### Defined in -[src/math/numberUtils.ts:58](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/numberUtils.ts#L58) +[src/math/numberUtils.ts:58](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/numberUtils.ts#L58) ___ @@ -94,7 +94,7 @@ f(x, min, max) = { #### Defined in -[src/math/numberUtils.ts:29](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/numberUtils.ts#L29) +[src/math/numberUtils.ts:29](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/numberUtils.ts#L29) ___ @@ -125,4 +125,4 @@ f(x, min, max) = { #### Defined in -[src/math/numberUtils.ts:46](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/numberUtils.ts#L46) +[src/math/numberUtils.ts:46](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/numberUtils.ts#L46) diff --git a/docs/modules/stringutils.md b/docs/modules/stringutils.md index 8415318..22f59c1 100644 --- a/docs/modules/stringutils.md +++ b/docs/modules/stringutils.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / StringUtils +[dastal - v4.1.1](../README.md) / StringUtils # Namespace: StringUtils @@ -30,4 +30,4 @@ Pad a string from both sides. #### Defined in -[src/collection/stringUtils.ts:4](https://github.com/havelessbemore/dastal/blob/d5a812e/src/collection/stringUtils.ts#L4) +[src/collection/stringUtils.ts:4](https://github.com/havelessbemore/dastal/blob/351eddf/src/collection/stringUtils.ts#L4) diff --git a/docs/modules/u32.md b/docs/modules/u32.md index 5975d7d..b3b1435 100644 --- a/docs/modules/u32.md +++ b/docs/modules/u32.md @@ -1,4 +1,4 @@ -[dastal - v4.1.0](../README.md) / u32 +[dastal - v4.1.1](../README.md) / u32 # Namespace: u32 @@ -40,7 +40,7 @@ Get the number of bits set of a 32-bit unsigned number ([source](https://graphic #### Defined in -[src/math/u32.ts:10](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L10) +[src/math/u32.ts:10](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L10) ___ @@ -66,7 +66,7 @@ The inverted number #### Defined in -[src/math/u32.ts:27](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L27) +[src/math/u32.ts:27](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L27) ___ @@ -90,7 +90,7 @@ Example: 8 (1000) -> true #### Defined in -[src/math/u32.ts:38](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L38) +[src/math/u32.ts:38](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L38) ___ @@ -114,7 +114,7 @@ The lowest bit set #### Defined in -[src/math/u32.ts:48](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L48) +[src/math/u32.ts:48](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L48) ___ @@ -138,7 +138,7 @@ Get the Least Significant Power of a 32-bit unsigned number #### Defined in -[src/math/u32.ts:62](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L62) +[src/math/u32.ts:62](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L62) ___ @@ -162,7 +162,7 @@ Example: 54 (110110) -> 6 (000110) #### Defined in -[src/math/u32.ts:72](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L72) +[src/math/u32.ts:72](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L72) ___ @@ -186,7 +186,7 @@ Get the Most Significant Bit of a 32-bit unsigned number #### Defined in -[src/math/u32.ts:93](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L93) +[src/math/u32.ts:93](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L93) ___ @@ -210,7 +210,7 @@ Get the Most Significant Power of a 32-bit unsigned number #### Defined in -[src/math/u32.ts:108](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L108) +[src/math/u32.ts:108](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L108) ___ @@ -234,7 +234,7 @@ Example: 50 (110010) -> 48 (110000) #### Defined in -[src/math/u32.ts:123](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L123) +[src/math/u32.ts:123](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L123) ___ @@ -258,7 +258,7 @@ Example: 50 (110010) -> 19 (010011) #### Defined in -[src/math/u32.ts:138](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L138) +[src/math/u32.ts:138](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L138) ___ @@ -280,4 +280,4 @@ Turn a number into an unsigned 32-bit number #### Defined in -[src/math/u32.ts:150](https://github.com/havelessbemore/dastal/blob/d5a812e/src/math/u32.ts#L150) +[src/math/u32.ts:150](https://github.com/havelessbemore/dastal/blob/351eddf/src/math/u32.ts#L150) diff --git a/package.json b/package.json index ebd0592..cc82d3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dastal", - "version": "4.1.0", + "version": "4.1.1", "description": "Data Structures & Algorithms implementations", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", diff --git a/src/segmentTree/inOrderSegmentTree.ts b/src/segmentTree/inOrderSegmentTree.ts index bd21d07..8a7f608 100644 --- a/src/segmentTree/inOrderSegmentTree.ts +++ b/src/segmentTree/inOrderSegmentTree.ts @@ -22,7 +22,7 @@ export class InOrderSegmentTree implements SegmentTree { * * n elements require 2n memory. */ - static readonly MAX_SIZE: number = MAX_ARRAY_LENGTH >>> 1; + static readonly MAX_SIZE: number = Math.floor(MAX_ARRAY_LENGTH / 2); /** * The set of elements and aggregation nodes for the tree */ diff --git a/src/segmentTree/levelOrderSegmentTree.ts b/src/segmentTree/levelOrderSegmentTree.ts index 69e3c64..3c052f9 100644 --- a/src/segmentTree/levelOrderSegmentTree.ts +++ b/src/segmentTree/levelOrderSegmentTree.ts @@ -6,7 +6,7 @@ import { isArray, MAX_ARRAY_LENGTH } from 'src/collection/arrayUtils'; import { isCollection } from 'src/collection'; import { Collection } from 'src/collection/collection'; import { CombineFn } from '..'; -import { isPow2, lsp, msp } from '../math/u32'; +import { lsp, msp } from '../math/u32'; import { SegmentTree } from './segmentTree'; /** @@ -20,7 +20,7 @@ export class LevelOrderSegmentTree implements SegmentTree { * * n elements require 2^⌈log2(2n)⌉ - 1 memory: */ - static readonly MAX_SIZE: number = (MAX_ARRAY_LENGTH + 1) / 2; + static readonly MAX_SIZE: number = 2 ** Math.floor(Math.log2(MAX_ARRAY_LENGTH + 1) - 1); /** * The internal array used to store elements and aggregation nodes */ @@ -67,7 +67,7 @@ export class LevelOrderSegmentTree implements SegmentTree { const out = this.array[--this.length]; // If level is <= 1/4 full - if (this.length <= (this.array.length + 1) >>> 2) { + if (this.size <= (this.level + 1) >>> 2) { this.shrink(); } @@ -276,11 +276,11 @@ export class LevelOrderSegmentTree implements SegmentTree { } // Update the tree - this.level = 1; - for (let max = min + 1; mask; this.level += this.level + 1) { + this.level = 0; + for (let max = min + 1; mask; min += min + 1) { + this.level += this.level + 1; this.array.copyWithin(this.level, min, max); mask >>>= 1; - min += min + 1; max += max + 2 + +((length & mask) > 0); }