@js-sdsl/hash-map
Advanced tools
Comparing version 4.2.0-beta.0 to 4.2.0-beta.1
@@ -33,23 +33,29 @@ declare abstract class Base { | ||
}; | ||
declare abstract class HashContainer<K> extends Base { | ||
protected constructor(initBucketNum?: number, hashFunc?: (x: K) => number); | ||
declare abstract class HashContainer<K, V> extends Base { | ||
protected constructor(); | ||
clear(): void; | ||
/** | ||
* @description Iterate over all elements in the container. | ||
* @param callback Callback function like Array.forEach. | ||
* @example container.forEach((element, index) => console.log(element, index)); | ||
* @description Remove the element of the specified key. | ||
* @param key The key you want to remove. | ||
* @param isObject Tell us if the type of inserted key is `object` to improve efficiency.<br/> | ||
* If a `undefined` value is passed in, the type will be automatically judged. | ||
*/ | ||
abstract forEach(callback: (element: unknown, index: number, hashContainer: HashContainer<K>) => void): void; | ||
eraseElementByKey(key: K, isObject?: boolean): void; | ||
/** | ||
* @description Remove the elements of the specified value. | ||
* @param key The element you want to remove. | ||
* @example container.eraseElementByKey(1); | ||
* @description Check key if exist in container. | ||
* @param key The element you want to search. | ||
* @param isObject Tell us if the type of inserted key is `object` to improve efficiency.<br/> | ||
* If a `undefined` value is passed in, the type will be automatically judged. | ||
* @return Boolean about if key exist in container. | ||
*/ | ||
abstract eraseElementByKey(key: K): void; | ||
find(key: K, isObject?: boolean): boolean; | ||
/** | ||
* @param key The element you want to find. | ||
* @return Boolean about if the specified element in the hash set. | ||
* @example container.find(1).equals(container.end()); | ||
* @description Iterate over all elements in the container. | ||
* @param callback Callback function like Array.forEach. | ||
* @example container.forEach((element, index) => console.log(element, index)); | ||
*/ | ||
abstract find(key: K): void; | ||
abstract forEach(callback: (element: K | [ | ||
K, | ||
V | ||
], index: number, hashContainer: HashContainer<K, V>) => void): void; | ||
/** | ||
@@ -64,42 +70,36 @@ * @description Using for `for...of` syntax like Array. | ||
K, | ||
unknown | ||
V | ||
], void, undefined>; | ||
} | ||
declare class HashMap<K, V> extends HashContainer<K> { | ||
/** | ||
* @description HashMap's constructor. | ||
* @param container Initialize container, must have a forEach function. | ||
* @param initBucketNum Initialize bucket num, must be an integer power of 2 and greater than 16. | ||
* @param hashFunc The hash function, convert key element from type T to a number. | ||
* @example new HashMap([[0, 1], [2, 1], [3, 2]], 1 << 10, x => x); | ||
*/ | ||
declare class HashMap<K, V> extends HashContainer<K, V> { | ||
constructor(container?: initContainer<[ | ||
K, | ||
V | ||
]>, initBucketNum?: number, hashFunc?: (x: K) => number); | ||
forEach(callback: (element: [ | ||
K, | ||
V | ||
], index: number, map: HashMap<K, V>) => void): void; | ||
]>); | ||
/** | ||
* @description Insert a new key-value pair to hash map or set value by key. | ||
* @param key The key you want to insert. | ||
* @param value The value you want to insert. | ||
* @example HashMap.setElement(1, 2); // insert a key-value pair [1, 2] | ||
* @description Insert a key-value pair or set value by the given key. | ||
* @param key The key want to insert. | ||
* @param value The value want to set. | ||
* @param isObject Tell us if the type of inserted key is `object` to improve efficiency.<br/> | ||
* If a `undefined` value is passed in, the type will be automatically judged. | ||
*/ | ||
setElement(key: K, value: V): void; | ||
setElement(key: K, value: V, isObject?: boolean): void; | ||
/** | ||
* @description Get the value of the element which has the specified key. | ||
* @param key The key you want to get. | ||
* @example const value = container.getElementByKey(1); | ||
* @description Get the value of the element of the specified key. | ||
* @param key The key want to search. | ||
* @param isObject Tell us if the type of inserted key is `object` to improve efficiency.<br/> | ||
* If a `undefined` value is passed in, the type will be automatically judged. | ||
* @example const val = container.getElementByKey(1); | ||
*/ | ||
getElementByKey(key: K): V | undefined; | ||
eraseElementByKey(key: K): void; | ||
find(key: K): boolean; | ||
getElementByKey(key: K, isObject?: boolean): V | undefined; | ||
forEach(callback: (element: [ | ||
K, | ||
V | ||
], index: number, hashMap: HashMap<K, V>) => void): void; | ||
[Symbol.iterator](): Generator<[ | ||
K, | ||
V | ||
], void, unknown>; | ||
], void, undefined>; | ||
} | ||
export { HashMap }; | ||
export type { HashContainer }; |
@@ -7,8 +7,2 @@ "use strict"; | ||
class ContainerIterator { | ||
constructor(t = 0) { | ||
this.iteratorType = t; | ||
} | ||
} | ||
class Base { | ||
@@ -26,1119 +20,122 @@ constructor() { | ||
class Container extends Base {} | ||
function checkObject(t) { | ||
if (t === null) return false; | ||
const e = typeof t; | ||
return e === "object" || e === "function"; | ||
} | ||
class HashContainer extends Base { | ||
constructor(t = 16, e = (t => { | ||
let e; | ||
if (typeof t !== "string") { | ||
e = JSON.stringify(t); | ||
} else e = t; | ||
let s = 0; | ||
const i = e.length; | ||
for (let t = 0; t < i; t++) { | ||
const i = e.charCodeAt(t); | ||
s = (s << 5) - s + i; | ||
s |= 0; | ||
} | ||
return s >>> 0; | ||
})) { | ||
super(); | ||
if (t < 16 || (t & t - 1) !== 0) { | ||
throw new RangeError("InitBucketNum range error"); | ||
} | ||
this.h = this.o = t; | ||
this.u = e; | ||
} | ||
clear() { | ||
this.i = 0; | ||
this.h = this.o; | ||
this.l = []; | ||
} | ||
} | ||
class SequentialContainer extends Container {} | ||
class RandomIterator extends ContainerIterator { | ||
constructor(t, e, s, i, r) { | ||
super(r); | ||
this.p = t; | ||
this.g = e; | ||
this.I = s; | ||
this.B = i; | ||
if (this.iteratorType === 0) { | ||
this.pre = function() { | ||
if (this.p === 0) { | ||
throw new RangeError("Random iterator access denied!"); | ||
} | ||
this.p -= 1; | ||
return this; | ||
}; | ||
this.next = function() { | ||
if (this.p === this.g()) { | ||
throw new RangeError("Random Iterator access denied!"); | ||
} | ||
this.p += 1; | ||
return this; | ||
}; | ||
} else { | ||
this.pre = function() { | ||
if (this.p === this.g() - 1) { | ||
throw new RangeError("Random iterator access denied!"); | ||
} | ||
this.p += 1; | ||
return this; | ||
}; | ||
this.next = function() { | ||
if (this.p === -1) { | ||
throw new RangeError("Random iterator access denied!"); | ||
} | ||
this.p -= 1; | ||
return this; | ||
}; | ||
} | ||
} | ||
get pointer() { | ||
if (this.p < 0 || this.p > this.g() - 1) { | ||
throw new RangeError; | ||
} | ||
return this.I(this.p); | ||
} | ||
set pointer(t) { | ||
if (this.p < 0 || this.p > this.g() - 1) { | ||
throw new RangeError; | ||
} | ||
this.B(this.p, t); | ||
} | ||
equals(t) { | ||
return this.p === t.p; | ||
} | ||
} | ||
class VectorIterator extends RandomIterator { | ||
copy() { | ||
return new VectorIterator(this.p, this.g, this.I, this.B, this.iteratorType); | ||
} | ||
} | ||
class Vector extends SequentialContainer { | ||
constructor(t = [], e = true) { | ||
super(); | ||
if (Array.isArray(t)) { | ||
this.m = e ? [ ...t ] : t; | ||
this.i = t.length; | ||
} else { | ||
this.m = []; | ||
t.forEach((t => this.pushBack(t))); | ||
} | ||
this.size = this.size.bind(this); | ||
this.getElementByPos = this.getElementByPos.bind(this); | ||
this.setElementByPos = this.setElementByPos.bind(this); | ||
} | ||
clear() { | ||
this.i = 0; | ||
this.m.length = 0; | ||
} | ||
begin() { | ||
return new VectorIterator(0, this.size, this.getElementByPos, this.setElementByPos); | ||
} | ||
end() { | ||
return new VectorIterator(this.i, this.size, this.getElementByPos, this.setElementByPos); | ||
} | ||
rBegin() { | ||
return new VectorIterator(this.i - 1, this.size, this.getElementByPos, this.setElementByPos, 1); | ||
} | ||
rEnd() { | ||
return new VectorIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1); | ||
} | ||
front() { | ||
return this.m[0]; | ||
} | ||
back() { | ||
return this.m[this.i - 1]; | ||
} | ||
forEach(t) { | ||
for (let e = 0; e < this.i; ++e) { | ||
t(this.m[e], e, this); | ||
} | ||
} | ||
getElementByPos(t) { | ||
if (t < 0 || t > this.i - 1) { | ||
throw new RangeError; | ||
} | ||
return this.m[t]; | ||
} | ||
eraseElementByPos(t) { | ||
if (t < 0 || t > this.i - 1) { | ||
throw new RangeError; | ||
} | ||
this.m.splice(t, 1); | ||
this.i -= 1; | ||
} | ||
eraseElementByValue(t) { | ||
let e = 0; | ||
for (let s = 0; s < this.i; ++s) { | ||
if (this.m[s] !== t) { | ||
this.m[e++] = this.m[s]; | ||
} | ||
} | ||
this.i = this.m.length = e; | ||
} | ||
eraseElementByIterator(t) { | ||
const e = t.p; | ||
t = t.next(); | ||
this.eraseElementByPos(e); | ||
return t; | ||
} | ||
pushBack(t) { | ||
this.m.push(t); | ||
this.i += 1; | ||
} | ||
popBack() { | ||
if (!this.i) return; | ||
this.m.pop(); | ||
this.i -= 1; | ||
} | ||
setElementByPos(t, e) { | ||
if (t < 0 || t > this.i - 1) { | ||
throw new RangeError; | ||
} | ||
this.m[t] = e; | ||
} | ||
insert(t, e, s = 1) { | ||
if (t < 0 || t > this.i) { | ||
throw new RangeError; | ||
} | ||
this.m.splice(t, 0, ...new Array(s).fill(e)); | ||
this.i += s; | ||
} | ||
find(t) { | ||
for (let e = 0; e < this.i; ++e) { | ||
if (this.m[e] === t) { | ||
return new VectorIterator(e, this.size, this.getElementByPos, this.getElementByPos); | ||
} | ||
} | ||
return this.end(); | ||
} | ||
reverse() { | ||
this.m.reverse(); | ||
} | ||
unique() { | ||
let t = 1; | ||
for (let e = 1; e < this.i; ++e) { | ||
if (this.m[e] !== this.m[e - 1]) { | ||
this.m[t++] = this.m[e]; | ||
} | ||
} | ||
this.i = this.m.length = t; | ||
} | ||
sort(t) { | ||
this.m.sort(t); | ||
} | ||
[Symbol.iterator]() { | ||
return function*() { | ||
return yield* this.m; | ||
}.bind(this)(); | ||
} | ||
} | ||
class TreeNode { | ||
constructor(t, e) { | ||
this.R = 1; | ||
this.O = undefined; | ||
this.M = undefined; | ||
this.V = undefined; | ||
this.N = undefined; | ||
this.T = undefined; | ||
this.O = t; | ||
this.M = e; | ||
} | ||
pre() { | ||
let t = this; | ||
if (t.R === 1 && t.T.T === t) { | ||
t = t.N; | ||
} else if (t.V) { | ||
t = t.V; | ||
while (t.N) { | ||
t = t.N; | ||
} | ||
} else { | ||
let e = t.T; | ||
while (e.V === t) { | ||
t = e; | ||
e = t.T; | ||
} | ||
t = e; | ||
} | ||
return t; | ||
} | ||
next() { | ||
let t = this; | ||
if (t.N) { | ||
t = t.N; | ||
while (t.V) { | ||
t = t.V; | ||
} | ||
return t; | ||
} else { | ||
let e = t.T; | ||
while (e.N === t) { | ||
t = e; | ||
e = t.T; | ||
} | ||
if (t.N !== e) { | ||
return e; | ||
} else return t; | ||
} | ||
} | ||
rotateLeft() { | ||
const t = this.T; | ||
const e = this.N; | ||
const s = e.V; | ||
if (t.T === this) t.T = e; else if (t.V === this) t.V = e; else t.N = e; | ||
e.T = t; | ||
e.V = this; | ||
this.T = e; | ||
this.N = s; | ||
if (s) s.T = this; | ||
return e; | ||
} | ||
rotateRight() { | ||
const t = this.T; | ||
const e = this.V; | ||
const s = e.N; | ||
if (t.T === this) t.T = e; else if (t.V === this) t.V = e; else t.N = e; | ||
e.T = t; | ||
e.N = this; | ||
this.T = e; | ||
this.V = s; | ||
if (s) s.T = this; | ||
return e; | ||
} | ||
} | ||
class TreeNodeEnableIndex extends TreeNode { | ||
constructor() { | ||
super(...arguments); | ||
this.V = undefined; | ||
this.N = undefined; | ||
this.T = undefined; | ||
this.C = 1; | ||
} | ||
rotateLeft() { | ||
const t = super.rotateLeft(); | ||
this.recount(); | ||
t.recount(); | ||
return t; | ||
} | ||
rotateRight() { | ||
const t = super.rotateRight(); | ||
this.recount(); | ||
t.recount(); | ||
return t; | ||
} | ||
recount() { | ||
this.C = 1; | ||
if (this.V) this.C += this.V.C; | ||
if (this.N) this.C += this.N.C; | ||
} | ||
} | ||
class TreeContainer extends Container { | ||
constructor(t = ((t, e) => { | ||
if (t < e) return -1; | ||
if (t > e) return 1; | ||
return 0; | ||
}), e = false) { | ||
super(); | ||
this._ = undefined; | ||
this.P = (t, e) => { | ||
if (t === undefined) return false; | ||
const s = this.P(t.V, e); | ||
if (s) return true; | ||
if (e(t)) return true; | ||
return this.P(t.N, e); | ||
}; | ||
this.S = t; | ||
if (e) { | ||
this.k = TreeNodeEnableIndex; | ||
this.v = function(t, e, s) { | ||
const i = this.q(t, e, s); | ||
if (i) { | ||
let t = i.T; | ||
while (t !== this.H) { | ||
t.C += 1; | ||
t = t.T; | ||
} | ||
const e = this.K(i); | ||
if (e) { | ||
const {parentNode: t, grandParent: s, curNode: i} = e; | ||
t.recount(); | ||
s.recount(); | ||
i.recount(); | ||
} | ||
} | ||
}; | ||
this.j = function(t) { | ||
let e = this.L(t); | ||
while (e !== this.H) { | ||
e.C -= 1; | ||
e = e.T; | ||
} | ||
}; | ||
} else { | ||
this.k = TreeNode; | ||
this.v = function(t, e, s) { | ||
const i = this.q(t, e, s); | ||
if (i) this.K(i); | ||
}; | ||
this.j = this.L; | ||
} | ||
this.H = new this.k; | ||
this.h = []; | ||
this.o = {}; | ||
this.HASH_KEY_TAG = Symbol("JS_SDSL_HASH_KEY_TAG"); | ||
Object.setPrototypeOf(this.o, null); | ||
} | ||
A(t, e) { | ||
let s; | ||
while (t) { | ||
const i = this.S(t.O, e); | ||
if (i < 0) { | ||
t = t.N; | ||
} else if (i > 0) { | ||
s = t; | ||
t = t.V; | ||
} else return t; | ||
} | ||
return s === undefined ? this.H : s; | ||
} | ||
U(t, e) { | ||
let s; | ||
while (t) { | ||
const i = this.S(t.O, e); | ||
if (i <= 0) { | ||
t = t.N; | ||
} else { | ||
s = t; | ||
t = t.V; | ||
} | ||
} | ||
return s === undefined ? this.H : s; | ||
} | ||
J(t, e) { | ||
let s; | ||
while (t) { | ||
const i = this.S(t.O, e); | ||
if (i < 0) { | ||
s = t; | ||
t = t.N; | ||
} else if (i > 0) { | ||
t = t.V; | ||
} else return t; | ||
} | ||
return s === undefined ? this.H : s; | ||
} | ||
D(t, e) { | ||
let s; | ||
while (t) { | ||
const i = this.S(t.O, e); | ||
if (i < 0) { | ||
s = t; | ||
t = t.N; | ||
} else { | ||
t = t.V; | ||
} | ||
} | ||
return s === undefined ? this.H : s; | ||
} | ||
F(t) { | ||
while (true) { | ||
const e = t.T; | ||
if (e === this.H) return; | ||
if (t.R === 1) { | ||
t.R = 0; | ||
u(t, e, s) { | ||
if (s === undefined) s = checkObject(t); | ||
if (s) { | ||
const s = t[this.HASH_KEY_TAG]; | ||
if (s !== undefined) { | ||
this.h[s][1] = e; | ||
return; | ||
} | ||
if (t === e.V) { | ||
const s = e.N; | ||
if (s.R === 1) { | ||
s.R = 0; | ||
e.R = 1; | ||
if (e === this._) { | ||
this._ = e.rotateLeft(); | ||
} else e.rotateLeft(); | ||
} else { | ||
if (s.N && s.N.R === 1) { | ||
s.R = e.R; | ||
e.R = 0; | ||
s.N.R = 0; | ||
if (e === this._) { | ||
this._ = e.rotateLeft(); | ||
} else e.rotateLeft(); | ||
return; | ||
} else if (s.V && s.V.R === 1) { | ||
s.R = 1; | ||
s.V.R = 0; | ||
s.rotateRight(); | ||
} else { | ||
s.R = 1; | ||
t = e; | ||
} | ||
} | ||
} else { | ||
const s = e.V; | ||
if (s.R === 1) { | ||
s.R = 0; | ||
e.R = 1; | ||
if (e === this._) { | ||
this._ = e.rotateRight(); | ||
} else e.rotateRight(); | ||
} else { | ||
if (s.V && s.V.R === 1) { | ||
s.R = e.R; | ||
e.R = 0; | ||
s.V.R = 0; | ||
if (e === this._) { | ||
this._ = e.rotateRight(); | ||
} else e.rotateRight(); | ||
return; | ||
} else if (s.N && s.N.R === 1) { | ||
s.R = 1; | ||
s.N.R = 0; | ||
s.rotateLeft(); | ||
} else { | ||
s.R = 1; | ||
t = e; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
L(t) { | ||
if (this.i === 1) { | ||
this.clear(); | ||
return this.H; | ||
} | ||
let e = t; | ||
while (e.V || e.N) { | ||
if (e.N) { | ||
e = e.N; | ||
while (e.V) e = e.V; | ||
} else { | ||
e = e.V; | ||
} | ||
[t.O, e.O] = [ e.O, t.O ]; | ||
[t.M, e.M] = [ e.M, t.M ]; | ||
t = e; | ||
} | ||
if (this.H.V === e) { | ||
this.H.V = e.T; | ||
} else if (this.H.N === e) { | ||
this.H.N = e.T; | ||
} | ||
this.F(e); | ||
const s = e.T; | ||
if (e === s.V) { | ||
s.V = undefined; | ||
} else s.N = undefined; | ||
this.i -= 1; | ||
this._.R = 0; | ||
return s; | ||
} | ||
K(t) { | ||
while (true) { | ||
const e = t.T; | ||
if (e.R === 0) return; | ||
const s = e.T; | ||
if (e === s.V) { | ||
const i = s.N; | ||
if (i && i.R === 1) { | ||
i.R = e.R = 0; | ||
if (s === this._) return; | ||
s.R = 1; | ||
t = s; | ||
continue; | ||
} else if (t === e.N) { | ||
t.R = 0; | ||
if (t.V) t.V.T = e; | ||
if (t.N) t.N.T = s; | ||
e.N = t.V; | ||
s.V = t.N; | ||
t.V = e; | ||
t.N = s; | ||
if (s === this._) { | ||
this._ = t; | ||
this.H.T = t; | ||
} else { | ||
const e = s.T; | ||
if (e.V === s) { | ||
e.V = t; | ||
} else e.N = t; | ||
} | ||
t.T = s.T; | ||
e.T = t; | ||
s.T = t; | ||
s.R = 1; | ||
return { | ||
parentNode: e, | ||
grandParent: s, | ||
curNode: t | ||
}; | ||
} else { | ||
e.R = 0; | ||
if (s === this._) { | ||
this._ = s.rotateRight(); | ||
} else s.rotateRight(); | ||
s.R = 1; | ||
} | ||
} else { | ||
const i = s.V; | ||
if (i && i.R === 1) { | ||
i.R = e.R = 0; | ||
if (s === this._) return; | ||
s.R = 1; | ||
t = s; | ||
continue; | ||
} else if (t === e.V) { | ||
t.R = 0; | ||
if (t.V) t.V.T = s; | ||
if (t.N) t.N.T = e; | ||
s.N = t.V; | ||
e.V = t.N; | ||
t.V = s; | ||
t.N = e; | ||
if (s === this._) { | ||
this._ = t; | ||
this.H.T = t; | ||
} else { | ||
const e = s.T; | ||
if (e.V === s) { | ||
e.V = t; | ||
} else e.N = t; | ||
} | ||
t.T = s.T; | ||
e.T = t; | ||
s.T = t; | ||
s.R = 1; | ||
return { | ||
parentNode: e, | ||
grandParent: s, | ||
curNode: t | ||
}; | ||
} else { | ||
e.R = 0; | ||
if (s === this._) { | ||
this._ = s.rotateLeft(); | ||
} else s.rotateLeft(); | ||
s.R = 1; | ||
} | ||
} | ||
return; | ||
} | ||
} | ||
q(t, e, s) { | ||
if (this._ === undefined) { | ||
this.i += 1; | ||
this._ = new this.k(t, e); | ||
this._.R = 0; | ||
this._.T = this.H; | ||
this.H.T = this._; | ||
this.H.V = this._; | ||
this.H.N = this._; | ||
return; | ||
} | ||
let i; | ||
const r = this.H.V; | ||
const n = this.S(r.O, t); | ||
if (n === 0) { | ||
r.M = e; | ||
return; | ||
} else if (n > 0) { | ||
r.V = new this.k(t, e); | ||
r.V.T = r; | ||
i = r.V; | ||
this.H.V = i; | ||
Object.defineProperty(t, this.HASH_KEY_TAG, { | ||
value: this.h.length, | ||
configurable: true | ||
}); | ||
this.h.push([ t, e ]); | ||
} else { | ||
const r = this.H.N; | ||
const n = this.S(r.O, t); | ||
if (n === 0) { | ||
r.M = e; | ||
const s = this.o[t]; | ||
if (s) { | ||
s[1] = e; | ||
return; | ||
} else if (n < 0) { | ||
r.N = new this.k(t, e); | ||
r.N.T = r; | ||
i = r.N; | ||
this.H.N = i; | ||
} else { | ||
if (s !== undefined) { | ||
const r = s.p; | ||
if (r !== this.H) { | ||
const s = this.S(r.O, t); | ||
if (s === 0) { | ||
r.M = e; | ||
return; | ||
} else if (s > 0) { | ||
const s = r.pre(); | ||
const n = this.S(s.O, t); | ||
if (n === 0) { | ||
s.M = e; | ||
return; | ||
} else if (n < 0) { | ||
i = new this.k(t, e); | ||
if (s.N === undefined) { | ||
s.N = i; | ||
i.T = s; | ||
} else { | ||
r.V = i; | ||
i.T = r; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (i === undefined) { | ||
i = this._; | ||
while (true) { | ||
const s = this.S(i.O, t); | ||
if (s > 0) { | ||
if (i.V === undefined) { | ||
i.V = new this.k(t, e); | ||
i.V.T = i; | ||
i = i.V; | ||
break; | ||
} | ||
i = i.V; | ||
} else if (s < 0) { | ||
if (i.N === undefined) { | ||
i.N = new this.k(t, e); | ||
i.N.T = i; | ||
i = i.N; | ||
break; | ||
} | ||
i = i.N; | ||
} else { | ||
i.M = e; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
this.o[t] = [ t, e ]; | ||
} | ||
this.i += 1; | ||
return i; | ||
} | ||
clear() { | ||
const t = this; | ||
this.h.forEach((function(e) { | ||
delete e[0][t.HASH_KEY_TAG]; | ||
})); | ||
this.h = []; | ||
this.o = {}; | ||
Object.setPrototypeOf(this.o, null); | ||
this.i = 0; | ||
this._ = undefined; | ||
this.H.T = undefined; | ||
this.H.V = this.H.N = undefined; | ||
} | ||
updateKeyByIterator(t, e) { | ||
const s = t.p; | ||
if (s === this.H) { | ||
throw new TypeError("Invalid iterator!"); | ||
eraseElementByKey(t, e) { | ||
if (e === undefined) e = checkObject(t); | ||
if (e) { | ||
const e = t[this.HASH_KEY_TAG]; | ||
if (e === undefined) return; | ||
delete t[this.HASH_KEY_TAG]; | ||
delete this.h[e]; | ||
} else { | ||
if (this.o[t] === undefined) return; | ||
delete this.o[t]; | ||
} | ||
if (this.i === 1) { | ||
s.O = e; | ||
return true; | ||
} | ||
if (s === this.H.V) { | ||
if (this.S(s.next().O, e) > 0) { | ||
s.O = e; | ||
return true; | ||
} | ||
return false; | ||
} | ||
if (s === this.H.N) { | ||
if (this.S(s.pre().O, e) < 0) { | ||
s.O = e; | ||
return true; | ||
} | ||
return false; | ||
} | ||
const i = s.pre().O; | ||
if (this.S(i, e) >= 0) return false; | ||
const r = s.next().O; | ||
if (this.S(r, e) <= 0) return false; | ||
s.O = e; | ||
return true; | ||
this.i -= 1; | ||
} | ||
eraseElementByPos(t) { | ||
if (t < 0 || t > this.i - 1) { | ||
throw new RangeError; | ||
} | ||
let e = 0; | ||
this.P(this._, (s => { | ||
if (t === e) { | ||
this.j(s); | ||
return true; | ||
} | ||
e += 1; | ||
return false; | ||
})); | ||
} | ||
G(t, e) { | ||
while (t) { | ||
const s = this.S(t.O, e); | ||
if (s < 0) { | ||
t = t.N; | ||
} else if (s > 0) { | ||
t = t.V; | ||
} else return t; | ||
} | ||
return t; | ||
} | ||
eraseElementByKey(t) { | ||
if (!this.i) return; | ||
const e = this.G(this._, t); | ||
if (e === undefined) return; | ||
this.j(e); | ||
} | ||
eraseElementByIterator(t) { | ||
const e = t.p; | ||
if (e === this.H) { | ||
throw new RangeError("Invalid iterator"); | ||
} | ||
if (e.N === undefined) { | ||
t = t.next(); | ||
} | ||
this.j(e); | ||
return t; | ||
} | ||
getHeight() { | ||
if (!this.i) return 0; | ||
const traversal = t => { | ||
if (!t) return 0; | ||
return Math.max(traversal(t.V), traversal(t.N)) + 1; | ||
}; | ||
return traversal(this._); | ||
} | ||
} | ||
class TreeIterator extends ContainerIterator { | ||
constructor(t, e, s) { | ||
super(s); | ||
this.p = t; | ||
this.H = e; | ||
if (this.iteratorType === 0) { | ||
this.pre = function() { | ||
if (this.p === this.H.V) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
} | ||
this.p = this.p.pre(); | ||
return this; | ||
}; | ||
this.next = function() { | ||
if (this.p === this.H) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
} | ||
this.p = this.p.next(); | ||
return this; | ||
}; | ||
find(t, e) { | ||
if (e === undefined) e = checkObject(t); | ||
if (e) { | ||
return typeof t[this.HASH_KEY_TAG] === "number"; | ||
} else { | ||
this.pre = function() { | ||
if (this.p === this.H.N) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
} | ||
this.p = this.p.next(); | ||
return this; | ||
}; | ||
this.next = function() { | ||
if (this.p === this.H) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
} | ||
this.p = this.p.pre(); | ||
return this; | ||
}; | ||
return this.o[t] !== undefined; | ||
} | ||
} | ||
get index() { | ||
let t = this.p; | ||
const e = this.H.T; | ||
if (t === this.H) { | ||
if (e) { | ||
return e.C - 1; | ||
} | ||
return 0; | ||
} | ||
let s = 0; | ||
if (t.V) { | ||
s += t.V.C; | ||
} | ||
while (t !== e) { | ||
const e = t.T; | ||
if (t === e.N) { | ||
s += 1; | ||
if (e.V) { | ||
s += e.V.C; | ||
} | ||
} | ||
t = e; | ||
} | ||
return s; | ||
} | ||
equals(t) { | ||
return this.p === t.p; | ||
} | ||
} | ||
class OrderedMapIterator extends TreeIterator { | ||
get pointer() { | ||
if (this.p === this.H) { | ||
throw new RangeError("OrderedMap iterator access denied"); | ||
} | ||
return new Proxy([], { | ||
get: (t, e) => { | ||
if (e === "0") return this.p.O; else if (e === "1") return this.p.M; | ||
}, | ||
set: (t, e, s) => { | ||
if (e !== "1") { | ||
throw new TypeError("props must be 1"); | ||
} | ||
this.p.M = s; | ||
return true; | ||
} | ||
}); | ||
class HashMap extends HashContainer { | ||
constructor(t = []) { | ||
super(); | ||
const e = this; | ||
t.forEach((function(t) { | ||
e.setElement(t[0], t[1]); | ||
})); | ||
} | ||
copy() { | ||
return new OrderedMapIterator(this.p, this.H, this.iteratorType); | ||
} | ||
} | ||
class OrderedMap extends TreeContainer { | ||
constructor(t = [], e, s) { | ||
super(e, s); | ||
this.W = function*(t) { | ||
if (t === undefined) return; | ||
yield* this.W(t.V); | ||
yield [ t.O, t.M ]; | ||
yield* this.W(t.N); | ||
}; | ||
t.forEach((([t, e]) => this.setElement(t, e))); | ||
} | ||
begin() { | ||
return new OrderedMapIterator(this.H.V || this.H, this.H); | ||
} | ||
end() { | ||
return new OrderedMapIterator(this.H, this.H); | ||
} | ||
rBegin() { | ||
return new OrderedMapIterator(this.H.N || this.H, this.H, 1); | ||
} | ||
rEnd() { | ||
return new OrderedMapIterator(this.H, this.H, 1); | ||
} | ||
front() { | ||
if (!this.i) return undefined; | ||
const t = this.H.V; | ||
return [ t.O, t.M ]; | ||
} | ||
back() { | ||
if (!this.i) return undefined; | ||
const t = this.H.N; | ||
return [ t.O, t.M ]; | ||
} | ||
forEach(t) { | ||
let e = 0; | ||
for (const s of this) t(s, e++, this); | ||
} | ||
lowerBound(t) { | ||
const e = this.A(this._, t); | ||
return new OrderedMapIterator(e, this.H); | ||
} | ||
upperBound(t) { | ||
const e = this.U(this._, t); | ||
return new OrderedMapIterator(e, this.H); | ||
} | ||
reverseLowerBound(t) { | ||
const e = this.J(this._, t); | ||
return new OrderedMapIterator(e, this.H); | ||
} | ||
reverseUpperBound(t) { | ||
const e = this.D(this._, t); | ||
return new OrderedMapIterator(e, this.H); | ||
} | ||
setElement(t, e, s) { | ||
this.v(t, e, s); | ||
this.u(t, e, s); | ||
} | ||
find(t) { | ||
const e = this.G(this._, t); | ||
if (e !== undefined) { | ||
return new OrderedMapIterator(e, this.H); | ||
getElementByKey(t, e) { | ||
if (e === undefined) e = checkObject(t); | ||
if (e) { | ||
const e = t[this.HASH_KEY_TAG]; | ||
return e !== undefined ? this.h[e][1] : undefined; | ||
} | ||
return this.end(); | ||
const s = this.o[t]; | ||
return s ? s[1] : undefined; | ||
} | ||
getElementByKey(t) { | ||
const e = this.G(this._, t); | ||
return e ? e.M : undefined; | ||
} | ||
getElementByPos(t) { | ||
if (t < 0 || t > this.i - 1) { | ||
throw new RangeError; | ||
forEach(t) { | ||
const e = this.h.length; | ||
for (let s = 0; s < e; ++s) { | ||
t(this.h[s], s, this); | ||
} | ||
let e; | ||
let s = 0; | ||
for (const i of this) { | ||
if (s === t) { | ||
e = i; | ||
break; | ||
} | ||
s += 1; | ||
} | ||
return e; | ||
} | ||
union(t) { | ||
t.forEach((([t, e]) => this.setElement(t, e))); | ||
} | ||
[Symbol.iterator]() { | ||
return this.W(this._); | ||
} | ||
} | ||
class HashMap extends HashContainer { | ||
constructor(t = [], e, s) { | ||
super(e, s); | ||
this.l = []; | ||
t.forEach((t => this.setElement(t[0], t[1]))); | ||
} | ||
X() { | ||
if (this.h >= 1073741824) return; | ||
const t = []; | ||
const e = this.h; | ||
this.h <<= 1; | ||
const s = Object.keys(this.l); | ||
const s = Object.keys(this.o); | ||
const i = s.length; | ||
for (let r = 0; r < i; ++r) { | ||
const i = parseInt(s[r]); | ||
const n = this.l[i]; | ||
const h = n.size(); | ||
if (h === 0) continue; | ||
if (h === 1) { | ||
const e = n.front(); | ||
t[this.u(e[0]) & this.h - 1] = new Vector([ e ], false); | ||
continue; | ||
} | ||
const o = []; | ||
const f = []; | ||
n.forEach((t => { | ||
const s = this.u(t[0]); | ||
if ((s & e) === 0) { | ||
o.push(t); | ||
} else f.push(t); | ||
})); | ||
if (n instanceof OrderedMap) { | ||
if (o.length > 6) { | ||
t[i] = new OrderedMap(o); | ||
} else { | ||
t[i] = new Vector(o, false); | ||
} | ||
if (f.length > 6) { | ||
t[i + e] = new OrderedMap(f); | ||
} else { | ||
t[i + e] = new Vector(f, false); | ||
} | ||
} else { | ||
t[i] = new Vector(o, false); | ||
t[i + e] = new Vector(f, false); | ||
} | ||
let n = e; | ||
for (let e = 0; e < i; ++e) { | ||
t(this.o[s[e]], n++, this); | ||
} | ||
this.l = t; | ||
} | ||
forEach(t) { | ||
const e = Object.values(this.l); | ||
const s = e.length; | ||
let i = 0; | ||
for (let r = 0; r < s; ++r) { | ||
e[r].forEach((e => t(e, i++, this))); | ||
const c = Object.getOwnPropertySymbols(this.o); | ||
const h = c.length; | ||
for (let e = 0; e < h; ++e) { | ||
t(this.o[c[e]], n++, this); | ||
} | ||
} | ||
setElement(t, e) { | ||
const s = this.u(t) & this.h - 1; | ||
const i = this.l[s]; | ||
if (!i) { | ||
this.i += 1; | ||
this.l[s] = new Vector([ [ t, e ] ], false); | ||
} else { | ||
const r = i.size(); | ||
if (i instanceof Vector) { | ||
for (const s of i) { | ||
if (s[0] === t) { | ||
s[1] = e; | ||
return; | ||
} | ||
} | ||
i.pushBack([ t, e ]); | ||
if (r + 1 >= 8) { | ||
if (this.h <= 64) { | ||
this.i += 1; | ||
this.X(); | ||
return; | ||
} | ||
this.l[s] = new OrderedMap(this.l[s]); | ||
} | ||
this.i += 1; | ||
} else { | ||
i.setElement(t, e); | ||
const s = i.size(); | ||
this.i += s - r; | ||
} | ||
} | ||
if (this.i > this.h * .75) { | ||
this.X(); | ||
} | ||
} | ||
getElementByKey(t) { | ||
const e = this.u(t) & this.h - 1; | ||
const s = this.l[e]; | ||
if (!s) return undefined; | ||
if (s instanceof OrderedMap) { | ||
return s.getElementByKey(t); | ||
} else { | ||
for (const e of s) { | ||
if (e[0] === t) return e[1]; | ||
} | ||
return undefined; | ||
} | ||
} | ||
eraseElementByKey(t) { | ||
const e = this.u(t) & this.h - 1; | ||
const s = this.l[e]; | ||
if (!s) return; | ||
if (s instanceof Vector) { | ||
let e = 0; | ||
for (const i of s) { | ||
if (i[0] === t) { | ||
s.eraseElementByPos(e); | ||
this.i -= 1; | ||
return; | ||
} | ||
e += 1; | ||
} | ||
} else { | ||
const i = s.size(); | ||
s.eraseElementByKey(t); | ||
const r = s.size(); | ||
this.i += r - i; | ||
if (r <= 6) { | ||
this.l[e] = new Vector(s); | ||
} | ||
} | ||
} | ||
find(t) { | ||
const e = this.u(t) & this.h - 1; | ||
const s = this.l[e]; | ||
if (!s) return false; | ||
if (s instanceof OrderedMap) { | ||
return !s.find(t).equals(s.end()); | ||
} | ||
for (const e of s) { | ||
if (e[0] === t) return true; | ||
} | ||
return false; | ||
} | ||
[Symbol.iterator]() { | ||
return function*() { | ||
const t = Object.values(this.l); | ||
yield* this.h; | ||
const t = Object.keys(this.o); | ||
const e = t.length; | ||
for (let s = 0; s < e; ++s) { | ||
const e = t[s]; | ||
for (const t of e) { | ||
yield t; | ||
} | ||
yield this.o[t[s]]; | ||
} | ||
const s = Object.getOwnPropertySymbols(this.o); | ||
const i = s.length; | ||
for (let t = 0; t < i; ++t) { | ||
yield this.o[s[t]]; | ||
} | ||
}.bind(this)(); | ||
@@ -1145,0 +142,0 @@ } |
@@ -33,23 +33,29 @@ declare abstract class Base { | ||
}; | ||
declare abstract class HashContainer<K> extends Base { | ||
protected constructor(initBucketNum?: number, hashFunc?: (x: K) => number); | ||
declare abstract class HashContainer<K, V> extends Base { | ||
protected constructor(); | ||
clear(): void; | ||
/** | ||
* @description Iterate over all elements in the container. | ||
* @param callback Callback function like Array.forEach. | ||
* @example container.forEach((element, index) => console.log(element, index)); | ||
* @description Remove the element of the specified key. | ||
* @param key The key you want to remove. | ||
* @param isObject Tell us if the type of inserted key is `object` to improve efficiency.<br/> | ||
* If a `undefined` value is passed in, the type will be automatically judged. | ||
*/ | ||
abstract forEach(callback: (element: unknown, index: number, hashContainer: HashContainer<K>) => void): void; | ||
eraseElementByKey(key: K, isObject?: boolean): void; | ||
/** | ||
* @description Remove the elements of the specified value. | ||
* @param key The element you want to remove. | ||
* @example container.eraseElementByKey(1); | ||
* @description Check key if exist in container. | ||
* @param key The element you want to search. | ||
* @param isObject Tell us if the type of inserted key is `object` to improve efficiency.<br/> | ||
* If a `undefined` value is passed in, the type will be automatically judged. | ||
* @return Boolean about if key exist in container. | ||
*/ | ||
abstract eraseElementByKey(key: K): void; | ||
find(key: K, isObject?: boolean): boolean; | ||
/** | ||
* @param key The element you want to find. | ||
* @return Boolean about if the specified element in the hash set. | ||
* @example container.find(1).equals(container.end()); | ||
* @description Iterate over all elements in the container. | ||
* @param callback Callback function like Array.forEach. | ||
* @example container.forEach((element, index) => console.log(element, index)); | ||
*/ | ||
abstract find(key: K): void; | ||
abstract forEach(callback: (element: K | [ | ||
K, | ||
V | ||
], index: number, hashContainer: HashContainer<K, V>) => void): void; | ||
/** | ||
@@ -64,42 +70,36 @@ * @description Using for `for...of` syntax like Array. | ||
K, | ||
unknown | ||
V | ||
], void, undefined>; | ||
} | ||
declare class HashMap<K, V> extends HashContainer<K> { | ||
/** | ||
* @description HashMap's constructor. | ||
* @param container Initialize container, must have a forEach function. | ||
* @param initBucketNum Initialize bucket num, must be an integer power of 2 and greater than 16. | ||
* @param hashFunc The hash function, convert key element from type T to a number. | ||
* @example new HashMap([[0, 1], [2, 1], [3, 2]], 1 << 10, x => x); | ||
*/ | ||
declare class HashMap<K, V> extends HashContainer<K, V> { | ||
constructor(container?: initContainer<[ | ||
K, | ||
V | ||
]>, initBucketNum?: number, hashFunc?: (x: K) => number); | ||
forEach(callback: (element: [ | ||
K, | ||
V | ||
], index: number, map: HashMap<K, V>) => void): void; | ||
]>); | ||
/** | ||
* @description Insert a new key-value pair to hash map or set value by key. | ||
* @param key The key you want to insert. | ||
* @param value The value you want to insert. | ||
* @example HashMap.setElement(1, 2); // insert a key-value pair [1, 2] | ||
* @description Insert a key-value pair or set value by the given key. | ||
* @param key The key want to insert. | ||
* @param value The value want to set. | ||
* @param isObject Tell us if the type of inserted key is `object` to improve efficiency.<br/> | ||
* If a `undefined` value is passed in, the type will be automatically judged. | ||
*/ | ||
setElement(key: K, value: V): void; | ||
setElement(key: K, value: V, isObject?: boolean): void; | ||
/** | ||
* @description Get the value of the element which has the specified key. | ||
* @param key The key you want to get. | ||
* @example const value = container.getElementByKey(1); | ||
* @description Get the value of the element of the specified key. | ||
* @param key The key want to search. | ||
* @param isObject Tell us if the type of inserted key is `object` to improve efficiency.<br/> | ||
* If a `undefined` value is passed in, the type will be automatically judged. | ||
* @example const val = container.getElementByKey(1); | ||
*/ | ||
getElementByKey(key: K): V | undefined; | ||
eraseElementByKey(key: K): void; | ||
find(key: K): boolean; | ||
getElementByKey(key: K, isObject?: boolean): V | undefined; | ||
forEach(callback: (element: [ | ||
K, | ||
V | ||
], index: number, hashMap: HashMap<K, V>) => void): void; | ||
[Symbol.iterator](): Generator<[ | ||
K, | ||
V | ||
], void, unknown>; | ||
], void, undefined>; | ||
} | ||
export { HashMap }; | ||
export type { HashContainer }; |
@@ -1,23 +0,23 @@ | ||
var extendStatics = function(r, e) { | ||
var extendStatics = function(t, e) { | ||
extendStatics = Object.setPrototypeOf || { | ||
__proto__: [] | ||
} instanceof Array && function(r, e) { | ||
r.__proto__ = e; | ||
} || function(r, e) { | ||
for (var t in e) if (Object.prototype.hasOwnProperty.call(e, t)) r[t] = e[t]; | ||
} instanceof Array && function(t, e) { | ||
t.__proto__ = e; | ||
} || function(t, e) { | ||
for (var n in e) if (Object.prototype.hasOwnProperty.call(e, n)) t[n] = e[n]; | ||
}; | ||
return extendStatics(r, e); | ||
return extendStatics(t, e); | ||
}; | ||
function __extends(r, e) { | ||
function __extends(t, e) { | ||
if (typeof e !== "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null"); | ||
extendStatics(r, e); | ||
extendStatics(t, e); | ||
function __() { | ||
this.constructor = r; | ||
this.constructor = t; | ||
} | ||
r.prototype = e === null ? Object.create(e) : (__.prototype = e.prototype, new __); | ||
t.prototype = e === null ? Object.create(e) : (__.prototype = e.prototype, new __); | ||
} | ||
function __generator(r, e) { | ||
var t = { | ||
function __generator(t, e) { | ||
var n = { | ||
label: 0, | ||
@@ -30,3 +30,3 @@ sent: function() { | ||
ops: [] | ||
}, i, n, s, a; | ||
}, r, i, s, a; | ||
return a = { | ||
@@ -39,23 +39,23 @@ next: verb(0), | ||
}), a; | ||
function verb(r) { | ||
function verb(t) { | ||
return function(e) { | ||
return step([ r, e ]); | ||
return step([ t, e ]); | ||
}; | ||
} | ||
function step(a) { | ||
if (i) throw new TypeError("Generator is already executing."); | ||
while (t) try { | ||
if (i = 1, n && (s = a[0] & 2 ? n["return"] : a[0] ? n["throw"] || ((s = n["return"]) && s.call(n), | ||
0) : n.next) && !(s = s.call(n, a[1])).done) return s; | ||
if (n = 0, s) a = [ a[0] & 2, s.value ]; | ||
switch (a[0]) { | ||
function step(u) { | ||
if (r) throw new TypeError("Generator is already executing."); | ||
while (a && (a = 0, u[0] && (n = 0)), n) try { | ||
if (r = 1, i && (s = u[0] & 2 ? i["return"] : u[0] ? i["throw"] || ((s = i["return"]) && s.call(i), | ||
0) : i.next) && !(s = s.call(i, u[1])).done) return s; | ||
if (i = 0, s) u = [ u[0] & 2, s.value ]; | ||
switch (u[0]) { | ||
case 0: | ||
case 1: | ||
s = a; | ||
s = u; | ||
break; | ||
case 4: | ||
t.label++; | ||
n.label++; | ||
return { | ||
value: a[1], | ||
value: u[1], | ||
done: false | ||
@@ -65,45 +65,45 @@ }; | ||
case 5: | ||
t.label++; | ||
n = a[1]; | ||
a = [ 0 ]; | ||
n.label++; | ||
i = u[1]; | ||
u = [ 0 ]; | ||
continue; | ||
case 7: | ||
a = t.ops.pop(); | ||
t.trys.pop(); | ||
u = n.ops.pop(); | ||
n.trys.pop(); | ||
continue; | ||
default: | ||
if (!(s = t.trys, s = s.length > 0 && s[s.length - 1]) && (a[0] === 6 || a[0] === 2)) { | ||
t = 0; | ||
if (!(s = n.trys, s = s.length > 0 && s[s.length - 1]) && (u[0] === 6 || u[0] === 2)) { | ||
n = 0; | ||
continue; | ||
} | ||
if (a[0] === 3 && (!s || a[1] > s[0] && a[1] < s[3])) { | ||
t.label = a[1]; | ||
if (u[0] === 3 && (!s || u[1] > s[0] && u[1] < s[3])) { | ||
n.label = u[1]; | ||
break; | ||
} | ||
if (a[0] === 6 && t.label < s[1]) { | ||
t.label = s[1]; | ||
s = a; | ||
if (u[0] === 6 && n.label < s[1]) { | ||
n.label = s[1]; | ||
s = u; | ||
break; | ||
} | ||
if (s && t.label < s[2]) { | ||
t.label = s[2]; | ||
t.ops.push(a); | ||
if (s && n.label < s[2]) { | ||
n.label = s[2]; | ||
n.ops.push(u); | ||
break; | ||
} | ||
if (s[2]) t.ops.pop(); | ||
t.trys.pop(); | ||
if (s[2]) n.ops.pop(); | ||
n.trys.pop(); | ||
continue; | ||
} | ||
a = e.call(r, t); | ||
} catch (r) { | ||
a = [ 6, r ]; | ||
n = 0; | ||
u = e.call(t, n); | ||
} catch (t) { | ||
u = [ 6, t ]; | ||
i = 0; | ||
} finally { | ||
i = s = 0; | ||
r = s = 0; | ||
} | ||
if (a[0] & 5) throw a[1]; | ||
if (u[0] & 5) throw u[1]; | ||
return { | ||
value: a[0] ? a[1] : void 0, | ||
value: u[0] ? u[1] : void 0, | ||
done: true | ||
@@ -114,11 +114,11 @@ }; | ||
function __values(r) { | ||
var e = typeof Symbol === "function" && Symbol.iterator, t = e && r[e], i = 0; | ||
if (t) return t.call(r); | ||
if (r && typeof r.length === "number") return { | ||
function __values(t) { | ||
var e = typeof Symbol === "function" && Symbol.iterator, n = e && t[e], r = 0; | ||
if (n) return n.call(t); | ||
if (t && typeof t.length === "number") return { | ||
next: function() { | ||
if (r && i >= r.length) r = void 0; | ||
if (t && r >= t.length) t = void 0; | ||
return { | ||
value: r && r[i++], | ||
done: !r | ||
value: t && t[r++], | ||
done: !t | ||
}; | ||
@@ -130,42 +130,2 @@ } | ||
function __read(r, e) { | ||
var t = typeof Symbol === "function" && r[Symbol.iterator]; | ||
if (!t) return r; | ||
var i = t.call(r), n, s = [], a; | ||
try { | ||
while ((e === void 0 || e-- > 0) && !(n = i.next()).done) s.push(n.value); | ||
} catch (r) { | ||
a = { | ||
error: r | ||
}; | ||
} finally { | ||
try { | ||
if (n && !n.done && (t = i["return"])) t.call(i); | ||
} finally { | ||
if (a) throw a.error; | ||
} | ||
} | ||
return s; | ||
} | ||
function __spreadArray(r, e, t) { | ||
if (t || arguments.length === 2) for (var i = 0, n = e.length, s; i < n; i++) { | ||
if (s || !(i in e)) { | ||
if (!s) s = Array.prototype.slice.call(e, 0, i); | ||
s[i] = e[i]; | ||
} | ||
} | ||
return r.concat(s || Array.prototype.slice.call(e)); | ||
} | ||
var ContainerIterator = function() { | ||
function ContainerIterator(r) { | ||
if (r === void 0) { | ||
r = 0; | ||
} | ||
this.iteratorType = r; | ||
} | ||
return ContainerIterator; | ||
}(); | ||
var Base = function() { | ||
@@ -184,1384 +144,171 @@ function Base() { | ||
var Container = function(r) { | ||
__extends(Container, r); | ||
(function(t) { | ||
__extends(Container, t); | ||
function Container() { | ||
return r !== null && r.apply(this, arguments) || this; | ||
return t !== null && t.apply(this, arguments) || this; | ||
} | ||
return Container; | ||
}(Base); | ||
})(Base); | ||
var HashContainer = function(r) { | ||
__extends(HashContainer, r); | ||
function HashContainer(e, t) { | ||
if (e === void 0) { | ||
e = 16; | ||
} | ||
if (t === void 0) { | ||
t = function(r) { | ||
var e; | ||
if (typeof r !== "string") { | ||
e = JSON.stringify(r); | ||
} else e = r; | ||
var t = 0; | ||
var i = e.length; | ||
for (var n = 0; n < i; n++) { | ||
var s = e.charCodeAt(n); | ||
t = (t << 5) - t + s; | ||
t |= 0; | ||
} | ||
return t >>> 0; | ||
}; | ||
} | ||
var i = r.call(this) || this; | ||
if (e < 16 || (e & e - 1) !== 0) { | ||
throw new RangeError("InitBucketNum range error"); | ||
} | ||
i.i = i.o = e; | ||
i.h = t; | ||
return i; | ||
} | ||
HashContainer.prototype.clear = function() { | ||
this.t = 0; | ||
this.i = this.o; | ||
this.u = []; | ||
}; | ||
return HashContainer; | ||
}(Base); | ||
function checkObject(t) { | ||
if (t === null) return false; | ||
var e = typeof t; | ||
return e === "object" || e === "function"; | ||
} | ||
var SequentialContainer = function(r) { | ||
__extends(SequentialContainer, r); | ||
function SequentialContainer() { | ||
return r !== null && r.apply(this, arguments) || this; | ||
} | ||
return SequentialContainer; | ||
}(Container); | ||
var RandomIterator = function(r) { | ||
__extends(RandomIterator, r); | ||
function RandomIterator(e, t, i, n, s) { | ||
var a = r.call(this, s) || this; | ||
a.v = e; | ||
a.l = t; | ||
a._ = i; | ||
a.p = n; | ||
if (a.iteratorType === 0) { | ||
a.pre = function() { | ||
if (this.v === 0) { | ||
throw new RangeError("Random iterator access denied!"); | ||
} | ||
this.v -= 1; | ||
return this; | ||
}; | ||
a.next = function() { | ||
if (this.v === this.l()) { | ||
throw new RangeError("Random Iterator access denied!"); | ||
} | ||
this.v += 1; | ||
return this; | ||
}; | ||
} else { | ||
a.pre = function() { | ||
if (this.v === this.l() - 1) { | ||
throw new RangeError("Random iterator access denied!"); | ||
} | ||
this.v += 1; | ||
return this; | ||
}; | ||
a.next = function() { | ||
if (this.v === -1) { | ||
throw new RangeError("Random iterator access denied!"); | ||
} | ||
this.v -= 1; | ||
return this; | ||
}; | ||
} | ||
return a; | ||
} | ||
Object.defineProperty(RandomIterator.prototype, "pointer", { | ||
get: function() { | ||
if (this.v < 0 || this.v > this.l() - 1) { | ||
throw new RangeError; | ||
} | ||
return this._(this.v); | ||
}, | ||
set: function(r) { | ||
if (this.v < 0 || this.v > this.l() - 1) { | ||
throw new RangeError; | ||
} | ||
this.p(this.v, r); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
RandomIterator.prototype.equals = function(r) { | ||
return this.v === r.v; | ||
}; | ||
return RandomIterator; | ||
}(ContainerIterator); | ||
var VectorIterator = function(r) { | ||
__extends(VectorIterator, r); | ||
function VectorIterator() { | ||
return r !== null && r.apply(this, arguments) || this; | ||
} | ||
VectorIterator.prototype.copy = function() { | ||
return new VectorIterator(this.v, this.l, this._, this.p, this.iteratorType); | ||
}; | ||
return VectorIterator; | ||
}(RandomIterator); | ||
var Vector = function(r) { | ||
__extends(Vector, r); | ||
function Vector(e, t) { | ||
if (e === void 0) { | ||
e = []; | ||
} | ||
if (t === void 0) { | ||
t = true; | ||
} | ||
var i = r.call(this) || this; | ||
if (Array.isArray(e)) { | ||
i.I = t ? __spreadArray([], __read(e), false) : e; | ||
i.t = e.length; | ||
} else { | ||
i.I = []; | ||
e.forEach((function(r) { | ||
return i.pushBack(r); | ||
})); | ||
} | ||
i.size = i.size.bind(i); | ||
i.getElementByPos = i.getElementByPos.bind(i); | ||
i.setElementByPos = i.setElementByPos.bind(i); | ||
return i; | ||
} | ||
Vector.prototype.clear = function() { | ||
this.t = 0; | ||
this.I.length = 0; | ||
}; | ||
Vector.prototype.begin = function() { | ||
return new VectorIterator(0, this.size, this.getElementByPos, this.setElementByPos); | ||
}; | ||
Vector.prototype.end = function() { | ||
return new VectorIterator(this.t, this.size, this.getElementByPos, this.setElementByPos); | ||
}; | ||
Vector.prototype.rBegin = function() { | ||
return new VectorIterator(this.t - 1, this.size, this.getElementByPos, this.setElementByPos, 1); | ||
}; | ||
Vector.prototype.rEnd = function() { | ||
return new VectorIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1); | ||
}; | ||
Vector.prototype.front = function() { | ||
return this.I[0]; | ||
}; | ||
Vector.prototype.back = function() { | ||
return this.I[this.t - 1]; | ||
}; | ||
Vector.prototype.forEach = function(r) { | ||
for (var e = 0; e < this.t; ++e) { | ||
r(this.I[e], e, this); | ||
} | ||
}; | ||
Vector.prototype.getElementByPos = function(r) { | ||
if (r < 0 || r > this.t - 1) { | ||
throw new RangeError; | ||
} | ||
return this.I[r]; | ||
}; | ||
Vector.prototype.eraseElementByPos = function(r) { | ||
if (r < 0 || r > this.t - 1) { | ||
throw new RangeError; | ||
} | ||
this.I.splice(r, 1); | ||
this.t -= 1; | ||
}; | ||
Vector.prototype.eraseElementByValue = function(r) { | ||
var e = 0; | ||
for (var t = 0; t < this.t; ++t) { | ||
if (this.I[t] !== r) { | ||
this.I[e++] = this.I[t]; | ||
} | ||
} | ||
this.t = this.I.length = e; | ||
}; | ||
Vector.prototype.eraseElementByIterator = function(r) { | ||
var e = r.v; | ||
r = r.next(); | ||
this.eraseElementByPos(e); | ||
return r; | ||
}; | ||
Vector.prototype.pushBack = function(r) { | ||
this.I.push(r); | ||
this.t += 1; | ||
}; | ||
Vector.prototype.popBack = function() { | ||
if (!this.t) return; | ||
this.I.pop(); | ||
this.t -= 1; | ||
}; | ||
Vector.prototype.setElementByPos = function(r, e) { | ||
if (r < 0 || r > this.t - 1) { | ||
throw new RangeError; | ||
} | ||
this.I[r] = e; | ||
}; | ||
Vector.prototype.insert = function(r, e, t) { | ||
var i; | ||
if (t === void 0) { | ||
t = 1; | ||
} | ||
if (r < 0 || r > this.t) { | ||
throw new RangeError; | ||
} | ||
(i = this.I).splice.apply(i, __spreadArray([ r, 0 ], __read(new Array(t).fill(e)), false)); | ||
this.t += t; | ||
}; | ||
Vector.prototype.find = function(r) { | ||
for (var e = 0; e < this.t; ++e) { | ||
if (this.I[e] === r) { | ||
return new VectorIterator(e, this.size, this.getElementByPos, this.getElementByPos); | ||
} | ||
} | ||
return this.end(); | ||
}; | ||
Vector.prototype.reverse = function() { | ||
this.I.reverse(); | ||
}; | ||
Vector.prototype.unique = function() { | ||
var r = 1; | ||
for (var e = 1; e < this.t; ++e) { | ||
if (this.I[e] !== this.I[e - 1]) { | ||
this.I[r++] = this.I[e]; | ||
} | ||
} | ||
this.t = this.I.length = r; | ||
}; | ||
Vector.prototype.sort = function(r) { | ||
this.I.sort(r); | ||
}; | ||
Vector.prototype[Symbol.iterator] = function() { | ||
return function() { | ||
return __generator(this, (function(r) { | ||
switch (r.label) { | ||
case 0: | ||
return [ 5, __values(this.I) ]; | ||
case 1: | ||
return [ 2, r.sent() ]; | ||
} | ||
})); | ||
}.bind(this)(); | ||
}; | ||
return Vector; | ||
}(SequentialContainer); | ||
var TreeNode = function() { | ||
function TreeNode(r, e) { | ||
this.M = 1; | ||
this.O = undefined; | ||
this.T = undefined; | ||
this.V = undefined; | ||
this.C = undefined; | ||
this.g = undefined; | ||
this.O = r; | ||
this.T = e; | ||
} | ||
TreeNode.prototype.pre = function() { | ||
var r = this; | ||
if (r.M === 1 && r.g.g === r) { | ||
r = r.C; | ||
} else if (r.V) { | ||
r = r.V; | ||
while (r.C) { | ||
r = r.C; | ||
} | ||
} else { | ||
var e = r.g; | ||
while (e.V === r) { | ||
r = e; | ||
e = r.g; | ||
} | ||
r = e; | ||
} | ||
return r; | ||
}; | ||
TreeNode.prototype.next = function() { | ||
var r = this; | ||
if (r.C) { | ||
r = r.C; | ||
while (r.V) { | ||
r = r.V; | ||
} | ||
return r; | ||
} else { | ||
var e = r.g; | ||
while (e.C === r) { | ||
r = e; | ||
e = r.g; | ||
} | ||
if (r.C !== e) { | ||
return e; | ||
} else return r; | ||
} | ||
}; | ||
TreeNode.prototype.rotateLeft = function() { | ||
var r = this.g; | ||
var e = this.C; | ||
var t = e.V; | ||
if (r.g === this) r.g = e; else if (r.V === this) r.V = e; else r.C = e; | ||
e.g = r; | ||
e.V = this; | ||
this.g = e; | ||
this.C = t; | ||
if (t) t.g = this; | ||
var HashContainer = function(t) { | ||
__extends(HashContainer, t); | ||
function HashContainer() { | ||
var e = t.call(this) || this; | ||
e.i = []; | ||
e.u = {}; | ||
e.HASH_KEY_TAG = Symbol("JS_SDSL_HASH_KEY_TAG"); | ||
Object.setPrototypeOf(e.u, null); | ||
return e; | ||
}; | ||
TreeNode.prototype.rotateRight = function() { | ||
var r = this.g; | ||
var e = this.V; | ||
var t = e.C; | ||
if (r.g === this) r.g = e; else if (r.V === this) r.V = e; else r.C = e; | ||
e.g = r; | ||
e.C = this; | ||
this.g = e; | ||
this.V = t; | ||
if (t) t.g = this; | ||
return e; | ||
}; | ||
return TreeNode; | ||
}(); | ||
var TreeNodeEnableIndex = function(r) { | ||
__extends(TreeNodeEnableIndex, r); | ||
function TreeNodeEnableIndex() { | ||
var e = r !== null && r.apply(this, arguments) || this; | ||
e.V = undefined; | ||
e.C = undefined; | ||
e.g = undefined; | ||
e.R = 1; | ||
return e; | ||
} | ||
TreeNodeEnableIndex.prototype.rotateLeft = function() { | ||
var e = r.prototype.rotateLeft.call(this); | ||
this.recount(); | ||
e.recount(); | ||
return e; | ||
}; | ||
TreeNodeEnableIndex.prototype.rotateRight = function() { | ||
var e = r.prototype.rotateRight.call(this); | ||
this.recount(); | ||
e.recount(); | ||
return e; | ||
}; | ||
TreeNodeEnableIndex.prototype.recount = function() { | ||
this.R = 1; | ||
if (this.V) this.R += this.V.R; | ||
if (this.C) this.R += this.C.R; | ||
}; | ||
return TreeNodeEnableIndex; | ||
}(TreeNode); | ||
var TreeContainer = function(r) { | ||
__extends(TreeContainer, r); | ||
function TreeContainer(e, t) { | ||
if (e === void 0) { | ||
e = function(r, e) { | ||
if (r < e) return -1; | ||
if (r > e) return 1; | ||
return 0; | ||
}; | ||
} | ||
if (t === void 0) { | ||
t = false; | ||
} | ||
var i = r.call(this) || this; | ||
i.m = undefined; | ||
i.N = function(r, e) { | ||
if (r === undefined) return false; | ||
var t = i.N(r.V, e); | ||
if (t) return true; | ||
if (e(r)) return true; | ||
return i.N(r.C, e); | ||
}; | ||
i.S = e; | ||
if (t) { | ||
i.H = TreeNodeEnableIndex; | ||
i.j = function(r, e, t) { | ||
var i = this.k(r, e, t); | ||
if (i) { | ||
var n = i.g; | ||
while (n !== this.A) { | ||
n.R += 1; | ||
n = n.g; | ||
} | ||
var s = this.B(i); | ||
if (s) { | ||
var a = s, o = a.parentNode, f = a.grandParent, h = a.curNode; | ||
o.recount(); | ||
f.recount(); | ||
h.recount(); | ||
} | ||
} | ||
}; | ||
i.q = function(r) { | ||
var e = this.P(r); | ||
while (e !== this.A) { | ||
e.R -= 1; | ||
e = e.g; | ||
} | ||
}; | ||
} else { | ||
i.H = TreeNode; | ||
i.j = function(r, e, t) { | ||
var i = this.k(r, e, t); | ||
if (i) this.B(i); | ||
}; | ||
i.q = i.P; | ||
} | ||
i.A = new i.H; | ||
return i; | ||
} | ||
TreeContainer.prototype.G = function(r, e) { | ||
var t; | ||
while (r) { | ||
var i = this.S(r.O, e); | ||
if (i < 0) { | ||
r = r.C; | ||
} else if (i > 0) { | ||
t = r; | ||
r = r.V; | ||
} else return r; | ||
} | ||
return t === undefined ? this.A : t; | ||
}; | ||
TreeContainer.prototype.J = function(r, e) { | ||
var t; | ||
while (r) { | ||
var i = this.S(r.O, e); | ||
if (i <= 0) { | ||
r = r.C; | ||
} else { | ||
t = r; | ||
r = r.V; | ||
} | ||
} | ||
return t === undefined ? this.A : t; | ||
}; | ||
TreeContainer.prototype.D = function(r, e) { | ||
var t; | ||
while (r) { | ||
var i = this.S(r.O, e); | ||
if (i < 0) { | ||
t = r; | ||
r = r.C; | ||
} else if (i > 0) { | ||
r = r.V; | ||
} else return r; | ||
} | ||
return t === undefined ? this.A : t; | ||
}; | ||
TreeContainer.prototype.F = function(r, e) { | ||
var t; | ||
while (r) { | ||
var i = this.S(r.O, e); | ||
if (i < 0) { | ||
t = r; | ||
r = r.C; | ||
} else { | ||
r = r.V; | ||
} | ||
} | ||
return t === undefined ? this.A : t; | ||
}; | ||
TreeContainer.prototype.K = function(r) { | ||
while (true) { | ||
var e = r.g; | ||
if (e === this.A) return; | ||
if (r.M === 1) { | ||
r.M = 0; | ||
HashContainer.prototype.o = function(t, e, n) { | ||
if (n === undefined) n = checkObject(t); | ||
if (n) { | ||
var r = t[this.HASH_KEY_TAG]; | ||
if (r !== undefined) { | ||
this.i[r][1] = e; | ||
return; | ||
} | ||
if (r === e.V) { | ||
var t = e.C; | ||
if (t.M === 1) { | ||
t.M = 0; | ||
e.M = 1; | ||
if (e === this.m) { | ||
this.m = e.rotateLeft(); | ||
} else e.rotateLeft(); | ||
} else { | ||
if (t.C && t.C.M === 1) { | ||
t.M = e.M; | ||
e.M = 0; | ||
t.C.M = 0; | ||
if (e === this.m) { | ||
this.m = e.rotateLeft(); | ||
} else e.rotateLeft(); | ||
return; | ||
} else if (t.V && t.V.M === 1) { | ||
t.M = 1; | ||
t.V.M = 0; | ||
t.rotateRight(); | ||
} else { | ||
t.M = 1; | ||
r = e; | ||
} | ||
} | ||
} else { | ||
var t = e.V; | ||
if (t.M === 1) { | ||
t.M = 0; | ||
e.M = 1; | ||
if (e === this.m) { | ||
this.m = e.rotateRight(); | ||
} else e.rotateRight(); | ||
} else { | ||
if (t.V && t.V.M === 1) { | ||
t.M = e.M; | ||
e.M = 0; | ||
t.V.M = 0; | ||
if (e === this.m) { | ||
this.m = e.rotateRight(); | ||
} else e.rotateRight(); | ||
return; | ||
} else if (t.C && t.C.M === 1) { | ||
t.M = 1; | ||
t.C.M = 0; | ||
t.rotateLeft(); | ||
} else { | ||
t.M = 1; | ||
r = e; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
TreeContainer.prototype.P = function(r) { | ||
var e, t; | ||
if (this.t === 1) { | ||
this.clear(); | ||
return this.A; | ||
} | ||
var i = r; | ||
while (i.V || i.C) { | ||
if (i.C) { | ||
i = i.C; | ||
while (i.V) i = i.V; | ||
} else { | ||
i = i.V; | ||
} | ||
e = __read([ i.O, r.O ], 2), r.O = e[0], i.O = e[1]; | ||
t = __read([ i.T, r.T ], 2), r.T = t[0], i.T = t[1]; | ||
r = i; | ||
} | ||
if (this.A.V === i) { | ||
this.A.V = i.g; | ||
} else if (this.A.C === i) { | ||
this.A.C = i.g; | ||
} | ||
this.K(i); | ||
var n = i.g; | ||
if (i === n.V) { | ||
n.V = undefined; | ||
} else n.C = undefined; | ||
this.t -= 1; | ||
this.m.M = 0; | ||
return n; | ||
}; | ||
TreeContainer.prototype.B = function(r) { | ||
while (true) { | ||
var e = r.g; | ||
if (e.M === 0) return; | ||
var t = e.g; | ||
if (e === t.V) { | ||
var i = t.C; | ||
if (i && i.M === 1) { | ||
i.M = e.M = 0; | ||
if (t === this.m) return; | ||
t.M = 1; | ||
r = t; | ||
continue; | ||
} else if (r === e.C) { | ||
r.M = 0; | ||
if (r.V) r.V.g = e; | ||
if (r.C) r.C.g = t; | ||
e.C = r.V; | ||
t.V = r.C; | ||
r.V = e; | ||
r.C = t; | ||
if (t === this.m) { | ||
this.m = r; | ||
this.A.g = r; | ||
} else { | ||
var n = t.g; | ||
if (n.V === t) { | ||
n.V = r; | ||
} else n.C = r; | ||
} | ||
r.g = t.g; | ||
e.g = r; | ||
t.g = r; | ||
t.M = 1; | ||
return { | ||
parentNode: e, | ||
grandParent: t, | ||
curNode: r | ||
}; | ||
} else { | ||
e.M = 0; | ||
if (t === this.m) { | ||
this.m = t.rotateRight(); | ||
} else t.rotateRight(); | ||
t.M = 1; | ||
} | ||
} else { | ||
var i = t.V; | ||
if (i && i.M === 1) { | ||
i.M = e.M = 0; | ||
if (t === this.m) return; | ||
t.M = 1; | ||
r = t; | ||
continue; | ||
} else if (r === e.V) { | ||
r.M = 0; | ||
if (r.V) r.V.g = t; | ||
if (r.C) r.C.g = e; | ||
t.C = r.V; | ||
e.V = r.C; | ||
r.V = t; | ||
r.C = e; | ||
if (t === this.m) { | ||
this.m = r; | ||
this.A.g = r; | ||
} else { | ||
var n = t.g; | ||
if (n.V === t) { | ||
n.V = r; | ||
} else n.C = r; | ||
} | ||
r.g = t.g; | ||
e.g = r; | ||
t.g = r; | ||
t.M = 1; | ||
return { | ||
parentNode: e, | ||
grandParent: t, | ||
curNode: r | ||
}; | ||
} else { | ||
e.M = 0; | ||
if (t === this.m) { | ||
this.m = t.rotateLeft(); | ||
} else t.rotateLeft(); | ||
t.M = 1; | ||
} | ||
} | ||
return; | ||
} | ||
}; | ||
TreeContainer.prototype.k = function(r, e, t) { | ||
if (this.m === undefined) { | ||
this.t += 1; | ||
this.m = new this.H(r, e); | ||
this.m.M = 0; | ||
this.m.g = this.A; | ||
this.A.g = this.m; | ||
this.A.V = this.m; | ||
this.A.C = this.m; | ||
return; | ||
} | ||
var i; | ||
var n = this.A.V; | ||
var s = this.S(n.O, r); | ||
if (s === 0) { | ||
n.T = e; | ||
return; | ||
} else if (s > 0) { | ||
n.V = new this.H(r, e); | ||
n.V.g = n; | ||
i = n.V; | ||
this.A.V = i; | ||
Object.defineProperty(t, this.HASH_KEY_TAG, { | ||
value: this.i.length, | ||
configurable: true | ||
}); | ||
this.i.push([ t, e ]); | ||
} else { | ||
var a = this.A.C; | ||
var o = this.S(a.O, r); | ||
if (o === 0) { | ||
a.T = e; | ||
var i = this.u[t]; | ||
if (i) { | ||
i[1] = e; | ||
return; | ||
} else if (o < 0) { | ||
a.C = new this.H(r, e); | ||
a.C.g = a; | ||
i = a.C; | ||
this.A.C = i; | ||
} else { | ||
if (t !== undefined) { | ||
var f = t.v; | ||
if (f !== this.A) { | ||
var h = this.S(f.O, r); | ||
if (h === 0) { | ||
f.T = e; | ||
return; | ||
} else if (h > 0) { | ||
var u = f.pre(); | ||
var c = this.S(u.O, r); | ||
if (c === 0) { | ||
u.T = e; | ||
return; | ||
} else if (c < 0) { | ||
i = new this.H(r, e); | ||
if (u.C === undefined) { | ||
u.C = i; | ||
i.g = u; | ||
} else { | ||
f.V = i; | ||
i.g = f; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (i === undefined) { | ||
i = this.m; | ||
while (true) { | ||
var d = this.S(i.O, r); | ||
if (d > 0) { | ||
if (i.V === undefined) { | ||
i.V = new this.H(r, e); | ||
i.V.g = i; | ||
i = i.V; | ||
break; | ||
} | ||
i = i.V; | ||
} else if (d < 0) { | ||
if (i.C === undefined) { | ||
i.C = new this.H(r, e); | ||
i.C.g = i; | ||
i = i.C; | ||
break; | ||
} | ||
i = i.C; | ||
} else { | ||
i.T = e; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
this.u[t] = [ t, e ]; | ||
} | ||
this.t += 1; | ||
return i; | ||
}; | ||
TreeContainer.prototype.clear = function() { | ||
HashContainer.prototype.clear = function() { | ||
var t = this; | ||
this.i.forEach((function(e) { | ||
delete e[0][t.HASH_KEY_TAG]; | ||
})); | ||
this.i = []; | ||
this.u = {}; | ||
Object.setPrototypeOf(this.u, null); | ||
this.t = 0; | ||
this.m = undefined; | ||
this.A.g = undefined; | ||
this.A.V = this.A.C = undefined; | ||
}; | ||
TreeContainer.prototype.updateKeyByIterator = function(r, e) { | ||
var t = r.v; | ||
if (t === this.A) { | ||
throw new TypeError("Invalid iterator!"); | ||
HashContainer.prototype.eraseElementByKey = function(t, e) { | ||
if (e === undefined) e = checkObject(t); | ||
if (e) { | ||
var n = t[this.HASH_KEY_TAG]; | ||
if (n === undefined) return; | ||
delete t[this.HASH_KEY_TAG]; | ||
delete this.i[n]; | ||
} else { | ||
if (this.u[t] === undefined) return; | ||
delete this.u[t]; | ||
} | ||
if (this.t === 1) { | ||
t.O = e; | ||
return true; | ||
} | ||
if (t === this.A.V) { | ||
if (this.S(t.next().O, e) > 0) { | ||
t.O = e; | ||
return true; | ||
} | ||
return false; | ||
} | ||
if (t === this.A.C) { | ||
if (this.S(t.pre().O, e) < 0) { | ||
t.O = e; | ||
return true; | ||
} | ||
return false; | ||
} | ||
var i = t.pre().O; | ||
if (this.S(i, e) >= 0) return false; | ||
var n = t.next().O; | ||
if (this.S(n, e) <= 0) return false; | ||
t.O = e; | ||
return true; | ||
this.t -= 1; | ||
}; | ||
TreeContainer.prototype.eraseElementByPos = function(r) { | ||
var e = this; | ||
if (r < 0 || r > this.t - 1) { | ||
throw new RangeError; | ||
} | ||
var t = 0; | ||
this.N(this.m, (function(i) { | ||
if (r === t) { | ||
e.q(i); | ||
return true; | ||
} | ||
t += 1; | ||
return false; | ||
})); | ||
}; | ||
TreeContainer.prototype.L = function(r, e) { | ||
while (r) { | ||
var t = this.S(r.O, e); | ||
if (t < 0) { | ||
r = r.C; | ||
} else if (t > 0) { | ||
r = r.V; | ||
} else return r; | ||
} | ||
return r; | ||
}; | ||
TreeContainer.prototype.eraseElementByKey = function(r) { | ||
if (!this.t) return; | ||
var e = this.L(this.m, r); | ||
if (e === undefined) return; | ||
this.q(e); | ||
}; | ||
TreeContainer.prototype.eraseElementByIterator = function(r) { | ||
var e = r.v; | ||
if (e === this.A) { | ||
throw new RangeError("Invalid iterator"); | ||
} | ||
if (e.C === undefined) { | ||
r = r.next(); | ||
} | ||
this.q(e); | ||
return r; | ||
}; | ||
TreeContainer.prototype.getHeight = function() { | ||
if (!this.t) return 0; | ||
var traversal = function(r) { | ||
if (!r) return 0; | ||
return Math.max(traversal(r.V), traversal(r.C)) + 1; | ||
}; | ||
return traversal(this.m); | ||
}; | ||
return TreeContainer; | ||
}(Container); | ||
var TreeIterator = function(r) { | ||
__extends(TreeIterator, r); | ||
function TreeIterator(e, t, i) { | ||
var n = r.call(this, i) || this; | ||
n.v = e; | ||
n.A = t; | ||
if (n.iteratorType === 0) { | ||
n.pre = function() { | ||
if (this.v === this.A.V) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
} | ||
this.v = this.v.pre(); | ||
return this; | ||
}; | ||
n.next = function() { | ||
if (this.v === this.A) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
} | ||
this.v = this.v.next(); | ||
return this; | ||
}; | ||
HashContainer.prototype.find = function(t, e) { | ||
if (e === undefined) e = checkObject(t); | ||
if (e) { | ||
return typeof t[this.HASH_KEY_TAG] === "number"; | ||
} else { | ||
n.pre = function() { | ||
if (this.v === this.A.C) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
} | ||
this.v = this.v.next(); | ||
return this; | ||
}; | ||
n.next = function() { | ||
if (this.v === this.A) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
} | ||
this.v = this.v.pre(); | ||
return this; | ||
}; | ||
return this.u[t] !== undefined; | ||
} | ||
return n; | ||
} | ||
Object.defineProperty(TreeIterator.prototype, "index", { | ||
get: function() { | ||
var r = this.v; | ||
var e = this.A.g; | ||
if (r === this.A) { | ||
if (e) { | ||
return e.R - 1; | ||
} | ||
return 0; | ||
} | ||
var t = 0; | ||
if (r.V) { | ||
t += r.V.R; | ||
} | ||
while (r !== e) { | ||
var i = r.g; | ||
if (r === i.C) { | ||
t += 1; | ||
if (i.V) { | ||
t += i.V.R; | ||
} | ||
} | ||
r = i; | ||
} | ||
return t; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
TreeIterator.prototype.equals = function(r) { | ||
return this.v === r.v; | ||
}; | ||
return TreeIterator; | ||
}(ContainerIterator); | ||
return HashContainer; | ||
}(Base); | ||
var OrderedMapIterator = function(r) { | ||
__extends(OrderedMapIterator, r); | ||
function OrderedMapIterator() { | ||
return r !== null && r.apply(this, arguments) || this; | ||
} | ||
Object.defineProperty(OrderedMapIterator.prototype, "pointer", { | ||
get: function() { | ||
var r = this; | ||
if (this.v === this.A) { | ||
throw new RangeError("OrderedMap iterator access denied"); | ||
} | ||
return new Proxy([], { | ||
get: function(e, t) { | ||
if (t === "0") return r.v.O; else if (t === "1") return r.v.T; | ||
}, | ||
set: function(e, t, i) { | ||
if (t !== "1") { | ||
throw new TypeError("props must be 1"); | ||
} | ||
r.v.T = i; | ||
return true; | ||
} | ||
}); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
OrderedMapIterator.prototype.copy = function() { | ||
return new OrderedMapIterator(this.v, this.A, this.iteratorType); | ||
}; | ||
return OrderedMapIterator; | ||
}(TreeIterator); | ||
var OrderedMap = function(r) { | ||
__extends(OrderedMap, r); | ||
function OrderedMap(e, t, i) { | ||
var HashMap = function(t) { | ||
__extends(HashMap, t); | ||
function HashMap(e) { | ||
if (e === void 0) { | ||
e = []; | ||
} | ||
var n = r.call(this, t, i) || this; | ||
n.U = function(r) { | ||
return __generator(this, (function(e) { | ||
switch (e.label) { | ||
case 0: | ||
if (r === undefined) return [ 2 ]; | ||
return [ 5, __values(this.U(r.V)) ]; | ||
case 1: | ||
e.sent(); | ||
return [ 4, [ r.O, r.T ] ]; | ||
case 2: | ||
e.sent(); | ||
return [ 5, __values(this.U(r.C)) ]; | ||
case 3: | ||
e.sent(); | ||
return [ 2 ]; | ||
} | ||
})); | ||
}; | ||
e.forEach((function(r) { | ||
var e = __read(r, 2), t = e[0], i = e[1]; | ||
return n.setElement(t, i); | ||
var n = t.call(this) || this; | ||
var r = n; | ||
e.forEach((function(t) { | ||
r.setElement(t[0], t[1]); | ||
})); | ||
return n; | ||
} | ||
OrderedMap.prototype.begin = function() { | ||
return new OrderedMapIterator(this.A.V || this.A, this.A); | ||
HashMap.prototype.setElement = function(t, e, n) { | ||
this.o(t, e, n); | ||
}; | ||
OrderedMap.prototype.end = function() { | ||
return new OrderedMapIterator(this.A, this.A); | ||
}; | ||
OrderedMap.prototype.rBegin = function() { | ||
return new OrderedMapIterator(this.A.C || this.A, this.A, 1); | ||
}; | ||
OrderedMap.prototype.rEnd = function() { | ||
return new OrderedMapIterator(this.A, this.A, 1); | ||
}; | ||
OrderedMap.prototype.front = function() { | ||
if (!this.t) return undefined; | ||
var r = this.A.V; | ||
return [ r.O, r.T ]; | ||
}; | ||
OrderedMap.prototype.back = function() { | ||
if (!this.t) return undefined; | ||
var r = this.A.C; | ||
return [ r.O, r.T ]; | ||
}; | ||
OrderedMap.prototype.forEach = function(r) { | ||
var e, t; | ||
var i = 0; | ||
try { | ||
for (var n = __values(this), s = n.next(); !s.done; s = n.next()) { | ||
var a = s.value; | ||
r(a, i++, this); | ||
} | ||
} catch (r) { | ||
e = { | ||
error: r | ||
}; | ||
} finally { | ||
try { | ||
if (s && !s.done && (t = n.return)) t.call(n); | ||
} finally { | ||
if (e) throw e.error; | ||
} | ||
HashMap.prototype.getElementByKey = function(t, e) { | ||
if (e === undefined) e = checkObject(t); | ||
if (e) { | ||
var n = t[this.HASH_KEY_TAG]; | ||
return n !== undefined ? this.i[n][1] : undefined; | ||
} | ||
var r = this.u[t]; | ||
return r ? r[1] : undefined; | ||
}; | ||
OrderedMap.prototype.lowerBound = function(r) { | ||
var e = this.G(this.m, r); | ||
return new OrderedMapIterator(e, this.A); | ||
}; | ||
OrderedMap.prototype.upperBound = function(r) { | ||
var e = this.J(this.m, r); | ||
return new OrderedMapIterator(e, this.A); | ||
}; | ||
OrderedMap.prototype.reverseLowerBound = function(r) { | ||
var e = this.D(this.m, r); | ||
return new OrderedMapIterator(e, this.A); | ||
}; | ||
OrderedMap.prototype.reverseUpperBound = function(r) { | ||
var e = this.F(this.m, r); | ||
return new OrderedMapIterator(e, this.A); | ||
}; | ||
OrderedMap.prototype.setElement = function(r, e, t) { | ||
this.j(r, e, t); | ||
}; | ||
OrderedMap.prototype.find = function(r) { | ||
var e = this.L(this.m, r); | ||
if (e !== undefined) { | ||
return new OrderedMapIterator(e, this.A); | ||
HashMap.prototype.forEach = function(t) { | ||
var e = this.i.length; | ||
for (var n = 0; n < e; ++n) { | ||
t(this.i[n], n, this); | ||
} | ||
return this.end(); | ||
}; | ||
OrderedMap.prototype.getElementByKey = function(r) { | ||
var e = this.L(this.m, r); | ||
return e ? e.T : undefined; | ||
}; | ||
OrderedMap.prototype.getElementByPos = function(r) { | ||
var e, t; | ||
if (r < 0 || r > this.t - 1) { | ||
throw new RangeError; | ||
var r = Object.keys(this.u); | ||
var i = r.length; | ||
var s = e; | ||
for (var n = 0; n < i; ++n) { | ||
t(this.u[r[n]], s++, this); | ||
} | ||
var i; | ||
var n = 0; | ||
try { | ||
for (var s = __values(this), a = s.next(); !a.done; a = s.next()) { | ||
var o = a.value; | ||
if (n === r) { | ||
i = o; | ||
break; | ||
} | ||
n += 1; | ||
} | ||
} catch (r) { | ||
e = { | ||
error: r | ||
}; | ||
} finally { | ||
try { | ||
if (a && !a.done && (t = s.return)) t.call(s); | ||
} finally { | ||
if (e) throw e.error; | ||
} | ||
var a = Object.getOwnPropertySymbols(this.u); | ||
var u = a.length; | ||
for (var n = 0; n < u; ++n) { | ||
t(this.u[a[n]], s++, this); | ||
} | ||
return i; | ||
}; | ||
OrderedMap.prototype.union = function(r) { | ||
var e = this; | ||
r.forEach((function(r) { | ||
var t = __read(r, 2), i = t[0], n = t[1]; | ||
return e.setElement(i, n); | ||
})); | ||
}; | ||
OrderedMap.prototype[Symbol.iterator] = function() { | ||
return this.U(this.m); | ||
}; | ||
return OrderedMap; | ||
}(TreeContainer); | ||
var HashMap = function(r) { | ||
__extends(HashMap, r); | ||
function HashMap(e, t, i) { | ||
if (e === void 0) { | ||
e = []; | ||
} | ||
var n = r.call(this, t, i) || this; | ||
n.u = []; | ||
e.forEach((function(r) { | ||
return n.setElement(r[0], r[1]); | ||
})); | ||
return n; | ||
} | ||
HashMap.prototype.W = function() { | ||
var r = this; | ||
if (this.i >= 1073741824) return; | ||
var e = []; | ||
var t = this.i; | ||
this.i <<= 1; | ||
var i = Object.keys(this.u); | ||
var n = i.length; | ||
var _loop_1 = function(n) { | ||
var a = parseInt(i[n]); | ||
var o = s.u[a]; | ||
var f = o.size(); | ||
if (f === 0) return "continue"; | ||
if (f === 1) { | ||
var h = o.front(); | ||
e[s.h(h[0]) & s.i - 1] = new Vector([ h ], false); | ||
return "continue"; | ||
} | ||
var u = []; | ||
var c = []; | ||
o.forEach((function(e) { | ||
var i = r.h(e[0]); | ||
if ((i & t) === 0) { | ||
u.push(e); | ||
} else c.push(e); | ||
})); | ||
if (o instanceof OrderedMap) { | ||
if (u.length > 6) { | ||
e[a] = new OrderedMap(u); | ||
} else { | ||
e[a] = new Vector(u, false); | ||
} | ||
if (c.length > 6) { | ||
e[a + t] = new OrderedMap(c); | ||
} else { | ||
e[a + t] = new Vector(c, false); | ||
} | ||
} else { | ||
e[a] = new Vector(u, false); | ||
e[a + t] = new Vector(c, false); | ||
} | ||
}; | ||
var s = this; | ||
for (var a = 0; a < n; ++a) { | ||
_loop_1(a); | ||
} | ||
this.u = e; | ||
}; | ||
HashMap.prototype.forEach = function(r) { | ||
var e = this; | ||
var t = Object.values(this.u); | ||
var i = t.length; | ||
var n = 0; | ||
for (var s = 0; s < i; ++s) { | ||
t[s].forEach((function(t) { | ||
return r(t, n++, e); | ||
})); | ||
} | ||
}; | ||
HashMap.prototype.setElement = function(r, e) { | ||
var t, i; | ||
var n = this.h(r) & this.i - 1; | ||
var s = this.u[n]; | ||
if (!s) { | ||
this.t += 1; | ||
this.u[n] = new Vector([ [ r, e ] ], false); | ||
} else { | ||
var a = s.size(); | ||
if (s instanceof Vector) { | ||
try { | ||
for (var o = __values(s), f = o.next(); !f.done; f = o.next()) { | ||
var h = f.value; | ||
if (h[0] === r) { | ||
h[1] = e; | ||
return; | ||
} | ||
} | ||
} catch (r) { | ||
t = { | ||
error: r | ||
}; | ||
} finally { | ||
try { | ||
if (f && !f.done && (i = o.return)) i.call(o); | ||
} finally { | ||
if (t) throw t.error; | ||
} | ||
} | ||
s.pushBack([ r, e ]); | ||
if (a + 1 >= 8) { | ||
if (this.i <= 64) { | ||
this.t += 1; | ||
this.W(); | ||
return; | ||
} | ||
this.u[n] = new OrderedMap(this.u[n]); | ||
} | ||
this.t += 1; | ||
} else { | ||
s.setElement(r, e); | ||
var u = s.size(); | ||
this.t += u - a; | ||
} | ||
} | ||
if (this.t > this.i * .75) { | ||
this.W(); | ||
} | ||
}; | ||
HashMap.prototype.getElementByKey = function(r) { | ||
var e, t; | ||
var i = this.h(r) & this.i - 1; | ||
var n = this.u[i]; | ||
if (!n) return undefined; | ||
if (n instanceof OrderedMap) { | ||
return n.getElementByKey(r); | ||
} else { | ||
try { | ||
for (var s = __values(n), a = s.next(); !a.done; a = s.next()) { | ||
var o = a.value; | ||
if (o[0] === r) return o[1]; | ||
} | ||
} catch (r) { | ||
e = { | ||
error: r | ||
}; | ||
} finally { | ||
try { | ||
if (a && !a.done && (t = s.return)) t.call(s); | ||
} finally { | ||
if (e) throw e.error; | ||
} | ||
} | ||
return undefined; | ||
} | ||
}; | ||
HashMap.prototype.eraseElementByKey = function(r) { | ||
var e, t; | ||
var i = this.h(r) & this.i - 1; | ||
var n = this.u[i]; | ||
if (!n) return; | ||
if (n instanceof Vector) { | ||
var s = 0; | ||
try { | ||
for (var a = __values(n), o = a.next(); !o.done; o = a.next()) { | ||
var f = o.value; | ||
if (f[0] === r) { | ||
n.eraseElementByPos(s); | ||
this.t -= 1; | ||
return; | ||
} | ||
s += 1; | ||
} | ||
} catch (r) { | ||
e = { | ||
error: r | ||
}; | ||
} finally { | ||
try { | ||
if (o && !o.done && (t = a.return)) t.call(a); | ||
} finally { | ||
if (e) throw e.error; | ||
} | ||
} | ||
} else { | ||
var h = n.size(); | ||
n.eraseElementByKey(r); | ||
var u = n.size(); | ||
this.t += u - h; | ||
if (u <= 6) { | ||
this.u[i] = new Vector(n); | ||
} | ||
} | ||
}; | ||
HashMap.prototype.find = function(r) { | ||
var e, t; | ||
var i = this.h(r) & this.i - 1; | ||
var n = this.u[i]; | ||
if (!n) return false; | ||
if (n instanceof OrderedMap) { | ||
return !n.find(r).equals(n.end()); | ||
} | ||
try { | ||
for (var s = __values(n), a = s.next(); !a.done; a = s.next()) { | ||
var o = a.value; | ||
if (o[0] === r) return true; | ||
} | ||
} catch (r) { | ||
e = { | ||
error: r | ||
}; | ||
} finally { | ||
try { | ||
if (a && !a.done && (t = s.return)) t.call(s); | ||
} finally { | ||
if (e) throw e.error; | ||
} | ||
} | ||
return false; | ||
}; | ||
HashMap.prototype[Symbol.iterator] = function() { | ||
return function() { | ||
var r, e, t, i, n, s, a, o; | ||
var f, h; | ||
return __generator(this, (function(u) { | ||
switch (u.label) { | ||
var t, e, n, r, i, n; | ||
return __generator(this, (function(s) { | ||
switch (s.label) { | ||
case 0: | ||
r = Object.values(this.u); | ||
e = r.length; | ||
t = 0; | ||
u.label = 1; | ||
return [ 5, __values(this.i) ]; | ||
case 1: | ||
if (!(t < e)) return [ 3, 10 ]; | ||
i = r[t]; | ||
u.label = 2; | ||
s.sent(); | ||
t = Object.keys(this.u); | ||
e = t.length; | ||
n = 0; | ||
s.label = 2; | ||
case 2: | ||
u.trys.push([ 2, 7, 8, 9 ]); | ||
n = (f = void 0, __values(i)), s = n.next(); | ||
u.label = 3; | ||
if (!(n < e)) return [ 3, 5 ]; | ||
return [ 4, this.u[t[n]] ]; | ||
case 3: | ||
if (!!s.done) return [ 3, 6 ]; | ||
a = s.value; | ||
return [ 4, a ]; | ||
s.sent(); | ||
s.label = 4; | ||
case 4: | ||
u.sent(); | ||
u.label = 5; | ||
++n; | ||
return [ 3, 2 ]; | ||
case 5: | ||
s = n.next(); | ||
return [ 3, 3 ]; | ||
r = Object.getOwnPropertySymbols(this.u); | ||
i = r.length; | ||
n = 0; | ||
s.label = 6; | ||
case 6: | ||
return [ 3, 9 ]; | ||
if (!(n < i)) return [ 3, 9 ]; | ||
return [ 4, this.u[r[n]] ]; | ||
case 7: | ||
o = u.sent(); | ||
f = { | ||
error: o | ||
}; | ||
return [ 3, 9 ]; | ||
s.sent(); | ||
s.label = 8; | ||
case 8: | ||
try { | ||
if (s && !s.done && (h = n.return)) h.call(n); | ||
} finally { | ||
if (f) throw f.error; | ||
} | ||
return [ 7 ]; | ||
++n; | ||
return [ 3, 6 ]; | ||
case 9: | ||
++t; | ||
return [ 3, 1 ]; | ||
case 10: | ||
return [ 2 ]; | ||
@@ -1568,0 +315,0 @@ } |
/*! | ||
* @js-sdsl/hash-map v4.2.0-beta.0 | ||
* @js-sdsl/hash-map v4.2.0-beta.1 | ||
* https://github.com/js-sdsl/js-sdsl | ||
@@ -7,3 +7,3 @@ * (c) 2021-present ZLY201 <zilongyao1366@gmail.com> | ||
*/ | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var i=function(t,r){return(i=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,r){t.__proto__=r}:function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}))(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=t}i(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}function f(i,n){var o,s,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},t={next:r(0),throw:r(1),return:r(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function r(e){return function(t){var r=[e,t];if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,s&&(h=2&r[0]?s.return:r[0]?s.throw||((h=s.return)&&h.call(s),0):s.next)&&!(h=h.call(s,r[1])).done)return h;switch(s=0,(r=h?[2&r[0],h.value]:r)[0]){case 0:case 1:h=r;break;case 4:return u.label++,{value:r[1],done:!1};case 5:u.label++,s=r[1],r=[0];continue;case 7:r=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===r[0]||2===r[0])){u=0;continue}if(3===r[0]&&(!h||r[1]>h[0]&&r[1]<h[3]))u.label=r[1];else if(6===r[0]&&u.label<h[1])u.label=h[1],h=r;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(r)}}r=n.call(i,u)}catch(t){r=[6,t],s=0}finally{o=h=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}}}function c(t){var r="function"==typeof Symbol&&Symbol.iterator,e=r&&t[r],i=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&i>=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function n(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var i,n,o=e.call(t),s=[];try{for(;(void 0===r||0<r--)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(e=o.return)&&e.call(o)}finally{if(n)throw n.error}}return s}function o(t,r,e){if(e||2===arguments.length)for(var i,n=0,o=r.length;n<o;n++)!i&&n in r||((i=i||Array.prototype.slice.call(r,0,n))[n]=r[n]);return t.concat(i||Array.prototype.slice.call(r))}function e(t){this.iteratorType=t=void 0===t?0:t}h.prototype.size=function(){return this.t},h.prototype.empty=function(){return 0===this.t};var s=h;function h(){this.t=0}r(l,u=s);var u,a=l;function l(){return null!==u&&u.apply(this,arguments)||this}r(v,p=s),v.prototype.clear=function(){this.t=0,this.i=this.u,this.o=[]};var p,s=v;function v(t,r){void 0===t&&(t=16),void 0===r&&(r=function(t){for(var r="string"!=typeof t?JSON.stringify(t):t,e=0,i=r.length,n=0;n<i;n++){e=(e<<5)-e+r.charCodeAt(n);e|=0}return e>>>0});var e=p.call(this)||this;if(t<16||0!=(t&t-1))throw new RangeError("InitBucketNum range error");return e.i=e.u=t,e.h=r,e}r(w,y=a);var y,d=w;function w(){return null!==y&&y.apply(this,arguments)||this}r(g,m=e),Object.defineProperty(g.prototype,"pointer",{get:function(){if(this.v<0||this.v>this.l()-1)throw new RangeError;return this._(this.v)},set:function(t){if(this.v<0||this.v>this.l()-1)throw new RangeError;this.p(this.v,t)},enumerable:!1,configurable:!0}),g.prototype.equals=function(t){return this.v===t.v};var m,L=g;function g(t,r,e,i,n){n=m.call(this,n)||this;return n.v=t,n.l=r,n._=e,n.p=i,0===n.iteratorType?(n.pre=function(){if(0===this.v)throw new RangeError("Random iterator access denied!");return--this.v,this},n.next=function(){if(this.v===this.l())throw new RangeError("Random Iterator access denied!");return this.v+=1,this}):(n.pre=function(){if(this.v===this.l()-1)throw new RangeError("Random iterator access denied!");return this.v+=1,this},n.next=function(){if(-1===this.v)throw new RangeError("Random iterator access denied!");return--this.v,this}),n}r(E,I=L),E.prototype.copy=function(){return new E(this.v,this.l,this._,this.p,this.iteratorType)};var I,C=E;function E(){return null!==I&&I.apply(this,arguments)||this}r(b,z=d),b.prototype.clear=function(){this.t=0,this.T.length=0},b.prototype.begin=function(){return new C(0,this.size,this.getElementByPos,this.setElementByPos)},b.prototype.end=function(){return new C(this.t,this.size,this.getElementByPos,this.setElementByPos)},b.prototype.rBegin=function(){return new C(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},b.prototype.rEnd=function(){return new C(-1,this.size,this.getElementByPos,this.setElementByPos,1)},b.prototype.front=function(){return this.T[0]},b.prototype.back=function(){return this.T[this.t-1]},b.prototype.forEach=function(t){for(var r=0;r<this.t;++r)t(this.T[r],r,this)},b.prototype.getElementByPos=function(t){if(t<0||t>this.t-1)throw new RangeError;return this.T[t]},b.prototype.eraseElementByPos=function(t){if(t<0||t>this.t-1)throw new RangeError;this.T.splice(t,1),--this.t},b.prototype.eraseElementByValue=function(t){for(var r=0,e=0;e<this.t;++e)this.T[e]!==t&&(this.T[r++]=this.T[e]);this.t=this.T.length=r},b.prototype.eraseElementByIterator=function(t){var r=t.v;return t=t.next(),this.eraseElementByPos(r),t},b.prototype.pushBack=function(t){this.T.push(t),this.t+=1},b.prototype.popBack=function(){this.t&&(this.T.pop(),--this.t)},b.prototype.setElementByPos=function(t,r){if(t<0||t>this.t-1)throw new RangeError;this.T[t]=r},b.prototype.insert=function(t,r,e){var i;if(void 0===e&&(e=1),t<0||t>this.t)throw new RangeError;(i=this.T).splice.apply(i,o([t,0],n(new Array(e).fill(r)),!1)),this.t+=e},b.prototype.find=function(t){for(var r=0;r<this.t;++r)if(this.T[r]===t)return new C(r,this.size,this.getElementByPos,this.getElementByPos);return this.end()},b.prototype.reverse=function(){this.T.reverse()},b.prototype.unique=function(){for(var t=1,r=1;r<this.t;++r)this.T[r]!==this.T[r-1]&&(this.T[t++]=this.T[r]);this.t=this.T.length=t},b.prototype.sort=function(t){this.T.sort(t)},b.prototype[Symbol.iterator]=function(){return function(){return f(this,function(t){switch(t.label){case 0:return[5,c(this.T)];case 1:return[2,t.sent()]}})}.bind(this)()};var z,A=b;function b(t,r){void 0===t&&(t=[]),void 0===r&&(r=!0);var e=z.call(this)||this;return Array.isArray(t)?(e.T=r?o([],n(t),!1):t,e.t=t.length):(e.T=[],t.forEach(function(t){return e.pushBack(t)})),e.size=e.size.bind(e),e.getElementByPos=e.getElementByPos.bind(e),e.setElementByPos=e.setElementByPos.bind(e),e}V.prototype.pre=function(){var t=this;if(1===t.M&&t.V.V===t)t=t.C;else if(t.I)for(t=t.I;t.C;)t=t.C;else{for(var r=t.V;r.I===t;)r=(t=r).V;t=r}return t},V.prototype.next=function(){var t=this;if(t.C){for(t=t.C;t.I;)t=t.I;return t}for(var r=t.V;r.C===t;)r=(t=r).V;return t.C!==r?r:t},V.prototype.rotateLeft=function(){var t=this.V,r=this.C,e=r.I;return t.V===this?t.V=r:t.I===this?t.I=r:t.C=r,r.V=t,(r.I=this).V=r,(this.C=e)&&(e.V=this),r},V.prototype.rotateRight=function(){var t=this.V,r=this.I,e=r.C;return t.V===this?t.V=r:t.I===this?t.I=r:t.C=r,r.V=t,(r.C=this).V=r,(this.I=e)&&(e.V=this),r};var N=V;function V(t,r){this.M=1,this.O=void 0,this.g=void 0,this.I=void 0,this.C=void 0,this.V=void 0,this.O=t,this.g=r}r(B,M=N),B.prototype.rotateLeft=function(){var t=M.prototype.rotateLeft.call(this);return this.recount(),t.recount(),t},B.prototype.rotateRight=function(){var t=M.prototype.rotateRight.call(this);return this.recount(),t.recount(),t},B.prototype.recount=function(){this.R=1,this.I&&(this.R+=this.I.R),this.C&&(this.R+=this.C.R)};var M,H=B;function B(){var t=null!==M&&M.apply(this,arguments)||this;return t.I=void 0,t.C=void 0,t.V=void 0,t.R=1,t}r(R,_=a),R.prototype.G=function(t,r){for(var e;t;){var i=this.S(t.O,r);if(i<0)t=t.C;else{if(!(0<i))return t;t=(e=t).I}}return void 0===e?this.A:e},R.prototype.J=function(t,r){for(var e;t;)t=this.S(t.O,r)<=0?t.C:(e=t).I;return void 0===e?this.A:e},R.prototype.D=function(t,r){for(var e;t;){var i=this.S(t.O,r);if(i<0)t=(e=t).C;else{if(!(0<i))return t;t=t.I}}return void 0===e?this.A:e},R.prototype.F=function(t,r){for(var e;t;)t=this.S(t.O,r)<0?(e=t).C:t.I;return void 0===e?this.A:e},R.prototype.K=function(t){for(;;){var r,e=t.V;if(e===this.A)return;if(1===t.M)return void(t.M=0);if(t===e.I)if(1===(r=e.C).M)r.M=0,e.M=1,e===this.m?this.m=e.rotateLeft():e.rotateLeft();else{if(r.C&&1===r.C.M)return r.M=e.M,e.M=0,r.C.M=0,void(e===this.m?this.m=e.rotateLeft():e.rotateLeft());r.I&&1===r.I.M?(r.M=1,r.I.M=0,r.rotateRight()):(r.M=1,t=e)}else if(1===(r=e.I).M)r.M=0,e.M=1,e===this.m?this.m=e.rotateRight():e.rotateRight();else{if(r.I&&1===r.I.M)return r.M=e.M,e.M=0,r.I.M=0,void(e===this.m?this.m=e.rotateRight():e.rotateRight());r.C&&1===r.C.M?(r.M=1,r.C.M=0,r.rotateLeft()):(r.M=1,t=e)}}},R.prototype.P=function(t){var r;if(1===this.t)return this.clear(),this.A;for(var e=t;e.I||e.C;){if(e.C)for(e=e.C;e.I;)e=e.I;else e=e.I;r=n([e.O,t.O],2),t.O=r[0],e.O=r[1],r=n([e.g,t.g],2),t.g=r[0],e.g=r[1],t=e}this.A.I===e?this.A.I=e.V:this.A.C===e&&(this.A.C=e.V),this.K(e);var i=e.V;return e===i.I?i.I=void 0:i.C=void 0,--this.t,this.m.M=0,i},R.prototype.B=function(t){for(;;){var r=t.V;if(0===r.M)return;var e,i,n=r.V;if(r===n.I){if((e=n.C)&&1===e.M){if(e.M=r.M=0,n===this.m)return;n.M=1,t=n;continue}if(t===r.C)return t.M=0,t.I&&(t.I.V=r),t.C&&(t.C.V=n),r.C=t.I,n.I=t.C,t.I=r,(t.C=n)===this.m?(this.m=t,this.A.V=t):(i=n.V).I===n?i.I=t:i.C=t,t.V=n.V,r.V=t,n.V=t,n.M=1,{parentNode:r,grandParent:n,curNode:t};r.M=0,n===this.m?this.m=n.rotateRight():n.rotateRight()}else{if((e=n.I)&&1===e.M){if(e.M=r.M=0,n===this.m)return;n.M=1,t=n;continue}if(t===r.I)return t.M=0,t.I&&(t.I.V=n),t.C&&(t.C.V=r),n.C=t.I,r.I=t.C,t.I=n,t.C=r,n===this.m?(this.m=t,this.A.V=t):(i=n.V).I===n?i.I=t:i.C=t,t.V=n.V,r.V=t,n.V=t,n.M=1,{parentNode:r,grandParent:n,curNode:t};r.M=0,n===this.m?this.m=n.rotateLeft():n.rotateLeft()}return void(n.M=1)}},R.prototype.k=function(t,r,e){if(void 0===this.m)this.t+=1,this.m=new this.H(t,r),this.m.M=0,this.m.V=this.A,this.A.V=this.m,this.A.I=this.m,this.A.C=this.m;else{var i,n=this.A.I,o=this.S(n.O,t);if(0!==o){if(0<o)n.I=new this.H(t,r),i=(n.I.V=n).I,this.A.I=i;else{var o=this.A.C,s=this.S(o.O,t);if(0===s)return void(o.g=r);if(s<0)o.C=new this.H(t,r),i=(o.C.V=o).C,this.A.C=i;else{if(void 0!==e){s=e.v;if(s!==this.A){o=this.S(s.O,t);if(0===o)return void(s.g=r);if(0<o){e=s.pre(),o=this.S(e.O,t);if(0===o)return void(e.g=r);o<0&&(i=new this.H(t,r),void 0===e.C?(e.C=i).V=e:(s.I=i).V=s)}}}if(void 0===i)for(i=this.m;;){var h=this.S(i.O,t);if(0<h){if(void 0===i.I){i.I=new this.H(t,r),i=(i.I.V=i).I;break}i=i.I}else{if(!(h<0))return void(i.g=r);if(void 0===i.C){i.C=new this.H(t,r),i=(i.C.V=i).C;break}i=i.C}}}}return this.t+=1,i}n.g=r}},R.prototype.clear=function(){this.t=0,this.m=void 0,this.A.V=void 0,this.A.I=this.A.C=void 0},R.prototype.updateKeyByIterator=function(t,r){t=t.v;if(t===this.A)throw new TypeError("Invalid iterator!");if(1!==this.t){if(t===this.A.I)return 0<this.S(t.next().O,r)&&(t.O=r,!0);if(t===this.A.C)return this.S(t.pre().O,r)<0&&(t.O=r,!0);var e=t.pre().O;if(0<=this.S(e,r))return!1;if(e=t.next().O,this.S(e,r)<=0)return!1}return t.O=r,!0},R.prototype.eraseElementByPos=function(r){var e=this;if(r<0||r>this.t-1)throw new RangeError;var i=0;this.N(this.m,function(t){return r===i?(e.q(t),!0):(i+=1,!1)})},R.prototype.L=function(t,r){for(;t;){var e=this.S(t.O,r);if(e<0)t=t.C;else{if(!(0<e))return t;t=t.I}}return t},R.prototype.eraseElementByKey=function(t){this.t&&void 0!==(t=this.L(this.m,t))&&this.q(t)},R.prototype.eraseElementByIterator=function(t){var r=t.v;if(r===this.A)throw new RangeError("Invalid iterator");return void 0===r.C&&(t=t.next()),this.q(r),t},R.prototype.getHeight=function(){var r;return this.t?(r=function(t){return t?Math.max(r(t.I),r(t.C))+1:0})(this.m):0};var _,L=R;function R(t,r){void 0===t&&(t=function(t,r){return t<r?-1:r<t?1:0}),void 0===r&&(r=!1);var e=_.call(this)||this;return e.m=void 0,e.N=function(t,r){return void 0!==t&&(!!e.N(t.I,r)||!!r(t)||e.N(t.C,r))},e.S=t,r?(e.H=H,e.j=function(t,r,e){t=this.k(t,r,e);if(t){for(var i=t.V;i!==this.A;)i.R+=1,i=i.V;var r=this.B(t);r&&(e=r.parentNode,t=r.grandParent,r=r.curNode,e.recount(),t.recount(),r.recount())}},e.q=function(t){for(var r=this.P(t);r!==this.A;)--r.R,r=r.V}):(e.H=N,e.j=function(t,r,e){t=this.k(t,r,e);t&&this.B(t)},e.q=e.P),e.A=new e.H,e}r(O,q=e),Object.defineProperty(O.prototype,"index",{get:function(){var t=this.v,r=this.A.V;if(t===this.A)return r?r.R-1:0;var e=0;for(t.I&&(e+=t.I.R);t!==r;){var i=t.V;t===i.C&&(e+=1,i.I)&&(e+=i.I.R),t=i}return e},enumerable:!1,configurable:!0}),O.prototype.equals=function(t){return this.v===t.v};var q,d=O;function O(t,r,e){e=q.call(this,e)||this;return e.v=t,e.A=r,0===e.iteratorType?(e.pre=function(){if(this.v===this.A.I)throw new RangeError("Tree iterator access denied!");return this.v=this.v.pre(),this},e.next=function(){if(this.v===this.A)throw new RangeError("Tree iterator access denied!");return this.v=this.v.next(),this}):(e.pre=function(){if(this.v===this.A.C)throw new RangeError("Tree iterator access denied!");return this.v=this.v.next(),this},e.next=function(){if(this.v===this.A)throw new RangeError("Tree iterator access denied!");return this.v=this.v.pre(),this}),e}r(P,T=d),Object.defineProperty(P.prototype,"pointer",{get:function(){var i=this;if(this.v===this.A)throw new RangeError("OrderedMap iterator access denied");return new Proxy([],{get:function(t,r){return"0"===r?i.v.O:"1"===r?i.v.g:void 0},set:function(t,r,e){if("1"!==r)throw new TypeError("props must be 1");return i.v.g=e,!0}})},enumerable:!1,configurable:!0}),P.prototype.copy=function(){return new P(this.v,this.A,this.iteratorType)};var T,x=P;function P(){return null!==T&&T.apply(this,arguments)||this}r(j,K=L),j.prototype.begin=function(){return new x(this.A.I||this.A,this.A)},j.prototype.end=function(){return new x(this.A,this.A)},j.prototype.rBegin=function(){return new x(this.A.C||this.A,this.A,1)},j.prototype.rEnd=function(){return new x(this.A,this.A,1)},j.prototype.front=function(){var t;if(this.t)return[(t=this.A.I).O,t.g]},j.prototype.back=function(){var t;if(this.t)return[(t=this.A.C).O,t.g]},j.prototype.forEach=function(t){var r,e,i=0;try{for(var n=c(this),o=n.next();!o.done;o=n.next())t(o.value,i++,this)}catch(t){r={error:t}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(r)throw r.error}}},j.prototype.lowerBound=function(t){t=this.G(this.m,t);return new x(t,this.A)},j.prototype.upperBound=function(t){t=this.J(this.m,t);return new x(t,this.A)},j.prototype.reverseLowerBound=function(t){t=this.D(this.m,t);return new x(t,this.A)},j.prototype.reverseUpperBound=function(t){t=this.F(this.m,t);return new x(t,this.A)},j.prototype.setElement=function(t,r,e){this.j(t,r,e)},j.prototype.find=function(t){t=this.L(this.m,t);return void 0!==t?new x(t,this.A):this.end()},j.prototype.getElementByKey=function(t){t=this.L(this.m,t);return t?t.g:void 0},j.prototype.getElementByPos=function(t){var r,e,i;if(t<0||t>this.t-1)throw new RangeError;var n=0;try{for(var o=c(this),s=o.next();!s.done;s=o.next()){var h=s.value;if(n===t){i=h;break}n+=1}}catch(t){r={error:t}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(r)throw r.error}}return i},j.prototype.union=function(t){var e=this;t.forEach(function(t){var t=n(t,2),r=t[0],t=t[1];return e.setElement(r,t)})},j.prototype[Symbol.iterator]=function(){return this.U(this.m)};var K,S=j;function j(t,r,e){void 0===t&&(t=[]);var i=K.call(this,r,e)||this;return i.U=function(r){return f(this,function(t){switch(t.label){case 0:return void 0===r?[2]:[5,c(this.U(r.I))];case 1:return t.sent(),[4,[r.O,r.g]];case 2:return t.sent(),[5,c(this.U(r.C))];case 3:return t.sent(),[2]}})},t.forEach(function(t){var t=n(t,2),r=t[0],t=t[1];return i.setElement(r,t)}),i}r(k,U=s),k.prototype.W=function(){var o=this;if(!(1073741824<=this.i)){for(var s=[],h=this.i,u=(this.i<<=1,Object.keys(this.o)),t=u.length,a=this,r=0;r<t;++r)!function(t){var r,e,t=parseInt(u[t]),i=a.o[t],n=i.size();0===n||(1===n?(n=i.front(),s[a.h(n[0])&a.i-1]=new A([n],!1)):(r=[],e=[],i.forEach(function(t){(0==(o.h(t[0])&h)?r:e).push(t)}),i instanceof S?(s[t]=6<r.length?new S(r):new A(r,!1),s[t+h]=6<e.length?new S(e):new A(e,!1)):(s[t]=new A(r,!1),s[t+h]=new A(e,!1))))}(r);this.o=s}},k.prototype.forEach=function(r){for(var e=this,t=Object.values(this.o),i=t.length,n=0,o=0;o<i;++o)t[o].forEach(function(t){return r(t,n++,e)})},k.prototype.setElement=function(t,r){var e,i=this.h(t)&this.i-1,n=this.o[i];if(n){var o=n.size();if(n instanceof A){try{for(var s=c(n),h=s.next();!h.done;h=s.next()){var u=h.value;if(u[0]===t)return void(u[1]=r)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(a=s.return)&&a.call(s)}finally{if(e)throw e.error}}if(n.pushBack([t,r]),8<=o+1){if(this.i<=64)return this.t+=1,void this.W();this.o[i]=new S(this.o[i])}this.t+=1}else{n.setElement(t,r);var a=n.size();this.t+=a-o}}else this.t+=1,this.o[i]=new A([[t,r]],!1);this.t>.75*this.i&&this.W()},k.prototype.getElementByKey=function(t){var r,e,i=this.h(t)&this.i-1,i=this.o[i];if(i){if(i instanceof S)return i.getElementByKey(t);try{for(var n=c(i),o=n.next();!o.done;o=n.next()){var s=o.value;if(s[0]===t)return s[1]}}catch(t){r={error:t}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(r)throw r.error}}}},k.prototype.eraseElementByKey=function(t){var r=this.h(t)&this.i-1,e=this.o[r];if(e)if(e instanceof A){var i=0;try{for(var n=c(e),o=n.next();!o.done;o=n.next()){if(o.value[0]===t)return e.eraseElementByPos(i),void--this.t;i+=1}}catch(t){h={error:t}}finally{try{o&&!o.done&&(s=n.return)&&s.call(n)}finally{if(h)throw h.error}}}else{var s=e.size(),h=(e.eraseElementByKey(t),e.size());this.t+=h-s,h<=6&&(this.o[r]=new A(e))}},k.prototype.find=function(t){var r,e,i=this.h(t)&this.i-1,i=this.o[i];if(i){if(i instanceof S)return!i.find(t).equals(i.end());try{for(var n=c(i),o=n.next();!o.done;o=n.next())if(o.value[0]===t)return!0}catch(t){r={error:t}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(r)throw r.error}}}return!1},k.prototype[Symbol.iterator]=function(){return function(){var r,e,i,n,o,s,h,u,a;return f(this,function(t){switch(t.label){case 0:r=Object.values(this.o),e=r.length,i=0,t.label=1;case 1:if(!(i<e))return[3,10];n=r[i],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,o=c(n),s=o.next(),t.label=3;case 3:return s.done?[3,6]:[4,s.value];case 4:t.sent(),t.label=5;case 5:return s=o.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(u)throw u.error}return[7];case 9:return++i,[3,1];case 10:return[2]}})}.bind(this)()};var U,a=k;function k(t,r,e){void 0===t&&(t=[]);var i=U.call(this,r,e)||this;return i.o=[],t.forEach(function(t){return i.setElement(t[0],t[1])}),i}t.HashMap=a,Object.defineProperty(t,"X",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var o=function(t,e){return(o=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))(t,e)};function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function s(o,r){var i,s,u,l={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},c={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(n){return function(t){var e=[n,t];if(i)throw new TypeError("Generator is already executing.");for(;l=c&&e[c=0]?0:l;)try{if(i=1,s&&(u=2&e[0]?s.return:e[0]?s.throw||((u=s.return)&&u.call(s),0):s.next)&&!(u=u.call(s,e[1])).done)return u;switch(s=0,(e=u?[2&e[0],u.value]:e)[0]){case 0:case 1:u=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,s=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(u=0<(u=l.trys).length&&u[u.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!u||e[1]>u[0]&&e[1]<u[3]))l.label=e[1];else if(6===e[0]&&l.label<u[1])l.label=u[1],u=e;else{if(!(u&&l.label<u[2])){u[2]&&l.ops.pop(),l.trys.pop();continue}l.label=u[2],l.ops.push(e)}}e=r.call(o,l)}catch(t){e=[6,t],s=0}finally{i=u=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}i.prototype.size=function(){return this.t},i.prototype.empty=function(){return 0===this.t};var n,r=i;function i(){this.t=0}function u(){return null!==n&&n.apply(this,arguments)||this}function l(t){return null!==t&&("object"==(t=typeof t)||"function"==t)}e(u,n=r);e(f,c=r),f.prototype.o=function(t,e,n){if(n=void 0===n?l(t):n){n=t[this.HASH_KEY_TAG];if(void 0!==n)return void(this.i[n][1]=e);Object.defineProperty(t,this.HASH_KEY_TAG,{value:this.i.length,configurable:!0}),this.i.push([t,e])}else{n=this.u[t];if(n)return void(n[1]=e);this.u[t]=[t,e]}this.t+=1},f.prototype.clear=function(){var e=this;this.i.forEach(function(t){delete t[0][e.HASH_KEY_TAG]}),this.i=[],this.u={},Object.setPrototypeOf(this.u,null),this.t=0},f.prototype.eraseElementByKey=function(t,e){if(e=void 0===e?l(t):e){e=t[this.HASH_KEY_TAG];if(void 0===e)return;delete t[this.HASH_KEY_TAG],delete this.i[e]}else{if(void 0===this.u[t])return;delete this.u[t]}--this.t},f.prototype.find=function(t,e){return(e=void 0===e?l(t):e)?"number"==typeof t[this.HASH_KEY_TAG]:void 0!==this.u[t]};var c,r=f;function f(){var t=c.call(this)||this;return t.i=[],t.u={},t.HASH_KEY_TAG=Symbol("JS_SDSL_HASH_KEY_TAG"),Object.setPrototypeOf(t.u,null),t}e(h,a=r),h.prototype.setElement=function(t,e,n){this.o(t,e,n)},h.prototype.getElementByKey=function(t,e){return(e=void 0===e?l(t):e)?void 0!==(e=t[this.HASH_KEY_TAG])?this.i[e][1]:void 0:(e=this.u[t])?e[1]:void 0},h.prototype.forEach=function(t){for(var e=this.i.length,n=0;n<e;++n)t(this.i[n],n,this);for(var o=Object.keys(this.u),r=o.length,i=e,n=0;n<r;++n)t(this.u[o[n]],i++,this);for(var s=Object.getOwnPropertySymbols(this.u),u=s.length,n=0;n<u;++n)t(this.u[s[n]],i++,this)},h.prototype[Symbol.iterator]=function(){return function(){var e,n,o,r,i;return s(this,function(t){switch(t.label){case 0:return[5,function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],o=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&o>=t.length?void 0:t)&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.i)];case 1:t.sent(),e=Object.keys(this.u),n=e.length,i=0,t.label=2;case 2:return i<n?[4,this.u[e[i]]]:[3,5];case 3:t.sent(),t.label=4;case 4:return++i,[3,2];case 5:o=Object.getOwnPropertySymbols(this.u),r=o.length,i=0,t.label=6;case 6:return i<r?[4,this.u[o[i]]]:[3,9];case 7:t.sent(),t.label=8;case 8:return++i,[3,6];case 9:return[2]}})}.bind(this)()};var a,r=h;function h(t){void 0===t&&(t=[]);var e=a.call(this)||this,n=e;return t.forEach(function(t){n.setElement(t[0],t[1])}),e}t.HashMap=r,Object.defineProperty(t,"h",{value:!0})}); | ||
//# sourceMappingURL=hash-map.min.js.map |
{ | ||
"name": "@js-sdsl/hash-map", | ||
"version": "4.2.0-beta.0", | ||
"version": "4.2.0-beta.1", | ||
"description": "javascript standard data structure library which benchmark against C++ STL", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts", | ||
"author": { | ||
@@ -13,3 +14,7 @@ "name": "ZLY201", | ||
"sideEffects": false, | ||
"homepage": "https://js-sdsl.github.io", | ||
"homepage": "https://js-sdsl.org", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/js-sdsl" | ||
}, | ||
"lint-staged": { | ||
@@ -49,6 +54,7 @@ "*.{js,ts}": [ | ||
"conventional-changelog-conventionalcommits": "^5.0.0", | ||
"crypto": "^1.0.1", | ||
"delete-empty": "^3.0.0", | ||
"eslint": "^8.23.1", | ||
"eslint-import-resolver-typescript": "^3.5.2", | ||
"eslint-plugin-compat": "^4.0.2", | ||
"eslint-plugin-import": "^2.26.0", | ||
"get-npm-package-version": "^1.1.1", | ||
@@ -55,0 +61,0 @@ "gh-pages": "^3.2.3", |
118
README.md
<p align="center"> | ||
<a href="https://js-sdsl.github.io/" target="_blank" rel="noopener noreferrer"> | ||
<img src="https://js-sdsl.github.io/assets/logo-removebg.png" alt="js-sdsl logo" width="120" /> | ||
<a href="https://js-sdsl.org/" target="_blank" rel="noopener noreferrer"> | ||
<img src="https://js-sdsl.org/assets/logo-removebg.png" alt="js-sdsl logo" width="120" /> | ||
</a> | ||
@@ -30,11 +30,11 @@ </p> | ||
- **LinkList** - linked list of non-contiguous memory addresses. | ||
- **Deque** - double-ended-queue, O(1) time complexity to inserting elements front and back or getting elements by index. | ||
- **Deque** - double-ended-queue, O(1) time complexity to `unshift` or getting elements by index. | ||
- **OrderedSet** - sorted set which implemented by red black tree. | ||
- **OrderedMap** - sorted map which implemented by red black tree. | ||
- **HashSet** - refer to the hash set implemented by java. | ||
- **HashMap** - refer to the hash map implemented by java. | ||
- **HashSet** - refer to the [polyfill of ES6 Set](https://github.com/rousan/collections-es6). | ||
- **HashMap** - refer to the [polyfill of ES6 Map](https://github.com/rousan/collections-es6). | ||
## ⚔️ Benchmark | ||
We are benchmarking against other popular data structure libraries. In some ways we're better than the best library. See [benchmark](https://js-sdsl.github.io/#/test/benchmark-analyze). | ||
We are benchmarking against other popular data structure libraries. In some ways we're better than the best library. See [benchmark](https://js-sdsl.org/#/test/benchmark-analyze). | ||
@@ -95,28 +95,28 @@ ## 🖥 Supported platforms | ||
| package | npm | install | | ||
|-----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|---------------------------------| | ||
| [@js-sdsl/stack](https://js-sdsl.github.io/js-sdsl/classes/Stack.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/stack)](https://www.npmjs.com/package/@js-sdsl/stack) | `npm i @js-sdsl/stack` | | ||
| [@js-sdsl/queue](https://js-sdsl.github.io/js-sdsl/classes/Queue.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/queue)](https://www.npmjs.com/package/@js-sdsl/queue) | `npm i @js-sdsl/queue` | | ||
| [@js-sdsl/priority-queue](https://js-sdsl.github.io/js-sdsl/classes/PriorityQueue.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/priority-queue)](https://www.npmjs.com/package/@js-sdsl/priority-queue) | `npm i @js-sdsl/priority-queue` | | ||
| [@js-sdsl/vector](https://js-sdsl.github.io/js-sdsl/classes/Vector.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/vector)](https://www.npmjs.com/package/@js-sdsl/vector) | `npm i @js-sdsl/vector` | | ||
| [@js-sdsl/link-list](https://js-sdsl.github.io/js-sdsl/classes/LinkList.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/link-list)](https://www.npmjs.com/package/@js-sdsl/link-list) | `npm i @js-sdsl/link-list` | | ||
| [@js-sdsl/deque](https://js-sdsl.github.io/js-sdsl/classes/Deque.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/deque)](https://www.npmjs.com/package/@js-sdsl/deque) | `npm i @js-sdsl/deque` | | ||
| [@js-sdsl/ordered-set](https://js-sdsl.github.io/js-sdsl/classes/OrderedSet.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/ordered-set)](https://www.npmjs.com/package/@js-sdsl/ordered-set) | `npm i @js-sdsl/ordered-set` | | ||
| [@js-sdsl/ordered-map](https://js-sdsl.github.io/js-sdsl/classes/OrderedMap.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/ordered-map)](https://www.npmjs.com/package/@js-sdsl/ordered-map) | `npm i @js-sdsl/ordered-map` | | ||
| [@js-sdsl/hash-set](https://js-sdsl.github.io/js-sdsl/classes/HashSet.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/hash-set)](https://www.npmjs.com/package/@js-sdsl/hash-set) | `npm i @js-sdsl/hash-set` | | ||
| [@js-sdsl/hash-map](https://js-sdsl.github.io/js-sdsl/classes/HashMap.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/hash-map)](https://www.npmjs.com/package/@js-sdsl/hash-map) | `npm i @js-sdsl/hash-map` | | ||
| package | npm | size | docs | | ||
|---------------------------------------------------|-----------------------------------------------------------------------|------------------------------------------------------------------|-----------------------------| | ||
| [@js-sdsl/stack][stack-package] | [![NPM Package][stack-npm-version]][stack-npm-link] | [![GZIP Size][stack-umd-size]][stack-umd-link] | [link][stack-docs] | | ||
| [@js-sdsl/queue][queue-package] | [![NPM Package][queue-npm-version]][queue-npm-link] | [![GZIP Size][queue-umd-size]][queue-umd-link] | [link][queue-docs] | | ||
| [@js-sdsl/priority-queue][priority-queue-package] | [![NPM Package][priority-queue-npm-version]][priority-queue-npm-link] | [![GZIP Size][priority-queue-umd-size]][priority-queue-umd-link] | [link][priority-queue-docs] | | ||
| [@js-sdsl/vector][vector-package] | [![NPM Package][vector-npm-version]][vector-npm-link] | [![GZIP Size][vector-umd-size]][vector-umd-link] | [link][vector-docs] | | ||
| [@js-sdsl/link-list][link-list-package] | [![NPM Package][link-list-npm-version]][link-list-npm-link] | [![GZIP Size][link-list-umd-size]][link-list-umd-link] | [link][link-list-docs] | | ||
| [@js-sdsl/deque][deque-package] | [![NPM Package][deque-npm-version]][deque-npm-link] | [![GZIP Size][deque-umd-size]][deque-umd-link] | [link][deque-docs] | | ||
| [@js-sdsl/ordered-set][ordered-set-package] | [![NPM Package][ordered-set-npm-version]][ordered-set-npm-link] | [![GZIP Size][ordered-set-umd-size]][ordered-set-umd-link] | [link][ordered-set-docs] | | ||
| [@js-sdsl/ordered-map][ordered-map-package] | [![NPM Package][ordered-map-npm-version]][ordered-map-npm-link] | [![GZIP Size][ordered-map-umd-size]][ordered-map-umd-link] | [link][ordered-map-docs] | | ||
| [@js-sdsl/hash-set][hash-set-package] | [![NPM Package][hash-set-npm-version]][hash-set-npm-link] | [![GZIP Size][hash-set-umd-size]][hash-set-umd-link] | [link][hash-set-docs] | | ||
| [@js-sdsl/hash-map][hash-map-package] | [![NPM Package][hash-map-npm-version]][hash-map-npm-link] | [![GZIP Size][hash-map-umd-size]][hash-map-umd-link] | [link][hash-map-docs] | | ||
## 🪒 Usage | ||
You can visit our [official website](https://js-sdsl.github.io/) to get more information. | ||
You can visit our [official website](https://js-sdsl.org/) to get more information. | ||
To help you have a better use, we also provide this [API document](https://js-sdsl.github.io/js-sdsl/index.html). | ||
To help you have a better use, we also provide this [API document](https://js-sdsl.org/js-sdsl/index.html). | ||
For previous versions of the documentation, please visit: | ||
`https://js-sdsl.github.io/js-sdsl/previous/v${version}/index.html` | ||
`https://js-sdsl.org/js-sdsl/previous/v${version}/index.html` | ||
E.g. | ||
[https://js-sdsl.github.io/js-sdsl/previous/v4.1.5/index.html](https://js-sdsl.github.io/js-sdsl/previous/v4.1.5/index.html) | ||
[https://js-sdsl.org/js-sdsl/previous/v4.1.5/index.html](https://js-sdsl.org/js-sdsl/previous/v4.1.5/index.html) | ||
@@ -168,3 +168,3 @@ ### For browser | ||
You can also visit [here](https://js-sdsl.github.io/#/test/performance-test) to get the result. | ||
You can also visit [here](https://js-sdsl.org/#/test/performance-test) to get the result. | ||
@@ -219,3 +219,3 @@ ## ⌨️ Development | ||
<a href="https://eslint.org/"><img src="https://js-sdsl.github.io/assets/sponsors/eslint-logo-color.png" alt="eslint logo" width="150"></a> | ||
<a href="https://eslint.org/"><img src="https://js-sdsl.org/assets/sponsors/eslint-logo-color.png" alt="eslint logo" width="150"></a> | ||
@@ -231,1 +231,71 @@ Thanks also give to these sponsors or backers: | ||
[MIT](https://github.com/js-sdsl/js-sdsl/blob/main/LICENSE) © [ZLY201](https://github.com/zly201) | ||
[stack-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/OtherContainer/Stack.ts | ||
[stack-npm-version]: https://img.shields.io/npm/v/@js-sdsl/stack | ||
[stack-npm-link]: https://www.npmjs.com/package/@js-sdsl/stack | ||
[stack-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/stack/dist/umd/stack.min.js?compression=gzip&style=flat-square/ | ||
[stack-umd-link]: https://unpkg.com/@js-sdsl/stack/dist/umd/stack.min.js | ||
[stack-docs]: https://js-sdsl.org/js-sdsl/classes/Stack.html | ||
[queue-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/OtherContainer/Queue.ts | ||
[queue-npm-version]: https://img.shields.io/npm/v/@js-sdsl/queue | ||
[queue-npm-link]: https://www.npmjs.com/package/@js-sdsl/queue | ||
[queue-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/queue/dist/umd/queue.min.js?compression=gzip&style=flat-square/ | ||
[queue-umd-link]: https://unpkg.com/@js-sdsl/queue/dist/umd/queue.min.js | ||
[queue-docs]: https://js-sdsl.org/js-sdsl/classes/Queue.html | ||
[priority-queue-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/OtherContainer/PriorityQueue.ts | ||
[priority-queue-npm-version]: https://img.shields.io/npm/v/@js-sdsl/priority-queue | ||
[priority-queue-npm-link]: https://www.npmjs.com/package/@js-sdsl/priority-queue | ||
[priority-queue-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/priority-queue/dist/umd/priority-queue.min.js?compression=gzip&style=flat-square/ | ||
[priority-queue-umd-link]: https://unpkg.com/@js-sdsl/priority-queue/dist/umd/priority-queue.min.js | ||
[priority-queue-docs]: https://js-sdsl.org/js-sdsl/classes/PriorityQueue.html | ||
[vector-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/SequentialContainer/Vector.ts | ||
[vector-npm-version]: https://img.shields.io/npm/v/@js-sdsl/vector | ||
[vector-npm-link]: https://www.npmjs.com/package/@js-sdsl/vector | ||
[vector-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/vector/dist/umd/vector.min.js?compression=gzip&style=flat-square/ | ||
[vector-umd-link]: https://unpkg.com/@js-sdsl/vector/dist/umd/vector.min.js | ||
[vector-docs]: https://js-sdsl.org/js-sdsl/classes/Vector.html | ||
[link-list-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/SequentialContainer/LinkList.ts | ||
[link-list-npm-version]: https://img.shields.io/npm/v/@js-sdsl/link-list | ||
[link-list-npm-link]: https://www.npmjs.com/package/@js-sdsl/link-list | ||
[link-list-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/link-list/dist/umd/link-list.min.js?compression=gzip&style=flat-square/ | ||
[link-list-umd-link]: https://unpkg.com/@js-sdsl/link-list/dist/umd/link-list.min.js | ||
[link-list-docs]: https://js-sdsl.org/js-sdsl/classes/LinkList.html | ||
[deque-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/SequentialContainer/Deque.ts | ||
[deque-npm-version]: https://img.shields.io/npm/v/@js-sdsl/deque | ||
[deque-npm-link]: https://www.npmjs.com/package/@js-sdsl/deque | ||
[deque-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/deque/dist/umd/deque.min.js?compression=gzip&style=flat-square/ | ||
[deque-umd-link]: https://unpkg.com/@js-sdsl/deque/dist/umd/deque.min.js | ||
[deque-docs]: https://js-sdsl.org/js-sdsl/classes/Deque.html | ||
[ordered-set-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/TreeContainer/OrderedSet.ts | ||
[ordered-set-npm-version]: https://img.shields.io/npm/v/@js-sdsl/ordered-set | ||
[ordered-set-npm-link]: https://www.npmjs.com/package/@js-sdsl/ordered-set | ||
[ordered-set-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/ordered-set/dist/umd/ordered-set.min.js?compression=gzip&style=flat-square/ | ||
[ordered-set-umd-link]: https://unpkg.com/@js-sdsl/ordered-set/dist/umd/ordered-set.min.js | ||
[ordered-set-docs]: https://js-sdsl.org/js-sdsl/classes/OrderedSet.html | ||
[ordered-map-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/TreeContainer/OrderedMap.ts | ||
[ordered-map-npm-version]: https://img.shields.io/npm/v/@js-sdsl/ordered-map | ||
[ordered-map-npm-link]: https://www.npmjs.com/package/@js-sdsl/ordered-map | ||
[ordered-map-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/ordered-map/dist/umd/ordered-map.min.js?compression=gzip&style=flat-square/ | ||
[ordered-map-umd-link]: https://unpkg.com/@js-sdsl/ordered-map/dist/umd/ordered-map.min.js | ||
[ordered-map-docs]: https://js-sdsl.org/js-sdsl/classes/OrderedMap.html | ||
[hash-set-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/HashContainer/HashSet.ts | ||
[hash-set-npm-version]: https://img.shields.io/npm/v/@js-sdsl/hash-set | ||
[hash-set-npm-link]: https://www.npmjs.com/package/@js-sdsl/hash-set | ||
[hash-set-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/hash-set/dist/umd/hash-set.min.js?compression=gzip&style=flat-square/ | ||
[hash-set-umd-link]: https://unpkg.com/@js-sdsl/hash-set/dist/umd/hash-set.min.js | ||
[hash-set-docs]: https://js-sdsl.org/js-sdsl/classes/HashSet.html | ||
[hash-map-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/HashContainer/HashMap.ts | ||
[hash-map-npm-version]: https://img.shields.io/npm/v/@js-sdsl/hash-map | ||
[hash-map-npm-link]: https://www.npmjs.com/package/@js-sdsl/hash-map | ||
[hash-map-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/hash-map/dist/umd/hash-map.min.js?compression=gzip&style=flat-square/ | ||
[hash-map-umd-link]: https://unpkg.com/@js-sdsl/hash-map/dist/umd/hash-map.min.js | ||
[hash-map-docs]: https://js-sdsl.org/js-sdsl/classes/HashMap.html |
<p align="center"> | ||
<a href="https://js-sdsl.github.io/" target="_blank" rel="noopener noreferrer"> | ||
<img src="https://js-sdsl.github.io/assets/logo-removebg.png" alt="js-sdsl logo" width="120" /> | ||
<a href="https://js-sdsl.org/" target="_blank" rel="noopener noreferrer"> | ||
<img src="https://js-sdsl.org/assets/logo-removebg.png" alt="js-sdsl logo" width="120" /> | ||
</a> | ||
@@ -30,7 +30,7 @@ </p> | ||
- **LinkList** - 非连续内存地址的链表 | ||
- **Deque** - 双端队列,向前和向后插入元素或按索引获取元素的 O(1) 时间复杂度 | ||
- **Deque** - 双端队列,向前和向后插入元素或按索引获取元素的时间复杂度为 O(1) | ||
- **OrderedSet** - 由红黑树实现的排序集合 | ||
- **OrderedMap** - 由红黑树实现的排序字典 | ||
- **HashSet** - 参考 java 实现的哈希集合 | ||
- **HashMap** - 参考 java 实现的哈希字典 | ||
- **HashSet** - 参考 [ES6 Set polyfill](https://github.com/rousan/collections-es6) 实现的哈希集合 | ||
- **HashMap** - 参考 [ES6 Set polyfill](https://github.com/rousan/collections-es6) 实现的哈希字典 | ||
@@ -41,3 +41,3 @@ ## ⚔️ 基准测试 | ||
查看 [benchmark](https://js-sdsl.github.io/#/zh-cn/test/benchmark-analyze) 以获取更多信息 | ||
查看 [benchmark](https://js-sdsl.org/#/zh-cn/test/benchmark-analyze) 以获取更多信息 | ||
@@ -98,28 +98,28 @@ ## 🖥 支持的平台 | ||
| package | npm | install | | ||
|-----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|---------------------------------| | ||
| [@js-sdsl/stack](https://js-sdsl.github.io/js-sdsl/classes/Stack.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/stack)](https://www.npmjs.com/package/@js-sdsl/stack) | `npm i @js-sdsl/stack` | | ||
| [@js-sdsl/queue](https://js-sdsl.github.io/js-sdsl/classes/Queue.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/queue)](https://www.npmjs.com/package/@js-sdsl/queue) | `npm i @js-sdsl/queue` | | ||
| [@js-sdsl/priority-queue](https://js-sdsl.github.io/js-sdsl/classes/PriorityQueue.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/priority-queue)](https://www.npmjs.com/package/@js-sdsl/priority-queue) | `npm i @js-sdsl/priority-queue` | | ||
| [@js-sdsl/vector](https://js-sdsl.github.io/js-sdsl/classes/Vector.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/vector)](https://www.npmjs.com/package/@js-sdsl/vector) | `npm i @js-sdsl/vector` | | ||
| [@js-sdsl/link-list](https://js-sdsl.github.io/js-sdsl/classes/LinkList.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/link-list)](https://www.npmjs.com/package/@js-sdsl/link-list) | `npm i @js-sdsl/link-list` | | ||
| [@js-sdsl/deque](https://js-sdsl.github.io/js-sdsl/classes/Deque.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/deque)](https://www.npmjs.com/package/@js-sdsl/deque) | `npm i @js-sdsl/deque` | | ||
| [@js-sdsl/ordered-set](https://js-sdsl.github.io/js-sdsl/classes/OrderedSet.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/ordered-set)](https://www.npmjs.com/package/@js-sdsl/ordered-set) | `npm i @js-sdsl/ordered-set` | | ||
| [@js-sdsl/ordered-map](https://js-sdsl.github.io/js-sdsl/classes/OrderedMap.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/ordered-map)](https://www.npmjs.com/package/@js-sdsl/ordered-map) | `npm i @js-sdsl/ordered-map` | | ||
| [@js-sdsl/hash-set](https://js-sdsl.github.io/js-sdsl/classes/HashSet.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/hash-set)](https://www.npmjs.com/package/@js-sdsl/hash-set) | `npm i @js-sdsl/hash-set` | | ||
| [@js-sdsl/hash-map](https://js-sdsl.github.io/js-sdsl/classes/HashMap.html) | [![NPM Package](https://img.shields.io/npm/v/@js-sdsl/hash-map)](https://www.npmjs.com/package/@js-sdsl/hash-map) | `npm i @js-sdsl/hash-map` | | ||
| package | npm | size | docs | | ||
|---------------------------------------------------|-----------------------------------------------------------------------|------------------------------------------------------------------|-----------------------------| | ||
| [@js-sdsl/stack][stack-package] | [![NPM Package][stack-npm-version]][stack-npm-link] | [![GZIP Size][stack-umd-size]][stack-umd-link] | [link][stack-docs] | | ||
| [@js-sdsl/queue][queue-package] | [![NPM Package][queue-npm-version]][queue-npm-link] | [![GZIP Size][queue-umd-size]][queue-umd-link] | [link][queue-docs] | | ||
| [@js-sdsl/priority-queue][priority-queue-package] | [![NPM Package][priority-queue-npm-version]][priority-queue-npm-link] | [![GZIP Size][priority-queue-umd-size]][priority-queue-umd-link] | [link][priority-queue-docs] | | ||
| [@js-sdsl/vector][vector-package] | [![NPM Package][vector-npm-version]][vector-npm-link] | [![GZIP Size][vector-umd-size]][vector-umd-link] | [link][vector-docs] | | ||
| [@js-sdsl/link-list][link-list-package] | [![NPM Package][link-list-npm-version]][link-list-npm-link] | [![GZIP Size][link-list-umd-size]][link-list-umd-link] | [link][link-list-docs] | | ||
| [@js-sdsl/deque][deque-package] | [![NPM Package][deque-npm-version]][deque-npm-link] | [![GZIP Size][deque-umd-size]][deque-umd-link] | [link][deque-docs] | | ||
| [@js-sdsl/ordered-set][ordered-set-package] | [![NPM Package][ordered-set-npm-version]][ordered-set-npm-link] | [![GZIP Size][ordered-set-umd-size]][ordered-set-umd-link] | [link][ordered-set-docs] | | ||
| [@js-sdsl/ordered-map][ordered-map-package] | [![NPM Package][ordered-map-npm-version]][ordered-map-npm-link] | [![GZIP Size][ordered-map-umd-size]][ordered-map-umd-link] | [link][ordered-map-docs] | | ||
| [@js-sdsl/hash-set][hash-set-package] | [![NPM Package][hash-set-npm-version]][hash-set-npm-link] | [![GZIP Size][hash-set-umd-size]][hash-set-umd-link] | [link][hash-set-docs] | | ||
| [@js-sdsl/hash-map][hash-map-package] | [![NPM Package][hash-map-npm-version]][hash-map-npm-link] | [![GZIP Size][hash-map-umd-size]][hash-map-umd-link] | [link][hash-map-docs] | | ||
## 🪒 使用说明 | ||
您可以[访问我们的主页](https://js-sdsl.github.io/)获取更多信息 | ||
您可以[访问我们的主页](https://js-sdsl.org/)获取更多信息 | ||
并且我们提供了完整的 [API 文档](https://js-sdsl.github.io/js-sdsl/index.html)供您参考 | ||
并且我们提供了完整的 [API 文档](https://js-sdsl.org/js-sdsl/index.html)供您参考 | ||
想要查看从前版本的文档,请访问: | ||
`https://js-sdsl.github.io/js-sdsl/previous/v${version}/index.html` | ||
`https://js-sdsl.org/js-sdsl/previous/v${version}/index.html` | ||
例如: | ||
[https://js-sdsl.github.io/js-sdsl/previous/v4.1.5/index.html](https://js-sdsl.github.io/js-sdsl/previous/v4.1.5/index.html) | ||
[https://js-sdsl.org/js-sdsl/previous/v4.1.5/index.html](https://js-sdsl.org/js-sdsl/previous/v4.1.5/index.html) | ||
@@ -171,3 +171,3 @@ ### 在浏览器中使用 | ||
您也可以访问[我们的网站](https://js-sdsl.github.io/#/zh-cn/test/performance-test)来获取结果 | ||
您也可以访问[我们的网站](https://js-sdsl.org/#/zh-cn/test/performance-test)来获取结果 | ||
@@ -222,3 +222,3 @@ ## ⌨️ 开发 | ||
<a href="https://eslint.org/"><img src="https://js-sdsl.github.io/assets/sponsors/eslint-logo-color.png" alt="eslint logo" width="150"></a> | ||
<a href="https://eslint.org/"><img src="https://js-sdsl.org/assets/sponsors/eslint-logo-color.png" alt="eslint logo" width="150"></a> | ||
@@ -234,1 +234,71 @@ 同样感谢这些赞助商和支持者们: | ||
[MIT](https://github.com/js-sdsl/js-sdsl/blob/main/LICENSE) © [ZLY201](https://github.com/zly201) | ||
[stack-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/OtherContainer/Stack.ts | ||
[stack-npm-version]: https://img.shields.io/npm/v/@js-sdsl/stack | ||
[stack-npm-link]: https://www.npmjs.com/package/@js-sdsl/stack | ||
[stack-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/stack/dist/umd/stack.min.js?compression=gzip&style=flat-square/ | ||
[stack-umd-link]: https://unpkg.com/@js-sdsl/stack/dist/umd/stack.min.js | ||
[stack-docs]: https://js-sdsl.org/js-sdsl/classes/Stack.html | ||
[queue-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/OtherContainer/Queue.ts | ||
[queue-npm-version]: https://img.shields.io/npm/v/@js-sdsl/queue | ||
[queue-npm-link]: https://www.npmjs.com/package/@js-sdsl/queue | ||
[queue-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/queue/dist/umd/queue.min.js?compression=gzip&style=flat-square/ | ||
[queue-umd-link]: https://unpkg.com/@js-sdsl/queue/dist/umd/queue.min.js | ||
[queue-docs]: https://js-sdsl.org/js-sdsl/classes/Queue.html | ||
[priority-queue-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/OtherContainer/PriorityQueue.ts | ||
[priority-queue-npm-version]: https://img.shields.io/npm/v/@js-sdsl/priority-queue | ||
[priority-queue-npm-link]: https://www.npmjs.com/package/@js-sdsl/priority-queue | ||
[priority-queue-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/priority-queue/dist/umd/priority-queue.min.js?compression=gzip&style=flat-square/ | ||
[priority-queue-umd-link]: https://unpkg.com/@js-sdsl/priority-queue/dist/umd/priority-queue.min.js | ||
[priority-queue-docs]: https://js-sdsl.org/js-sdsl/classes/PriorityQueue.html | ||
[vector-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/SequentialContainer/Vector.ts | ||
[vector-npm-version]: https://img.shields.io/npm/v/@js-sdsl/vector | ||
[vector-npm-link]: https://www.npmjs.com/package/@js-sdsl/vector | ||
[vector-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/vector/dist/umd/vector.min.js?compression=gzip&style=flat-square/ | ||
[vector-umd-link]: https://unpkg.com/@js-sdsl/vector/dist/umd/vector.min.js | ||
[vector-docs]: https://js-sdsl.org/js-sdsl/classes/Vector.html | ||
[link-list-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/SequentialContainer/LinkList.ts | ||
[link-list-npm-version]: https://img.shields.io/npm/v/@js-sdsl/link-list | ||
[link-list-npm-link]: https://www.npmjs.com/package/@js-sdsl/link-list | ||
[link-list-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/link-list/dist/umd/link-list.min.js?compression=gzip&style=flat-square/ | ||
[link-list-umd-link]: https://unpkg.com/@js-sdsl/link-list/dist/umd/link-list.min.js | ||
[link-list-docs]: https://js-sdsl.org/js-sdsl/classes/LinkList.html | ||
[deque-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/SequentialContainer/Deque.ts | ||
[deque-npm-version]: https://img.shields.io/npm/v/@js-sdsl/deque | ||
[deque-npm-link]: https://www.npmjs.com/package/@js-sdsl/deque | ||
[deque-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/deque/dist/umd/deque.min.js?compression=gzip&style=flat-square/ | ||
[deque-umd-link]: https://unpkg.com/@js-sdsl/deque/dist/umd/deque.min.js | ||
[deque-docs]: https://js-sdsl.org/js-sdsl/classes/Deque.html | ||
[ordered-set-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/TreeContainer/OrderedSet.ts | ||
[ordered-set-npm-version]: https://img.shields.io/npm/v/@js-sdsl/ordered-set | ||
[ordered-set-npm-link]: https://www.npmjs.com/package/@js-sdsl/ordered-set | ||
[ordered-set-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/ordered-set/dist/umd/ordered-set.min.js?compression=gzip&style=flat-square/ | ||
[ordered-set-umd-link]: https://unpkg.com/@js-sdsl/ordered-set/dist/umd/ordered-set.min.js | ||
[ordered-set-docs]: https://js-sdsl.org/js-sdsl/classes/OrderedSet.html | ||
[ordered-map-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/TreeContainer/OrderedMap.ts | ||
[ordered-map-npm-version]: https://img.shields.io/npm/v/@js-sdsl/ordered-map | ||
[ordered-map-npm-link]: https://www.npmjs.com/package/@js-sdsl/ordered-map | ||
[ordered-map-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/ordered-map/dist/umd/ordered-map.min.js?compression=gzip&style=flat-square/ | ||
[ordered-map-umd-link]: https://unpkg.com/@js-sdsl/ordered-map/dist/umd/ordered-map.min.js | ||
[ordered-map-docs]: https://js-sdsl.org/js-sdsl/classes/OrderedMap.html | ||
[hash-set-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/HashContainer/HashSet.ts | ||
[hash-set-npm-version]: https://img.shields.io/npm/v/@js-sdsl/hash-set | ||
[hash-set-npm-link]: https://www.npmjs.com/package/@js-sdsl/hash-set | ||
[hash-set-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/hash-set/dist/umd/hash-set.min.js?compression=gzip&style=flat-square/ | ||
[hash-set-umd-link]: https://unpkg.com/@js-sdsl/hash-set/dist/umd/hash-set.min.js | ||
[hash-set-docs]: https://js-sdsl.org/js-sdsl/classes/HashSet.html | ||
[hash-map-package]: https://github.com/js-sdsl/js-sdsl/blob/main/src/container/HashContainer/HashMap.ts | ||
[hash-map-npm-version]: https://img.shields.io/npm/v/@js-sdsl/hash-map | ||
[hash-map-npm-link]: https://www.npmjs.com/package/@js-sdsl/hash-map | ||
[hash-map-umd-size]: https://img.badgesize.io/https://unpkg.com/@js-sdsl/hash-map/dist/umd/hash-map.min.js?compression=gzip&style=flat-square/ | ||
[hash-map-umd-link]: https://unpkg.com/@js-sdsl/hash-map/dist/umd/hash-map.min.js | ||
[hash-map-docs]: https://js-sdsl.org/js-sdsl/classes/HashMap.html |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
14
297
157255
73
1049