linked-list-typed 2.4.3 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/index.cjs +62 -36
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +62 -35
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +62 -37
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +62 -36
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +23 -0
  10. package/dist/types/common/index.d.ts +1 -0
  11. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  12. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +15 -5
  13. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  14. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +7 -1
  15. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -0
  16. package/dist/types/data-structures/graph/directed-graph.d.ts +3 -2
  17. package/dist/types/data-structures/graph/undirected-graph.d.ts +16 -2
  18. package/dist/types/data-structures/hash/hash-map.d.ts +2 -2
  19. package/dist/types/data-structures/heap/heap.d.ts +3 -7
  20. package/dist/types/data-structures/queue/deque.d.ts +41 -1
  21. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
  22. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
  23. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
  24. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
  25. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  26. package/dist/types/types/data-structures/queue/deque.d.ts +6 -0
  27. package/dist/types/types/data-structures/stack/stack.d.ts +1 -1
  28. package/dist/umd/linked-list-typed.js +60 -33
  29. package/dist/umd/linked-list-typed.js.map +1 -1
  30. package/dist/umd/linked-list-typed.min.js +1 -1
  31. package/dist/umd/linked-list-typed.min.js.map +1 -1
  32. package/package.json +2 -2
  33. package/src/common/error.ts +60 -0
  34. package/src/common/index.ts +2 -0
  35. package/src/data-structures/base/iterable-element-base.ts +5 -4
  36. package/src/data-structures/binary-tree/binary-indexed-tree.ts +6 -5
  37. package/src/data-structures/binary-tree/binary-tree.ts +121 -49
  38. package/src/data-structures/binary-tree/bst.ts +12 -4
  39. package/src/data-structures/binary-tree/red-black-tree.ts +20 -0
  40. package/src/data-structures/binary-tree/tree-map.ts +8 -7
  41. package/src/data-structures/binary-tree/tree-multi-map.ts +4 -4
  42. package/src/data-structures/binary-tree/tree-multi-set.ts +10 -9
  43. package/src/data-structures/binary-tree/tree-set.ts +7 -6
  44. package/src/data-structures/graph/abstract-graph.ts +124 -19
  45. package/src/data-structures/graph/directed-graph.ts +8 -4
  46. package/src/data-structures/graph/map-graph.ts +1 -1
  47. package/src/data-structures/graph/undirected-graph.ts +99 -4
  48. package/src/data-structures/hash/hash-map.ts +19 -6
  49. package/src/data-structures/heap/heap.ts +21 -17
  50. package/src/data-structures/heap/max-heap.ts +2 -3
  51. package/src/data-structures/linked-list/doubly-linked-list.ts +4 -4
  52. package/src/data-structures/linked-list/singly-linked-list.ts +15 -9
  53. package/src/data-structures/matrix/matrix.ts +9 -10
  54. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -3
  55. package/src/data-structures/queue/deque.ts +72 -4
  56. package/src/data-structures/stack/stack.ts +1 -1
  57. package/src/data-structures/trie/trie.ts +12 -6
  58. package/src/types/data-structures/binary-tree/avl-tree.ts +1 -1
  59. package/src/types/data-structures/binary-tree/red-black-tree.ts +1 -1
  60. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -1
  61. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -1
  62. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  63. package/src/types/data-structures/queue/deque.ts +7 -0
  64. package/src/types/data-structures/stack/stack.ts +1 -1
  65. package/src/utils/utils.ts +4 -2
@@ -1,4 +1,4 @@
1
- "use strict";var linkedListTyped=(()=>{var _=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var D=(o,s,e)=>s in o?_(o,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[s]=e;var C=(o,s)=>{for(var e in s)_(o,e,{get:s[e],enumerable:!0})},A=(o,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of S(s))!M.call(o,n)&&n!==e&&_(o,n,{get:()=>s[n],enumerable:!(t=I(s,n))||t.enumerable});return o};var O=o=>A(_({},"__esModule",{value:!0}),o);var d=(o,s,e)=>D(o,typeof s!="symbol"?s+"":s,e);var K={};C(K,{DFSOperation:()=>w,DoublyLinkedList:()=>m,DoublyLinkedListNode:()=>L,Range:()=>x,SinglyLinkedList:()=>N,SinglyLinkedListNode:()=>E,SkipList:()=>v,SkipListNode:()=>g});var p=class{constructor(s){d(this,"_toElementFn");if(s){let{toElementFn:e}=s;if(typeof e=="function")this._toElementFn=e;else if(e)throw new TypeError("toElementFn must be a function type")}}get toElementFn(){return this._toElementFn}*[Symbol.iterator](...s){yield*this._getIterator(...s)}*values(){for(let s of this)yield s}every(s,e){let t=0;for(let n of this)if(e===void 0){if(!s(n,t++,this))return!1}else if(!s.call(e,n,t++,this))return!1;return!0}some(s,e){let t=0;for(let n of this)if(e===void 0){if(s(n,t++,this))return!0}else if(s.call(e,n,t++,this))return!0;return!1}forEach(s,e){let t=0;for(let n of this)e===void 0?s(n,t++,this):s.call(e,n,t++,this)}find(s,e){let t=0;for(let n of this)if(e===void 0){if(s(n,t++,this))return n}else if(s.call(e,n,t++,this))return n}has(s){for(let e of this)if(e===s)return!0;return!1}reduce(s,e){let t=0,n=this[Symbol.iterator](),i;if(arguments.length>=2)i=e;else{let r=n.next();if(r.done)throw new TypeError("Reduce of empty structure with no initial value");i=r.value,t=1}for(let r of n)i=s(i,r,t++,this);return i}toArray(){return[...this]}toVisual(){return[...this]}print(){console.log(this.toVisual())}};var f=class{constructor(s){d(this,"_value");d(this,"_next");this._value=s,this._next=void 0}get value(){return this._value}set value(s){this._value=s}get next(){return this._next}set next(s){this._next=s}},k=class o extends p{constructor(e){super(e);d(this,"_maxLen",-1);if(e){let{maxLen:t}=e;typeof t=="number"&&t>0&&t%1===0&&(this._maxLen=t)}}get maxLen(){return this._maxLen}indexOf(e,t=0){if(this.length===0)return-1;t<0&&(t=this.length+t),t<0&&(t=0);for(let n=t;n<this.length;n++)if(this.at(n)===e)return n;return-1}lastIndexOf(e,t=this.length-1){if(this.length===0)return-1;t>=this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(let n=t;n>=0;n--)if(this.at(n)===e)return n;return-1}findIndex(e,t){for(let n=0;n<this.length;n++){let i=this.at(n);if(i!==void 0&&e.call(t,i,n,this))return n}return-1}concat(...e){let t=this.clone();for(let n of e)n instanceof o?t.pushMany(n):t.push(n);return t}sort(e){let t=this.toArray();t.sort(e),this.clear();for(let n of t)this.push(n);return this}splice(e,t=0,...n){let i=this._createInstance();e=e<0?this.length+e:e,e=Math.max(0,Math.min(e,this.length)),t=Math.max(0,Math.min(t,this.length-e));for(let r=0;r<t;r++){let l=this.deleteAt(e);l!==void 0&&i.push(l)}for(let r=0;r<n.length;r++)this.addAt(e+r,n[r]);return i}join(e=","){return this.toArray().join(e)}toReversedArray(){let e=[];for(let t=this.length-1;t>=0;t--)e.push(this.at(t));return e}reduceRight(e,t){let n=t!=null?t:0;for(let i=this.length-1;i>=0;i--)n=e(n,this.at(i),i,this);return n}slice(e=0,t=this.length){e=e<0?this.length+e:e,t=t<0?this.length+t:t;let n=this._createInstance();for(let i=e;i<t;i++)n.push(this.at(i));return n}fill(e,t=0,n=this.length){if(t=t<0?this.length+t:t,n=n<0?this.length+n:n,t<0&&(t=0),n>this.length&&(n=this.length),t>=n)return this;for(let i=t;i<n;i++)this.setAt(i,e);return this}},c=class extends k{constructor(s){if(super(s),s){let{maxLen:e}=s;typeof e=="number"&&e>0&&e%1===0&&(this._maxLen=e)}}indexOf(s,e=0){let t=this._getIterator(),n=t.next(),i=0;for(;i<e;)n=t.next(),i++;for(;!n.done;){if(n.value===s)return i;n=t.next(),i++}return-1}lastIndexOf(s,e=this.length-1){let t=this._getReverseIterator(),n=t.next(),i=this.length-1;for(;i>e;)n=t.next(),i--;for(;!n.done;){if(n.value===s)return i;n=t.next(),i--}return-1}concat(...s){let e=this.clone();for(let t of s)t instanceof k?e.pushMany(t):e.push(t);return e}slice(s=0,e=this.length){s=s<0?this.length+s:s,e=e<0?this.length+e:e;let t=this._createInstance(),n=this._getIterator(),i=n.next(),r=0;for(;r<s;)i=n.next(),r++;for(let l=s;l<e;l++)t.push(i.value),i=n.next();return t}splice(s,e=0,...t){let n=this._createInstance();s=s<0?this.length+s:s,s=Math.max(0,Math.min(s,this.length)),e=Math.max(0,e);let i=0,r,l,h=this._getNodeIterator();for(let a of h){if(i===s){r=a;break}l=a,i++}for(let a=0;a<e&&r;a++){n.push(r.value);let u=r.next;this.delete(r),r=u}for(let a=0;a<t.length;a++)l?(this.addAfter(l,t[a]),l=l.next):(this.addAt(0,t[a]),l=this._getNodeIterator().next().value);return n}reduceRight(s,e){let t=e!=null?e:0,n=this.length-1;for(let i of this._getReverseIterator())t=s(t,i,n--,this);return t}};var E=class extends f{constructor(e){super(e);d(this,"_next");this._value=e,this._next=void 0}get next(){return this._next}set next(e){this._next=e}},N=class extends c{constructor(e=[],t){super(t);d(this,"_equals",Object.is);d(this,"_head");d(this,"_tail");d(this,"_length",0);this.pushMany(e)}get head(){return this._head}get tail(){return this._tail}get length(){return this._length}get first(){var e;return(e=this.head)==null?void 0:e.value}get last(){var e;return(e=this.tail)==null?void 0:e.value}static from(e,t){let n=new this([],t);for(let i of e)n.push(i);return n}push(e){let t=this._ensureNode(e);return this.head?(this.tail.next=t,this._tail=t):this._head=this._tail=t,this._length++,this._maxLen>0&&this.length>this._maxLen&&this.shift(),!0}pop(){if(!this.head)return;if(this.head===this.tail){let n=this.head.value;return this._head=void 0,this._tail=void 0,this._length--,n}let e=this.head;for(;e.next!==this.tail;)e=e.next;let t=this.tail.value;return e.next=void 0,this._tail=e,this._length--,t}shift(){if(!this.head)return;let e=this.head;return this._head=this.head.next,this._head||(this._tail=void 0),this._length--,e.value}unshift(e){let t=this._ensureNode(e);return this.head?(t.next=this.head,this._head=t):this._head=this._tail=t,this._length++,!0}pushMany(e){let t=[];for(let n of e)this.toElementFn?t.push(this.push(this.toElementFn(n))):t.push(this.push(n));return t}unshiftMany(e){let t=[];for(let n of e)this.toElementFn?t.push(this.unshift(this.toElementFn(n))):t.push(this.unshift(n));return t}search(e){let t=this._ensurePredicate(e),n=this.head;for(;n;){if(t(n))return n.value;n=n.next}}at(e){if(e<0||e>=this._length)return;let t=this.head;for(let n=0;n<e;n++)t=t.next;return t.value}isNode(e){return e instanceof E}getNodeAt(e){if(e<0||e>=this._length)return;let t=this.head;for(let n=0;n<e;n++)t=t.next;return t}deleteAt(e){if(e<0||e>=this._length)return;if(e===0)return this.shift();let t=this.getNodeAt(e),n=this._getPrevNode(t),i=t.value;return n.next=t.next,t===this.tail&&(this._tail=n),this._length--,i}delete(e){if(e===void 0||!this.head)return!1;let t=this.isNode(e)?e:this.getNode(e);if(!t)return!1;let n=this._getPrevNode(t);return n?(n.next=t.next,t===this.tail&&(this._tail=n)):(this._head=t.next,t===this.tail&&(this._tail=void 0)),this._length--,!0}addAt(e,t){if(e<0||e>this._length)return!1;if(e===0)return this.unshift(t);if(e===this._length)return this.push(t);let n=this._ensureNode(t),i=this.getNodeAt(e-1);return n.next=i.next,i.next=n,this._length++,!0}setAt(e,t){let n=this.getNodeAt(e);return n?(n.value=t,!0):!1}isEmpty(){return this._length===0}clear(){this._head=void 0,this._tail=void 0,this._length=0}reverse(){if(!this.head||this.head===this.tail)return this;let e,t=this.head,n;for(;t;)n=t.next,t.next=e,e=t,t=n;return[this._head,this._tail]=[this.tail,this.head],this}getNode(e){if(e===void 0)return;if(this.isNode(e))return e;let t=this._ensurePredicate(e),n=this.head;for(;n;){if(t(n))return n;n=n.next}}addBefore(e,t){let n=this.getNode(e);if(!n)return!1;let i=this._getPrevNode(n),r=this._ensureNode(t);return i?(i.next=r,r.next=n,this._length++):(r.next=this._head,this._head=r,this._tail||(this._tail=r),this._length++),!0}addAfter(e,t){let n=this.getNode(e);if(!n)return!1;let i=this._ensureNode(t);return i.next=n.next,n.next=i,n===this.tail&&(this._tail=i),this._length++,!0}splice(e,t=0,...n){e=Math.max(0,Math.min(e,this.length)),t=Math.max(0,t);let i=this._createInstance(),r=e===0?void 0:this.getNodeAt(e-1),l=r?r.next:this.head,h=0;for(;h<t&&l;)i.push(l.value),l=l.next,h++;let a=l;if(r?r.next=a:this._head=a,a||(this._tail=r),n.length>0){let u,b;for(let R of n){let y=this._ensureNode(R);u||(u=y),b&&(b.next=y),b=y}r?r.next=u:this._head=u,b.next=a,a||(this._tail=b)}return this._length+=n.length-h,this._length===0&&(this._head=void 0,this._tail=void 0),i}countOccurrences(e){let t=U(e,this._equals),n=0,i=this.head;for(;i;)t(i)&&n++,i=i.next;return n}setEquality(e){return this._equals=e,this}deleteWhere(e){let t,n=this.head,i=0;for(;n;){if(e(n.value,i++,this))return t?(t.next=n.next,n===this._tail&&(this._tail=t)):(this._head=n.next,n===this._tail&&(this._tail=void 0)),this._length--,!0;t=n,n=n.next}return!1}clone(){let e=this._createInstance();for(let t of this)e.push(t);return e}filter(e,t){let n=this._createInstance(),i=0;for(let r of this)e.call(t,r,i++,this)&&n.push(r);return n}mapSame(e,t){let n=this._createInstance(),i=0;for(let r of this){let l=t===void 0?e(r,i++,this):e.call(t,r,i++,this);n.push(l)}return n}map(e,t,n){let i=this._createLike([],{...t!=null?t:{},maxLen:this._maxLen}),r=0;for(let l of this)i.push(e.call(n,l,r++,this));return i}createNode(e){return new E(e)}_isPredicate(e){return typeof e=="function"}_ensureNode(e){return this.isNode(e)?e:this.createNode(e)}_ensurePredicate(e){if(this.isNode(e))return n=>n===e;if(this._isPredicate(e))return e;let t=e;return n=>this._equals(n.value,t)}_getPrevNode(e){if(!this.head||this.head===e)return;let t=this.head;for(;t.next&&t.next!==e;)t=t.next;return t.next===e?t:void 0}*_getIterator(){let e=this.head;for(;e;)yield e.value,e=e.next}*_getReverseIterator(){let e=[...this].reverse();for(let t of e)yield t}*_getNodeIterator(){let e=this.head;for(;e;)yield e,e=e.next}_createInstance(e){let t=this.constructor;return new t([],e)}_createLike(e=[],t){let n=this.constructor;return new n(e,t)}_spawnLike(e){return this._createLike([],e)}};function U(o,s){if(o instanceof E)return t=>t===o;if(typeof o=="function")return o;let e=o;return t=>s(t.value,e)}var L=class extends f{constructor(e){super(e);d(this,"_next");d(this,"_prev");this._value=e,this._next=void 0,this._prev=void 0}get next(){return this._next}set next(e){this._next=e}get prev(){return this._prev}set prev(e){this._prev=e}},m=class extends c{constructor(e=[],t){super(t);d(this,"_equals",Object.is);d(this,"_head");d(this,"_tail");d(this,"_length",0);this._head=void 0,this._tail=void 0,this._length=0,t!=null&&t.maxLen&&Number.isInteger(t.maxLen)&&t.maxLen>0&&(this._maxLen=t.maxLen),this.pushMany(e)}get head(){return this._head}get tail(){return this._tail}get length(){return this._length}get first(){var e;return(e=this.head)==null?void 0:e.value}get last(){var e;return(e=this.tail)==null?void 0:e.value}static fromArray(e){return new this(e)}isNode(e){return e instanceof L}push(e){let t=this._ensureNode(e);return this.head?(t.prev=this.tail,this.tail.next=t,this._tail=t):(this._head=t,this._tail=t),this._length++,this._maxLen>0&&this.length>this._maxLen&&this.shift(),!0}pop(){if(!this.tail)return;let e=this.tail;return this.head===this.tail?(this._head=void 0,this._tail=void 0):(this._tail=e.prev,this.tail.next=void 0),this._length--,e.value}shift(){if(!this.head)return;let e=this.head;return this.head===this.tail?(this._head=void 0,this._tail=void 0):(this._head=e.next,this.head.prev=void 0),this._length--,e.value}unshift(e){let t=this._ensureNode(e);return this.head?(t.next=this.head,this.head.prev=t,this._head=t):(this._head=t,this._tail=t),this._length++,this._maxLen>0&&this._length>this._maxLen&&this.pop(),!0}pushMany(e){let t=[];for(let n of e)this.toElementFn?t.push(this.push(this.toElementFn(n))):t.push(this.push(n));return t}unshiftMany(e){let t=[];for(let n of e)this.toElementFn?t.push(this.unshift(this.toElementFn(n))):t.push(this.unshift(n));return t}at(e){if(e<0||e>=this._length)return;let t=this.head;for(let n=0;n<e;n++)t=t.next;return t.value}getNodeAt(e){if(e<0||e>=this._length)return;let t=this.head;for(let n=0;n<e;n++)t=t.next;return t}getNode(e){if(e===void 0)return;if(this.isNode(e)){let i=e,r=this.head;for(;r;){if(r===i)return i;r=r.next}let l=h=>this._equals(h.value,i.value);for(r=this.head;r;){if(l(r))return r;r=r.next}return}let t=this._ensurePredicate(e),n=this.head;for(;n;){if(t(n))return n;n=n.next}}addAt(e,t){if(e<0||e>this._length)return!1;if(e===0)return this.unshift(t);if(e===this._length)return this.push(t);let n=this._ensureNode(t),i=this.getNodeAt(e-1),r=i.next;return n.prev=i,n.next=r,i.next=n,r.prev=n,this._length++,!0}addBefore(e,t){let n=this.isNode(e)?e:this.getNode(e);if(!n)return!1;let i=this._ensureNode(t);return i.prev=n.prev,n.prev&&(n.prev.next=i),i.next=n,n.prev=i,n===this.head&&(this._head=i),this._length++,!0}addAfter(e,t){let n=this.isNode(e)?e:this.getNode(e);if(!n)return!1;let i=this._ensureNode(t);return i.next=n.next,n.next&&(n.next.prev=i),i.prev=n,n.next=i,n===this.tail&&(this._tail=i),this._length++,!0}setAt(e,t){let n=this.getNodeAt(e);return n?(n.value=t,!0):!1}deleteAt(e){if(e<0||e>=this._length)return;if(e===0)return this.shift();if(e===this._length-1)return this.pop();let t=this.getNodeAt(e),n=t.prev,i=t.next;return n.next=i,i.prev=n,this._length--,t.value}delete(e){let t=this.getNode(e);if(!t)return!1;if(t===this.head)this.shift();else if(t===this.tail)this.pop();else{let n=t.prev,i=t.next;n.next=i,i.prev=n,this._length--}return!0}isEmpty(){return this._length===0}clear(){this._head=void 0,this._tail=void 0,this._length=0}search(e){let t=this._ensurePredicate(e),n=this.head;for(;n;){if(t(n))return n.value;n=n.next}}getBackward(e){let t=this._ensurePredicate(e),n=this.tail;for(;n;){if(t(n))return n.value;n=n.prev}}reverse(){let e=this.head;for([this._head,this._tail]=[this.tail,this.head];e;){let t=e.next;[e.prev,e.next]=[e.next,e.prev],e=t}return this}setEquality(e){return this._equals=e,this}clone(){let e=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen});for(let t of this)e.push(t);return e}filter(e,t){let n=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen}),i=0;for(let r of this)e.call(t,r,i++,this)&&n.push(r);return n}mapSame(e,t){let n=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen}),i=0;for(let r of this){let l=t===void 0?e(r,i++,this):e.call(t,r,i++,this);n.push(l)}return n}map(e,t,n){let i=this._createLike([],{...t!=null?t:{},maxLen:this._maxLen}),r=0;for(let l of this)i.push(e.call(n,l,r++,this));return i}_ensureNode(e){return this.isNode(e)?e:new L(e)}_ensurePredicate(e){if(this.isNode(e)){let n=e;return i=>i===n}if(typeof e=="function")return e;let t=e;return n=>this._equals(n.value,t)}_getPrevNode(e){return e.prev}_createInstance(e){let t=this.constructor;return new t([],e)}_createLike(e=[],t){let n=this.constructor;return new n(e,t)}*_getIterator(){let e=this.head;for(;e;)yield e.value,e=e.next}*_getReverseIterator(){let e=this.tail;for(;e;)yield e.value,e=e.prev}*_getNodeIterator(){let e=this.head;for(;e;)yield e,e=e.next}};var g=class{constructor(s,e,t){d(this,"key");d(this,"value");d(this,"forward");this.key=s,this.value=e,this.forward=new Array(t)}},v=class{constructor(s=[],e){d(this,"_head",new g(void 0,void 0,this.maxLevel));d(this,"_level",0);d(this,"_maxLevel",16);d(this,"_probability",.5);if(e){let{maxLevel:t,probability:n}=e;typeof t=="number"&&(this._maxLevel=t),typeof n=="number"&&(this._probability=n)}if(s)for(let[t,n]of s)this.add(t,n)}get head(){return this._head}get level(){return this._level}get maxLevel(){return this._maxLevel}get probability(){return this._probability}get first(){let s=this.head.forward[0];return s?s.value:void 0}get last(){let s=this.head;for(let e=this.level-1;e>=0;e--)for(;s.forward[e];)s=s.forward[e];return s.value}add(s,e){let t=new g(s,e,this._randomLevel()),n=new Array(this.maxLevel).fill(this.head),i=this.head;for(let r=this.level-1;r>=0;r--){for(;i.forward[r]&&i.forward[r].key<s;)i=i.forward[r];n[r]=i}for(let r=0;r<t.forward.length;r++)t.forward[r]=n[r].forward[r],n[r].forward[r]=t;t.forward[0]||(this._level=Math.max(this.level,t.forward.length))}get(s){let e=this.head;for(let t=this.level-1;t>=0;t--)for(;e.forward[t]&&e.forward[t].key<s;)e=e.forward[t];if(e=e.forward[0],e&&e.key===s)return e.value}has(s){return this.get(s)!==void 0}delete(s){let e=new Array(this.maxLevel).fill(this.head),t=this.head;for(let n=this.level-1;n>=0;n--){for(;t.forward[n]&&t.forward[n].key<s;)t=t.forward[n];e[n]=t}if(t=t.forward[0],t&&t.key===s){for(let n=0;n<this.level&&e[n].forward[n]===t;n++)e[n].forward[n]=t.forward[n];for(;this.level>0&&!this.head.forward[this.level-1];)this._level--;return!0}return!1}higher(s){let e=this.head;for(let n=this.level-1;n>=0;n--)for(;e.forward[n]&&e.forward[n].key<=s;)e=e.forward[n];let t=e.forward[0];return t?t.value:void 0}lower(s){let e=this.head,t;for(let n=this.level-1;n>=0;n--){for(;e.forward[n]&&e.forward[n].key<s;)e=e.forward[n];e.key<s&&(t=e)}return t?t.value:void 0}_randomLevel(){let s=1;for(;Math.random()<this.probability&&s<this.maxLevel;)s++;return s}};var w=(e=>(e[e.VISIT=0]="VISIT",e[e.PROCESS=1]="PROCESS",e))(w||{}),x=class{constructor(s,e,t=!0,n=!0){this.low=s;this.high=e;this.includeLow=t;this.includeHigh=n}isInRange(s,e){let t=this.includeLow?e(s,this.low)>=0:e(s,this.low)>0,n=this.includeHigh?e(s,this.high)<=0:e(s,this.high)<0;return t&&n}};return O(K);})();
1
+ "use strict";var linkedListTyped=(()=>{var _=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var O=(o,i,e)=>i in o?_(o,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[i]=e;var A=(o,i)=>{for(var e in i)_(o,e,{get:i[e],enumerable:!0})},C=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of S(i))!D.call(o,n)&&n!==e&&_(o,n,{get:()=>i[n],enumerable:!(t=M(i,n))||t.enumerable});return o};var U=o=>C(_({},"__esModule",{value:!0}),o);var d=(o,i,e)=>O(o,typeof i!="symbol"?i+"":i,e);var $={};A($,{DFSOperation:()=>w,DoublyLinkedList:()=>x,DoublyLinkedListNode:()=>g,ERR:()=>L,Range:()=>N,SinglyLinkedList:()=>v,SinglyLinkedListNode:()=>E,SkipList:()=>R,SkipListNode:()=>p});var L={indexOutOfRange:(o,i,e,t)=>`${t?t+": ":""}Index ${o} is out of range [${i}, ${e}].`,invalidIndex:o=>`${o?o+": ":""}Index must be an integer.`,invalidArgument:(o,i)=>`${i?i+": ":""}${o}`,comparatorRequired:o=>`${o?o+": ":""}Comparator is required for non-number/non-string/non-Date keys.`,invalidKey:(o,i)=>`${i?i+": ":""}${o}`,notAFunction:(o,i)=>`${i?i+": ":""}${o} must be a function.`,invalidEntry:o=>`${o?o+": ":""}Each entry must be a [key, value] tuple.`,invalidNaN:o=>`${o?o+": ":""}NaN is not a valid key.`,invalidDate:o=>`${o?o+": ":""}Invalid Date key.`,reduceEmpty:o=>`${o?o+": ":""}Reduce of empty structure with no initial value.`,callbackReturnType:(o,i,e)=>`${e?e+": ":""}Callback must return ${o}; got ${i}.`,invalidOperation:(o,i)=>`${i?i+": ":""}${o}`,matrixDimensionMismatch:o=>`Matrix: Dimensions must be compatible for ${o}.`,matrixSingular:()=>"Matrix: Singular matrix, inverse does not exist.",matrixNotSquare:()=>"Matrix: Must be square for inversion.",matrixNotRectangular:()=>"Matrix: Must be rectangular for transposition.",matrixRowMismatch:(o,i)=>`Matrix: Expected row length ${o}, but got ${i}.`};var w=(e=>(e[e.VISIT=0]="VISIT",e[e.PROCESS=1]="PROCESS",e))(w||{}),N=class{constructor(i,e,t=!0,n=!0){this.low=i;this.high=e;this.includeLow=t;this.includeHigh=n}isInRange(i,e){let t=this.includeLow?e(i,this.low)>=0:e(i,this.low)>0,n=this.includeHigh?e(i,this.high)<=0:e(i,this.high)<0;return t&&n}};var m=class{constructor(i){d(this,"_toElementFn");if(i){let{toElementFn:e}=i;if(typeof e=="function")this._toElementFn=e;else if(e)throw new TypeError(L.notAFunction("toElementFn"))}}get toElementFn(){return this._toElementFn}*[Symbol.iterator](...i){yield*this._getIterator(...i)}*values(){for(let i of this)yield i}every(i,e){let t=0;for(let n of this)if(e===void 0){if(!i(n,t++,this))return!1}else if(!i.call(e,n,t++,this))return!1;return!0}some(i,e){let t=0;for(let n of this)if(e===void 0){if(i(n,t++,this))return!0}else if(i.call(e,n,t++,this))return!0;return!1}forEach(i,e){let t=0;for(let n of this)e===void 0?i(n,t++,this):i.call(e,n,t++,this)}find(i,e){let t=0;for(let n of this)if(e===void 0){if(i(n,t++,this))return n}else if(i.call(e,n,t++,this))return n}has(i){for(let e of this)if(e===i)return!0;return!1}reduce(i,e){let t=0,n=this[Symbol.iterator](),s;if(arguments.length>=2)s=e;else{let r=n.next();if(r.done)throw new TypeError(L.reduceEmpty());s=r.value,t=1}for(let r of n)s=i(s,r,t++,this);return s}toArray(){return[...this]}toVisual(){return[...this]}print(){console.log(this.toVisual())}};var f=class{constructor(i){d(this,"_value");d(this,"_next");this._value=i,this._next=void 0}get value(){return this._value}set value(i){this._value=i}get next(){return this._next}set next(i){this._next=i}},y=class o extends m{constructor(e){super(e);d(this,"_maxLen",-1);if(e){let{maxLen:t}=e;typeof t=="number"&&t>0&&t%1===0&&(this._maxLen=t)}}get maxLen(){return this._maxLen}indexOf(e,t=0){if(this.length===0)return-1;t<0&&(t=this.length+t),t<0&&(t=0);for(let n=t;n<this.length;n++)if(this.at(n)===e)return n;return-1}lastIndexOf(e,t=this.length-1){if(this.length===0)return-1;t>=this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(let n=t;n>=0;n--)if(this.at(n)===e)return n;return-1}findIndex(e,t){for(let n=0;n<this.length;n++){let s=this.at(n);if(s!==void 0&&e.call(t,s,n,this))return n}return-1}concat(...e){let t=this.clone();for(let n of e)n instanceof o?t.pushMany(n):t.push(n);return t}sort(e){let t=this.toArray();t.sort(e),this.clear();for(let n of t)this.push(n);return this}splice(e,t=0,...n){let s=this._createInstance();e=e<0?this.length+e:e,e=Math.max(0,Math.min(e,this.length)),t=Math.max(0,Math.min(t,this.length-e));for(let r=0;r<t;r++){let l=this.deleteAt(e);l!==void 0&&s.push(l)}for(let r=0;r<n.length;r++)this.addAt(e+r,n[r]);return s}join(e=","){return this.toArray().join(e)}toReversedArray(){let e=[];for(let t=this.length-1;t>=0;t--)e.push(this.at(t));return e}reduceRight(e,t){let n=t!=null?t:0;for(let s=this.length-1;s>=0;s--)n=e(n,this.at(s),s,this);return n}slice(e=0,t=this.length){e=e<0?this.length+e:e,t=t<0?this.length+t:t;let n=this._createInstance();for(let s=e;s<t;s++)n.push(this.at(s));return n}fill(e,t=0,n=this.length){if(t=t<0?this.length+t:t,n=n<0?this.length+n:n,t<0&&(t=0),n>this.length&&(n=this.length),t>=n)return this;for(let s=t;s<n;s++)this.setAt(s,e);return this}},c=class extends y{constructor(i){if(super(i),i){let{maxLen:e}=i;typeof e=="number"&&e>0&&e%1===0&&(this._maxLen=e)}}indexOf(i,e=0){let t=this._getIterator(),n=t.next(),s=0;for(;s<e;)n=t.next(),s++;for(;!n.done;){if(n.value===i)return s;n=t.next(),s++}return-1}lastIndexOf(i,e=this.length-1){let t=this._getReverseIterator(),n=t.next(),s=this.length-1;for(;s>e;)n=t.next(),s--;for(;!n.done;){if(n.value===i)return s;n=t.next(),s--}return-1}concat(...i){let e=this.clone();for(let t of i)t instanceof y?e.pushMany(t):e.push(t);return e}slice(i=0,e=this.length){i=i<0?this.length+i:i,e=e<0?this.length+e:e;let t=this._createInstance(),n=this._getIterator(),s=n.next(),r=0;for(;r<i;)s=n.next(),r++;for(let l=i;l<e;l++)t.push(s.value),s=n.next();return t}splice(i,e=0,...t){let n=this._createInstance();i=i<0?this.length+i:i,i=Math.max(0,Math.min(i,this.length)),e=Math.max(0,e);let s=0,r,l,h=this._getNodeIterator();for(let a of h){if(s===i){r=a;break}l=a,s++}for(let a=0;a<e&&r;a++){n.push(r.value);let u=r.next;this.delete(r),r=u}for(let a=0;a<t.length;a++)l?(this.addAfter(l,t[a]),l=l.next):(this.addAt(0,t[a]),l=this._getNodeIterator().next().value);return n}reduceRight(i,e){let t=e!=null?e:0,n=this.length-1;for(let s of this._getReverseIterator())t=i(t,s,n--,this);return t}};var E=class extends f{constructor(e){super(e);d(this,"_next");this._value=e,this._next=void 0}get next(){return this._next}set next(e){this._next=e}},v=class extends c{constructor(e=[],t){super(t);d(this,"_equals",(e,t)=>Object.is(e,t));d(this,"_head");d(this,"_tail");d(this,"_length",0);this.pushMany(e)}get head(){return this._head}get tail(){return this._tail}get length(){return this._length}get first(){var e;return(e=this.head)==null?void 0:e.value}get last(){var e;return(e=this.tail)==null?void 0:e.value}static from(e,t){let n=new this([],t);for(let s of e)n.push(s);return n}push(e){let t=this._ensureNode(e);return this.head?(this.tail.next=t,this._tail=t):this._head=this._tail=t,this._length++,this._maxLen>0&&this.length>this._maxLen&&this.shift(),!0}pop(){var n;if(!this.head)return;if(this.head===this.tail){let s=this.head.value;return this._head=void 0,this._tail=void 0,this._length--,s}let e=this.head;for(;e.next&&e.next!==this.tail;)e=e.next;let t=(n=this.tail)==null?void 0:n.value;return e.next=void 0,this._tail=e,this._length--,t}shift(){if(!this.head)return;let e=this.head;return this._head=this.head.next,this._head||(this._tail=void 0),this._length--,e.value}unshift(e){let t=this._ensureNode(e);return this.head?(t.next=this.head,this._head=t):this._head=this._tail=t,this._length++,!0}pushMany(e){let t=[];for(let n of e)this.toElementFn?t.push(this.push(this.toElementFn(n))):t.push(this.push(n));return t}unshiftMany(e){let t=[];for(let n of e)this.toElementFn?t.push(this.unshift(this.toElementFn(n))):t.push(this.unshift(n));return t}search(e){let t=this._ensurePredicate(e),n=this.head;for(;n;){if(t(n))return n.value;n=n.next}}at(e){if(e<0||e>=this._length)return;let t=this.head;for(let n=0;n<e&&t;n++)t=t.next;return t==null?void 0:t.value}isNode(e){return e instanceof E}getNodeAt(e){if(e<0||e>=this._length)return;let t=this.head;for(let n=0;n<e&&t;n++)t=t.next;return t}deleteAt(e){if(e<0||e>=this._length)return;if(e===0)return this.shift();let t=this.getNodeAt(e),n=this._getPrevNode(t),s=t.value;return n.next=t.next,t===this.tail&&(this._tail=n),this._length--,s}delete(e){if(e===void 0||!this.head)return!1;let t=this.isNode(e)?e:this.getNode(e);if(!t)return!1;let n=this._getPrevNode(t);return n?(n.next=t.next,t===this.tail&&(this._tail=n)):(this._head=t.next,t===this.tail&&(this._tail=void 0)),this._length--,!0}addAt(e,t){if(e<0||e>this._length)return!1;if(e===0)return this.unshift(t);if(e===this._length)return this.push(t);let n=this._ensureNode(t),s=this.getNodeAt(e-1);return n.next=s.next,s.next=n,this._length++,!0}setAt(e,t){let n=this.getNodeAt(e);return n?(n.value=t,!0):!1}isEmpty(){return this._length===0}clear(){this._head=void 0,this._tail=void 0,this._length=0}reverse(){if(!this.head||this.head===this.tail)return this;let e,t=this.head,n;for(;t;)n=t.next,t.next=e,e=t,t=n;return[this._head,this._tail]=[this.tail,this.head],this}getNode(e){if(e===void 0)return;if(this.isNode(e))return e;let t=this._ensurePredicate(e),n=this.head;for(;n;){if(t(n))return n;n=n.next}}addBefore(e,t){let n=this.getNode(e);if(!n)return!1;let s=this._getPrevNode(n),r=this._ensureNode(t);return s?(s.next=r,r.next=n,this._length++):(r.next=this._head,this._head=r,this._tail||(this._tail=r),this._length++),!0}addAfter(e,t){let n=this.getNode(e);if(!n)return!1;let s=this._ensureNode(t);return s.next=n.next,n.next=s,n===this.tail&&(this._tail=s),this._length++,!0}splice(e,t=0,...n){e=Math.max(0,Math.min(e,this.length)),t=Math.max(0,t);let s=this._createInstance(),r=e===0?void 0:this.getNodeAt(e-1),l=r?r.next:this.head,h=0;for(;h<t&&l;)s.push(l.value),l=l.next,h++;let a=l;if(r?r.next=a:this._head=a,a||(this._tail=r),n.length>0){let u,b;for(let I of n){let k=this._ensureNode(I);u||(u=k),b&&(b.next=k),b=k}r?r.next=u:this._head=u,b.next=a,a||(this._tail=b)}return this._length+=n.length-h,this._length===0&&(this._head=void 0,this._tail=void 0),s}countOccurrences(e){let t=K(e,this._equals),n=0,s=this.head;for(;s;)t(s)&&n++,s=s.next;return n}setEquality(e){return this._equals=e,this}deleteWhere(e){let t,n=this.head,s=0;for(;n;){if(e(n.value,s++,this))return t?(t.next=n.next,n===this._tail&&(this._tail=t)):(this._head=n.next,n===this._tail&&(this._tail=void 0)),this._length--,!0;t=n,n=n.next}return!1}clone(){let e=this._createInstance();for(let t of this)e.push(t);return e}filter(e,t){let n=this._createInstance(),s=0;for(let r of this)e.call(t,r,s++,this)&&n.push(r);return n}mapSame(e,t){let n=this._createInstance(),s=0;for(let r of this){let l=t===void 0?e(r,s++,this):e.call(t,r,s++,this);n.push(l)}return n}map(e,t,n){let s=this._createLike([],{...t!=null?t:{},maxLen:this._maxLen}),r=0;for(let l of this)s.push(e.call(n,l,r++,this));return s}createNode(e){return new E(e)}_isPredicate(e){return typeof e=="function"}_ensureNode(e){return this.isNode(e)?e:this.createNode(e)}_ensurePredicate(e){if(this.isNode(e))return n=>n===e;if(this._isPredicate(e))return e;let t=e;return n=>this._equals(n.value,t)}_getPrevNode(e){if(!this.head||this.head===e)return;let t=this.head;for(;t.next&&t.next!==e;)t=t.next;return t.next===e?t:void 0}*_getIterator(){let e=this.head;for(;e;)yield e.value,e=e.next}*_getReverseIterator(){let e=[...this].reverse();for(let t of e)yield t}*_getNodeIterator(){let e=this.head;for(;e;)yield e,e=e.next}_createInstance(e){let t=this.constructor;return new t([],e)}_createLike(e=[],t){let n=this.constructor;return new n(e,t)}_spawnLike(e){return this._createLike([],e)}};function K(o,i){if(o instanceof E)return t=>t===o;if(typeof o=="function")return o;let e=o;return t=>i(t.value,e)}var g=class extends f{constructor(e){super(e);d(this,"_next");d(this,"_prev");this._value=e,this._next=void 0,this._prev=void 0}get next(){return this._next}set next(e){this._next=e}get prev(){return this._prev}set prev(e){this._prev=e}},x=class extends c{constructor(e=[],t){super(t);d(this,"_equals",(e,t)=>Object.is(e,t));d(this,"_head");d(this,"_tail");d(this,"_length",0);this._head=void 0,this._tail=void 0,this._length=0,t!=null&&t.maxLen&&Number.isInteger(t.maxLen)&&t.maxLen>0&&(this._maxLen=t.maxLen),this.pushMany(e)}get head(){return this._head}get tail(){return this._tail}get length(){return this._length}get first(){var e;return(e=this.head)==null?void 0:e.value}get last(){var e;return(e=this.tail)==null?void 0:e.value}static fromArray(e){return new this(e)}isNode(e){return e instanceof g}push(e){let t=this._ensureNode(e);return this.head?(t.prev=this.tail,this.tail.next=t,this._tail=t):(this._head=t,this._tail=t),this._length++,this._maxLen>0&&this.length>this._maxLen&&this.shift(),!0}pop(){if(!this.tail)return;let e=this.tail;return this.head===this.tail?(this._head=void 0,this._tail=void 0):(this._tail=e.prev,this.tail.next=void 0),this._length--,e.value}shift(){if(!this.head)return;let e=this.head;return this.head===this.tail?(this._head=void 0,this._tail=void 0):(this._head=e.next,this.head.prev=void 0),this._length--,e.value}unshift(e){let t=this._ensureNode(e);return this.head?(t.next=this.head,this.head.prev=t,this._head=t):(this._head=t,this._tail=t),this._length++,this._maxLen>0&&this._length>this._maxLen&&this.pop(),!0}pushMany(e){let t=[];for(let n of e)this.toElementFn?t.push(this.push(this.toElementFn(n))):t.push(this.push(n));return t}unshiftMany(e){let t=[];for(let n of e)this.toElementFn?t.push(this.unshift(this.toElementFn(n))):t.push(this.unshift(n));return t}at(e){if(e<0||e>=this._length)return;let t=this.head;for(let n=0;n<e&&t;n++)t=t.next;return t==null?void 0:t.value}getNodeAt(e){if(e<0||e>=this._length)return;let t=this.head;for(let n=0;n<e&&t;n++)t=t.next;return t}getNode(e){if(e===void 0)return;if(this.isNode(e)){let s=e,r=this.head;for(;r;){if(r===s)return s;r=r.next}let l=h=>this._equals(h.value,s.value);for(r=this.head;r;){if(l(r))return r;r=r.next}return}let t=this._ensurePredicate(e),n=this.head;for(;n;){if(t(n))return n;n=n.next}}addAt(e,t){if(e<0||e>this._length)return!1;if(e===0)return this.unshift(t);if(e===this._length)return this.push(t);let n=this._ensureNode(t),s=this.getNodeAt(e-1),r=s.next;return n.prev=s,n.next=r,s.next=n,r.prev=n,this._length++,!0}addBefore(e,t){let n=this.isNode(e)?e:this.getNode(e);if(!n)return!1;let s=this._ensureNode(t);return s.prev=n.prev,n.prev&&(n.prev.next=s),s.next=n,n.prev=s,n===this.head&&(this._head=s),this._length++,!0}addAfter(e,t){let n=this.isNode(e)?e:this.getNode(e);if(!n)return!1;let s=this._ensureNode(t);return s.next=n.next,n.next&&(n.next.prev=s),s.prev=n,n.next=s,n===this.tail&&(this._tail=s),this._length++,!0}setAt(e,t){let n=this.getNodeAt(e);return n?(n.value=t,!0):!1}deleteAt(e){if(e<0||e>=this._length)return;if(e===0)return this.shift();if(e===this._length-1)return this.pop();let t=this.getNodeAt(e),n=t.prev,s=t.next;return n.next=s,s.prev=n,this._length--,t.value}delete(e){let t=this.getNode(e);if(!t)return!1;if(t===this.head)this.shift();else if(t===this.tail)this.pop();else{let n=t.prev,s=t.next;n.next=s,s.prev=n,this._length--}return!0}isEmpty(){return this._length===0}clear(){this._head=void 0,this._tail=void 0,this._length=0}search(e){let t=this._ensurePredicate(e),n=this.head;for(;n;){if(t(n))return n.value;n=n.next}}getBackward(e){let t=this._ensurePredicate(e),n=this.tail;for(;n;){if(t(n))return n.value;n=n.prev}}reverse(){let e=this.head;for([this._head,this._tail]=[this.tail,this.head];e;){let t=e.next;[e.prev,e.next]=[e.next,e.prev],e=t}return this}setEquality(e){return this._equals=e,this}clone(){let e=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen});for(let t of this)e.push(t);return e}filter(e,t){let n=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen}),s=0;for(let r of this)e.call(t,r,s++,this)&&n.push(r);return n}mapSame(e,t){let n=this._createInstance({toElementFn:this._toElementFn,maxLen:this._maxLen}),s=0;for(let r of this){let l=t===void 0?e(r,s++,this):e.call(t,r,s++,this);n.push(l)}return n}map(e,t,n){let s=this._createLike([],{...t!=null?t:{},maxLen:this._maxLen}),r=0;for(let l of this)s.push(e.call(n,l,r++,this));return s}_ensureNode(e){return this.isNode(e)?e:new g(e)}_ensurePredicate(e){if(this.isNode(e)){let n=e;return s=>s===n}if(typeof e=="function")return e;let t=e;return n=>this._equals(n.value,t)}_getPrevNode(e){return e.prev}_createInstance(e){let t=this.constructor;return new t([],e)}_createLike(e=[],t){let n=this.constructor;return new n(e,t)}*_getIterator(){let e=this.head;for(;e;)yield e.value,e=e.next}*_getReverseIterator(){let e=this.tail;for(;e;)yield e.value,e=e.prev}*_getNodeIterator(){let e=this.head;for(;e;)yield e,e=e.next}};var p=class{constructor(i,e,t){d(this,"key");d(this,"value");d(this,"forward");this.key=i,this.value=e,this.forward=new Array(t)}},R=class{constructor(i=[],e){d(this,"_head",new p(void 0,void 0,this.maxLevel));d(this,"_level",0);d(this,"_maxLevel",16);d(this,"_probability",.5);if(e){let{maxLevel:t,probability:n}=e;typeof t=="number"&&(this._maxLevel=t),typeof n=="number"&&(this._probability=n)}if(i)for(let[t,n]of i)this.add(t,n)}get head(){return this._head}get level(){return this._level}get maxLevel(){return this._maxLevel}get probability(){return this._probability}get first(){let i=this.head.forward[0];return i?i.value:void 0}get last(){let i=this.head;for(let e=this.level-1;e>=0;e--)for(;i.forward[e];)i=i.forward[e];return i.value}add(i,e){let t=new p(i,e,this._randomLevel()),n=new Array(this.maxLevel).fill(this.head),s=this.head;for(let r=this.level-1;r>=0;r--){for(;s.forward[r]&&s.forward[r].key<i;)s=s.forward[r];n[r]=s}for(let r=0;r<t.forward.length;r++)t.forward[r]=n[r].forward[r],n[r].forward[r]=t;t.forward[0]||(this._level=Math.max(this.level,t.forward.length))}get(i){let e=this.head;for(let t=this.level-1;t>=0;t--)for(;e.forward[t]&&e.forward[t].key<i;)e=e.forward[t];if(e=e.forward[0],e&&e.key===i)return e.value}has(i){return this.get(i)!==void 0}delete(i){let e=new Array(this.maxLevel).fill(this.head),t=this.head;for(let n=this.level-1;n>=0;n--){for(;t.forward[n]&&t.forward[n].key<i;)t=t.forward[n];e[n]=t}if(t=t.forward[0],t&&t.key===i){for(let n=0;n<this.level&&e[n].forward[n]===t;n++)e[n].forward[n]=t.forward[n];for(;this.level>0&&!this.head.forward[this.level-1];)this._level--;return!0}return!1}higher(i){let e=this.head;for(let n=this.level-1;n>=0;n--)for(;e.forward[n]&&e.forward[n].key<=i;)e=e.forward[n];let t=e.forward[0];return t?t.value:void 0}lower(i){let e=this.head,t;for(let n=this.level-1;n>=0;n--){for(;e.forward[n]&&e.forward[n].key<i;)e=e.forward[n];e.key<i&&(t=e)}return t?t.value:void 0}_randomLevel(){let i=1;for(;Math.random()<this.probability&&i<this.maxLevel;)i++;return i}};return U($);})();
2
2
  /**
3
3
  * data-structure-typed
4
4
  *