@js-sdsl/ordered-map
Advanced tools
Comparing version
@@ -251,4 +251,4 @@ declare const enum IteratorType { | ||
/** | ||
* @description Remove the element of the specified _key. | ||
* @param key The _key you want to remove. | ||
* @description Remove the element of the specified key. | ||
* @param key The key you want to remove. | ||
*/ | ||
@@ -255,0 +255,0 @@ eraseElementByKey(key: K): void; |
@@ -7,31 +7,11 @@ "use strict"; | ||
class ContainerIterator { | ||
constructor(e = 0) { | ||
this.iteratorType = e; | ||
} | ||
} | ||
class Base { | ||
constructor() { | ||
this.i = 0; | ||
} | ||
size() { | ||
return this.i; | ||
} | ||
empty() { | ||
return this.i === 0; | ||
} | ||
} | ||
class Container extends Base {} | ||
class TreeNode { | ||
constructor(e, t) { | ||
this.h = 1; | ||
this.i = 1; | ||
this.h = undefined; | ||
this.o = undefined; | ||
this.u = undefined; | ||
this.o = undefined; | ||
this.l = undefined; | ||
this.p = undefined; | ||
this.g = undefined; | ||
this.u = e; | ||
this.h = e; | ||
this.o = t; | ||
@@ -41,14 +21,14 @@ } | ||
let e = this; | ||
if (e.h === 1 && e.g.g === e) { | ||
e = e.p; | ||
} else if (e.l) { | ||
if (e.i === 1 && e.p.p === e) { | ||
e = e.l; | ||
while (e.p) { | ||
e = e.p; | ||
} else if (e.u) { | ||
e = e.u; | ||
while (e.l) { | ||
e = e.l; | ||
} | ||
} else { | ||
let t = e.g; | ||
while (t.l === e) { | ||
let t = e.p; | ||
while (t.u === e) { | ||
e = t; | ||
t = e.g; | ||
t = e.p; | ||
} | ||
@@ -61,15 +41,15 @@ e = t; | ||
let e = this; | ||
if (e.p) { | ||
e = e.p; | ||
while (e.l) { | ||
e = e.l; | ||
if (e.l) { | ||
e = e.l; | ||
while (e.u) { | ||
e = e.u; | ||
} | ||
return e; | ||
} else { | ||
let t = e.g; | ||
while (t.p === e) { | ||
let t = e.p; | ||
while (t.l === e) { | ||
e = t; | ||
t = e.g; | ||
t = e.p; | ||
} | ||
if (e.p !== t) { | ||
if (e.l !== t) { | ||
return t; | ||
@@ -80,23 +60,23 @@ } else return e; | ||
rotateLeft() { | ||
const e = this.g; | ||
const t = this.p; | ||
const i = t.l; | ||
if (e.g === this) e.g = t; else if (e.l === this) e.l = t; else e.p = t; | ||
t.g = e; | ||
t.l = this; | ||
this.g = t; | ||
this.p = i; | ||
if (i) i.g = this; | ||
const e = this.p; | ||
const t = this.l; | ||
const i = t.u; | ||
if (e.p === this) e.p = t; else if (e.u === this) e.u = t; else e.l = t; | ||
t.p = e; | ||
t.u = this; | ||
this.p = t; | ||
this.l = i; | ||
if (i) i.p = this; | ||
return t; | ||
} | ||
rotateRight() { | ||
const e = this.g; | ||
const t = this.l; | ||
const i = t.p; | ||
if (e.g === this) e.g = t; else if (e.l === this) e.l = t; else e.p = t; | ||
t.g = e; | ||
t.p = this; | ||
this.g = t; | ||
this.l = i; | ||
if (i) i.g = this; | ||
const e = this.p; | ||
const t = this.u; | ||
const i = t.l; | ||
if (e.p === this) e.p = t; else if (e.u === this) e.u = t; else e.l = t; | ||
t.p = e; | ||
t.l = this; | ||
this.p = t; | ||
this.u = i; | ||
if (i) i.p = this; | ||
return t; | ||
@@ -109,6 +89,6 @@ } | ||
super(...arguments); | ||
this.u = undefined; | ||
this.l = undefined; | ||
this.p = undefined; | ||
this.g = undefined; | ||
this.I = 1; | ||
this.g = 1; | ||
} | ||
@@ -128,35 +108,48 @@ rotateLeft() { | ||
recount() { | ||
this.I = 1; | ||
if (this.l) this.I += this.l.I; | ||
if (this.p) this.I += this.p.I; | ||
this.g = 1; | ||
if (this.u) this.g += this.u.g; | ||
if (this.l) this.g += this.l.g; | ||
} | ||
} | ||
class ContainerIterator { | ||
constructor(e = 0) { | ||
this.iteratorType = e; | ||
} | ||
} | ||
class Base { | ||
constructor() { | ||
this.I = 0; | ||
} | ||
size() { | ||
return this.I; | ||
} | ||
empty() { | ||
return this.I === 0; | ||
} | ||
} | ||
class Container extends Base {} | ||
class TreeContainer extends Container { | ||
constructor(e = ((e, t) => { | ||
constructor(e = function(e, t) { | ||
if (e < t) return -1; | ||
if (e > t) return 1; | ||
return 0; | ||
}), t = false) { | ||
}, t = false) { | ||
super(); | ||
this.B = undefined; | ||
this.M = (e, t) => { | ||
if (e === undefined) return false; | ||
const i = this.M(e.l, t); | ||
if (i) return true; | ||
if (t(e)) return true; | ||
return this.M(e.p, t); | ||
}; | ||
this.N = e; | ||
this.M = e; | ||
if (t) { | ||
this.O = TreeNodeEnableIndex; | ||
this.T = function(e, t, i) { | ||
const s = this._(e, t, i); | ||
const s = this.N(e, t, i); | ||
if (s) { | ||
let e = s.g; | ||
while (e !== this.m) { | ||
e.I += 1; | ||
e = e.g; | ||
let e = s.p; | ||
while (e !== this._) { | ||
e.g += 1; | ||
e = e.p; | ||
} | ||
const t = this.R(s); | ||
const t = this.m(s); | ||
if (t) { | ||
@@ -170,7 +163,7 @@ const {parentNode: e, grandParent: i, curNode: s} = t; | ||
}; | ||
this.v = function(e) { | ||
let t = this.C(e); | ||
while (t !== this.m) { | ||
t.I -= 1; | ||
t = t.g; | ||
this.R = function(e) { | ||
let t = this.v(e); | ||
while (t !== this._) { | ||
t.g -= 1; | ||
t = t.p; | ||
} | ||
@@ -181,74 +174,74 @@ }; | ||
this.T = function(e, t, i) { | ||
const s = this._(e, t, i); | ||
if (s) this.R(s); | ||
const s = this.N(e, t, i); | ||
if (s) this.m(s); | ||
}; | ||
this.v = this.C; | ||
this.R = this.v; | ||
} | ||
this.m = new this.O; | ||
this._ = new this.O; | ||
} | ||
P(e, t) { | ||
C(e, t) { | ||
let i; | ||
while (e) { | ||
const s = this.N(e.u, t); | ||
const s = this.M(e.h, t); | ||
if (s < 0) { | ||
e = e.p; | ||
e = e.l; | ||
} else if (s > 0) { | ||
i = e; | ||
e = e.l; | ||
e = e.u; | ||
} else return e; | ||
} | ||
return i === undefined ? this.m : i; | ||
return i === undefined ? this._ : i; | ||
} | ||
k(e, t) { | ||
P(e, t) { | ||
let i; | ||
while (e) { | ||
const s = this.N(e.u, t); | ||
const s = this.M(e.h, t); | ||
if (s <= 0) { | ||
e = e.p; | ||
e = e.l; | ||
} else { | ||
i = e; | ||
e = e.l; | ||
e = e.u; | ||
} | ||
} | ||
return i === undefined ? this.m : i; | ||
return i === undefined ? this._ : i; | ||
} | ||
L(e, t) { | ||
k(e, t) { | ||
let i; | ||
while (e) { | ||
const s = this.N(e.u, t); | ||
const s = this.M(e.h, t); | ||
if (s < 0) { | ||
i = e; | ||
e = e.p; | ||
e = e.l; | ||
} else if (s > 0) { | ||
e = e.l; | ||
e = e.u; | ||
} else return e; | ||
} | ||
return i === undefined ? this.m : i; | ||
return i === undefined ? this._ : i; | ||
} | ||
S(e, t) { | ||
L(e, t) { | ||
let i; | ||
while (e) { | ||
const s = this.N(e.u, t); | ||
const s = this.M(e.h, t); | ||
if (s < 0) { | ||
i = e; | ||
e = e.p; | ||
e = e.l; | ||
} else { | ||
e = e.l; | ||
e = e.u; | ||
} | ||
} | ||
return i === undefined ? this.m : i; | ||
return i === undefined ? this._ : i; | ||
} | ||
K(e) { | ||
S(e) { | ||
while (true) { | ||
const t = e.g; | ||
if (t === this.m) return; | ||
if (e.h === 1) { | ||
e.h = 0; | ||
const t = e.p; | ||
if (t === this._) return; | ||
if (e.i === 1) { | ||
e.i = 0; | ||
return; | ||
} | ||
if (e === t.l) { | ||
const i = t.p; | ||
if (i.h === 1) { | ||
i.h = 0; | ||
t.h = 1; | ||
if (e === t.u) { | ||
const i = t.l; | ||
if (i.i === 1) { | ||
i.i = 0; | ||
t.i = 1; | ||
if (t === this.B) { | ||
@@ -258,6 +251,6 @@ this.B = t.rotateLeft(); | ||
} else { | ||
if (i.p && i.p.h === 1) { | ||
i.h = t.h; | ||
t.h = 0; | ||
i.p.h = 0; | ||
if (i.l && i.l.i === 1) { | ||
i.i = t.i; | ||
t.i = 0; | ||
i.l.i = 0; | ||
if (t === this.B) { | ||
@@ -267,8 +260,8 @@ this.B = t.rotateLeft(); | ||
return; | ||
} else if (i.l && i.l.h === 1) { | ||
i.h = 1; | ||
i.l.h = 0; | ||
} else if (i.u && i.u.i === 1) { | ||
i.i = 1; | ||
i.u.i = 0; | ||
i.rotateRight(); | ||
} else { | ||
i.h = 1; | ||
i.i = 1; | ||
e = t; | ||
@@ -278,6 +271,6 @@ } | ||
} else { | ||
const i = t.l; | ||
if (i.h === 1) { | ||
i.h = 0; | ||
t.h = 1; | ||
const i = t.u; | ||
if (i.i === 1) { | ||
i.i = 0; | ||
t.i = 1; | ||
if (t === this.B) { | ||
@@ -287,6 +280,6 @@ this.B = t.rotateRight(); | ||
} else { | ||
if (i.l && i.l.h === 1) { | ||
i.h = t.h; | ||
t.h = 0; | ||
i.l.h = 0; | ||
if (i.u && i.u.i === 1) { | ||
i.i = t.i; | ||
t.i = 0; | ||
i.u.i = 0; | ||
if (t === this.B) { | ||
@@ -296,8 +289,8 @@ this.B = t.rotateRight(); | ||
return; | ||
} else if (i.p && i.p.h === 1) { | ||
i.h = 1; | ||
i.p.h = 0; | ||
} else if (i.l && i.l.i === 1) { | ||
i.i = 1; | ||
i.l.i = 0; | ||
i.rotateLeft(); | ||
} else { | ||
i.h = 1; | ||
i.i = 1; | ||
e = t; | ||
@@ -309,67 +302,74 @@ } | ||
} | ||
C(e) { | ||
if (this.i === 1) { | ||
v(e) { | ||
if (this.I === 1) { | ||
this.clear(); | ||
return this.m; | ||
return this._; | ||
} | ||
let t = e; | ||
while (t.l || t.p) { | ||
if (t.p) { | ||
t = t.p; | ||
while (t.l) t = t.l; | ||
while (t.u || t.l) { | ||
if (t.l) { | ||
t = t.l; | ||
while (t.u) t = t.u; | ||
} else { | ||
t = t.l; | ||
t = t.u; | ||
} | ||
[e.u, t.u] = [ t.u, e.u ]; | ||
[e.h, t.h] = [ t.h, e.h ]; | ||
[e.o, t.o] = [ t.o, e.o ]; | ||
e = t; | ||
} | ||
if (this.m.l === t) { | ||
this.m.l = t.g; | ||
} else if (this.m.p === t) { | ||
this.m.p = t.g; | ||
if (this._.u === t) { | ||
this._.u = t.p; | ||
} else if (this._.l === t) { | ||
this._.l = t.p; | ||
} | ||
this.K(t); | ||
const i = t.g; | ||
if (t === i.l) { | ||
i.l = undefined; | ||
} else i.p = undefined; | ||
this.i -= 1; | ||
this.B.h = 0; | ||
this.S(t); | ||
const i = t.p; | ||
if (t === i.u) { | ||
i.u = undefined; | ||
} else i.l = undefined; | ||
this.I -= 1; | ||
this.B.i = 0; | ||
return i; | ||
} | ||
R(e) { | ||
K(e, t) { | ||
if (e === undefined) return false; | ||
const i = this.K(e.u, t); | ||
if (i) return true; | ||
if (t(e)) return true; | ||
return this.K(e.l, t); | ||
} | ||
m(e) { | ||
while (true) { | ||
const t = e.g; | ||
if (t.h === 0) return; | ||
const i = t.g; | ||
if (t === i.l) { | ||
const s = i.p; | ||
if (s && s.h === 1) { | ||
s.h = t.h = 0; | ||
const t = e.p; | ||
if (t.i === 0) return; | ||
const i = t.p; | ||
if (t === i.u) { | ||
const s = i.l; | ||
if (s && s.i === 1) { | ||
s.i = t.i = 0; | ||
if (i === this.B) return; | ||
i.h = 1; | ||
i.i = 1; | ||
e = i; | ||
continue; | ||
} else if (e === t.p) { | ||
e.h = 0; | ||
if (e.l) e.l.g = t; | ||
if (e.p) e.p.g = i; | ||
t.p = e.l; | ||
i.l = e.p; | ||
e.l = t; | ||
e.p = i; | ||
} else if (e === t.l) { | ||
e.i = 0; | ||
if (e.u) e.u.p = t; | ||
if (e.l) e.l.p = i; | ||
t.l = e.u; | ||
i.u = e.l; | ||
e.u = t; | ||
e.l = i; | ||
if (i === this.B) { | ||
this.B = e; | ||
this.m.g = e; | ||
this._.p = e; | ||
} else { | ||
const t = i.g; | ||
if (t.l === i) { | ||
t.l = e; | ||
} else t.p = e; | ||
const t = i.p; | ||
if (t.u === i) { | ||
t.u = e; | ||
} else t.l = e; | ||
} | ||
e.g = i.g; | ||
t.g = e; | ||
i.g = e; | ||
i.h = 1; | ||
e.p = i.p; | ||
t.p = e; | ||
i.p = e; | ||
i.i = 1; | ||
return { | ||
@@ -381,37 +381,37 @@ parentNode: t, | ||
} else { | ||
t.h = 0; | ||
t.i = 0; | ||
if (i === this.B) { | ||
this.B = i.rotateRight(); | ||
} else i.rotateRight(); | ||
i.h = 1; | ||
i.i = 1; | ||
} | ||
} else { | ||
const s = i.l; | ||
if (s && s.h === 1) { | ||
s.h = t.h = 0; | ||
const s = i.u; | ||
if (s && s.i === 1) { | ||
s.i = t.i = 0; | ||
if (i === this.B) return; | ||
i.h = 1; | ||
i.i = 1; | ||
e = i; | ||
continue; | ||
} else if (e === t.l) { | ||
e.h = 0; | ||
if (e.l) e.l.g = i; | ||
if (e.p) e.p.g = t; | ||
i.p = e.l; | ||
t.l = e.p; | ||
e.l = i; | ||
e.p = t; | ||
} else if (e === t.u) { | ||
e.i = 0; | ||
if (e.u) e.u.p = i; | ||
if (e.l) e.l.p = t; | ||
i.l = e.u; | ||
t.u = e.l; | ||
e.u = i; | ||
e.l = t; | ||
if (i === this.B) { | ||
this.B = e; | ||
this.m.g = e; | ||
this._.p = e; | ||
} else { | ||
const t = i.g; | ||
if (t.l === i) { | ||
t.l = e; | ||
} else t.p = e; | ||
const t = i.p; | ||
if (t.u === i) { | ||
t.u = e; | ||
} else t.l = e; | ||
} | ||
e.g = i.g; | ||
t.g = e; | ||
i.g = e; | ||
i.h = 1; | ||
e.p = i.p; | ||
t.p = e; | ||
i.p = e; | ||
i.i = 1; | ||
return { | ||
@@ -423,7 +423,7 @@ parentNode: t, | ||
} else { | ||
t.h = 0; | ||
t.i = 0; | ||
if (i === this.B) { | ||
this.B = i.rotateLeft(); | ||
} else i.rotateLeft(); | ||
i.h = 1; | ||
i.i = 1; | ||
} | ||
@@ -434,16 +434,16 @@ } | ||
} | ||
_(e, t, i) { | ||
N(e, t, i) { | ||
if (this.B === undefined) { | ||
this.i += 1; | ||
this.I += 1; | ||
this.B = new this.O(e, t); | ||
this.B.h = 0; | ||
this.B.g = this.m; | ||
this.m.g = this.B; | ||
this.m.l = this.B; | ||
this.m.p = this.B; | ||
this.B.i = 0; | ||
this.B.p = this._; | ||
this._.p = this.B; | ||
this._.u = this.B; | ||
this._.l = this.B; | ||
return; | ||
} | ||
let s; | ||
const r = this.m.l; | ||
const n = this.N(r.u, e); | ||
const r = this._.u; | ||
const n = this.M(r.h, e); | ||
if (n === 0) { | ||
@@ -453,9 +453,9 @@ r.o = t; | ||
} else if (n > 0) { | ||
r.l = new this.O(e, t); | ||
r.l.g = r; | ||
s = r.l; | ||
this.m.l = s; | ||
r.u = new this.O(e, t); | ||
r.u.p = r; | ||
s = r.u; | ||
this._.u = s; | ||
} else { | ||
const r = this.m.p; | ||
const n = this.N(r.u, e); | ||
const r = this._.l; | ||
const n = this.M(r.h, e); | ||
if (n === 0) { | ||
@@ -465,11 +465,11 @@ r.o = t; | ||
} else if (n < 0) { | ||
r.p = new this.O(e, t); | ||
r.p.g = r; | ||
s = r.p; | ||
this.m.p = s; | ||
r.l = new this.O(e, t); | ||
r.l.p = r; | ||
s = r.l; | ||
this._.l = s; | ||
} else { | ||
if (i !== undefined) { | ||
const r = i.U; | ||
if (r !== this.m) { | ||
const i = this.N(r.u, e); | ||
if (r !== this._) { | ||
const i = this.M(r.h, e); | ||
if (i === 0) { | ||
@@ -480,3 +480,3 @@ r.o = t; | ||
const i = r.pre(); | ||
const n = this.N(i.u, e); | ||
const n = this.M(i.h, e); | ||
if (n === 0) { | ||
@@ -487,8 +487,8 @@ i.o = t; | ||
s = new this.O(e, t); | ||
if (i.p === undefined) { | ||
i.p = s; | ||
s.g = i; | ||
if (i.l === undefined) { | ||
i.l = s; | ||
s.p = i; | ||
} else { | ||
r.l = s; | ||
s.g = r; | ||
r.u = s; | ||
s.p = r; | ||
} | ||
@@ -502,7 +502,15 @@ } | ||
while (true) { | ||
const i = this.N(s.u, e); | ||
const i = this.M(s.h, e); | ||
if (i > 0) { | ||
if (s.u === undefined) { | ||
s.u = new this.O(e, t); | ||
s.u.p = s; | ||
s = s.u; | ||
break; | ||
} | ||
s = s.u; | ||
} else if (i < 0) { | ||
if (s.l === undefined) { | ||
s.l = new this.O(e, t); | ||
s.l.g = s; | ||
s.l.p = s; | ||
s = s.l; | ||
@@ -512,10 +520,2 @@ break; | ||
s = s.l; | ||
} else if (i < 0) { | ||
if (s.p === undefined) { | ||
s.p = new this.O(e, t); | ||
s.p.g = s; | ||
s = s.p; | ||
break; | ||
} | ||
s = s.p; | ||
} else { | ||
@@ -529,23 +529,23 @@ s.o = t; | ||
} | ||
this.i += 1; | ||
this.I += 1; | ||
return s; | ||
} | ||
clear() { | ||
this.i = 0; | ||
this.I = 0; | ||
this.B = undefined; | ||
this.m.g = undefined; | ||
this.m.l = this.m.p = undefined; | ||
this._.p = undefined; | ||
this._.u = this._.l = undefined; | ||
} | ||
updateKeyByIterator(e, t) { | ||
const i = e.U; | ||
if (i === this.m) { | ||
if (i === this._) { | ||
throw new TypeError("Invalid iterator!"); | ||
} | ||
if (this.i === 1) { | ||
i.u = t; | ||
if (this.I === 1) { | ||
i.h = t; | ||
return true; | ||
} | ||
if (i === this.m.l) { | ||
if (this.N(i.next().u, t) > 0) { | ||
i.u = t; | ||
if (i === this._.u) { | ||
if (this.M(i.next().h, t) > 0) { | ||
i.h = t; | ||
return true; | ||
@@ -555,5 +555,5 @@ } | ||
} | ||
if (i === this.m.p) { | ||
if (this.N(i.pre().u, t) < 0) { | ||
i.u = t; | ||
if (i === this._.l) { | ||
if (this.M(i.pre().h, t) < 0) { | ||
i.h = t; | ||
return true; | ||
@@ -563,17 +563,18 @@ } | ||
} | ||
const s = i.pre().u; | ||
if (this.N(s, t) >= 0) return false; | ||
const r = i.next().u; | ||
if (this.N(r, t) <= 0) return false; | ||
i.u = t; | ||
const s = i.pre().h; | ||
if (this.M(s, t) >= 0) return false; | ||
const r = i.next().h; | ||
if (this.M(r, t) <= 0) return false; | ||
i.h = t; | ||
return true; | ||
} | ||
eraseElementByPos(e) { | ||
if (e < 0 || e > this.i - 1) { | ||
if (e < 0 || e > this.I - 1) { | ||
throw new RangeError; | ||
} | ||
let t = 0; | ||
this.M(this.B, (i => { | ||
const i = this; | ||
this.K(this.B, (function(s) { | ||
if (e === t) { | ||
this.v(i); | ||
i.R(s); | ||
return true; | ||
@@ -587,7 +588,7 @@ } | ||
while (e) { | ||
const i = this.N(e.u, t); | ||
const i = this.M(e.h, t); | ||
if (i < 0) { | ||
e = e.p; | ||
e = e.l; | ||
} else if (i > 0) { | ||
e = e.l; | ||
e = e.u; | ||
} else return e; | ||
@@ -598,23 +599,23 @@ } | ||
eraseElementByKey(e) { | ||
if (!this.i) return; | ||
if (!this.I) return; | ||
const t = this.j(this.B, e); | ||
if (t === undefined) return; | ||
this.v(t); | ||
this.R(t); | ||
} | ||
eraseElementByIterator(e) { | ||
const t = e.U; | ||
if (t === this.m) { | ||
if (t === this._) { | ||
throw new RangeError("Invalid iterator"); | ||
} | ||
if (t.p === undefined) { | ||
if (t.l === undefined) { | ||
e = e.next(); | ||
} | ||
this.v(t); | ||
this.R(t); | ||
return e; | ||
} | ||
getHeight() { | ||
if (!this.i) return 0; | ||
const traversal = e => { | ||
if (!this.I) return 0; | ||
const traversal = function(e) { | ||
if (!e) return 0; | ||
return Math.max(traversal(e.l), traversal(e.p)) + 1; | ||
return Math.max(traversal(e.u), traversal(e.l)) + 1; | ||
}; | ||
@@ -629,6 +630,6 @@ return traversal(this.B); | ||
this.U = e; | ||
this.m = t; | ||
this._ = t; | ||
if (this.iteratorType === 0) { | ||
this.pre = function() { | ||
if (this.U === this.m.l) { | ||
if (this.U === this._.u) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
@@ -640,3 +641,3 @@ } | ||
this.next = function() { | ||
if (this.U === this.m) { | ||
if (this.U === this._) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
@@ -649,3 +650,3 @@ } | ||
this.pre = function() { | ||
if (this.U === this.m.p) { | ||
if (this.U === this._.l) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
@@ -657,3 +658,3 @@ } | ||
this.next = function() { | ||
if (this.U === this.m) { | ||
if (this.U === this._) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
@@ -668,6 +669,6 @@ } | ||
let e = this.U; | ||
const t = this.m.g; | ||
if (e === this.m) { | ||
const t = this._.p; | ||
if (e === this._) { | ||
if (t) { | ||
return t.I - 1; | ||
return t.g - 1; | ||
} | ||
@@ -677,11 +678,11 @@ return 0; | ||
let i = 0; | ||
if (e.l) { | ||
i += e.l.I; | ||
if (e.u) { | ||
i += e.u.g; | ||
} | ||
while (e !== t) { | ||
const t = e.g; | ||
if (e === t.p) { | ||
const t = e.p; | ||
if (e === t.l) { | ||
i += 1; | ||
if (t.l) { | ||
i += t.l.I; | ||
if (t.u) { | ||
i += t.u.g; | ||
} | ||
@@ -700,14 +701,15 @@ } | ||
get pointer() { | ||
if (this.U === this.m) { | ||
if (this.U === this._) { | ||
throw new RangeError("OrderedMap iterator access denied"); | ||
} | ||
const e = this; | ||
return new Proxy([], { | ||
get: (e, t) => { | ||
if (t === "0") return this.U.u; else if (t === "1") return this.U.o; | ||
get(t, i) { | ||
if (i === "0") return e.U.h; else if (i === "1") return e.U.o; | ||
}, | ||
set: (e, t, i) => { | ||
if (t !== "1") { | ||
set(t, i, s) { | ||
if (i !== "1") { | ||
throw new TypeError("props must be 1"); | ||
} | ||
this.U.o = i; | ||
e.U.o = s; | ||
return true; | ||
@@ -718,3 +720,3 @@ } | ||
copy() { | ||
return new OrderedMapIterator(this.U, this.m, this.iteratorType); | ||
return new OrderedMapIterator(this.U, this._, this.iteratorType); | ||
} | ||
@@ -726,31 +728,34 @@ } | ||
super(t, i); | ||
this.q = function*(e) { | ||
if (e === undefined) return; | ||
yield* this.q(e.l); | ||
yield [ e.u, e.o ]; | ||
yield* this.q(e.p); | ||
}; | ||
e.forEach((([e, t]) => this.setElement(e, t))); | ||
const s = this; | ||
e.forEach((function(e) { | ||
s.setElement(e[0], e[1]); | ||
})); | ||
} | ||
* q(e) { | ||
if (e === undefined) return; | ||
yield* this.q(e.u); | ||
yield [ e.h, e.o ]; | ||
yield* this.q(e.l); | ||
} | ||
begin() { | ||
return new OrderedMapIterator(this.m.l || this.m, this.m); | ||
return new OrderedMapIterator(this._.u || this._, this._); | ||
} | ||
end() { | ||
return new OrderedMapIterator(this.m, this.m); | ||
return new OrderedMapIterator(this._, this._); | ||
} | ||
rBegin() { | ||
return new OrderedMapIterator(this.m.p || this.m, this.m, 1); | ||
return new OrderedMapIterator(this._.l || this._, this._, 1); | ||
} | ||
rEnd() { | ||
return new OrderedMapIterator(this.m, this.m, 1); | ||
return new OrderedMapIterator(this._, this._, 1); | ||
} | ||
front() { | ||
if (!this.i) return undefined; | ||
const e = this.m.l; | ||
return [ e.u, e.o ]; | ||
if (!this.I) return undefined; | ||
const e = this._.u; | ||
return [ e.h, e.o ]; | ||
} | ||
back() { | ||
if (!this.i) return undefined; | ||
const e = this.m.p; | ||
return [ e.u, e.o ]; | ||
if (!this.I) return undefined; | ||
const e = this._.l; | ||
return [ e.h, e.o ]; | ||
} | ||
@@ -762,16 +767,16 @@ forEach(e) { | ||
lowerBound(e) { | ||
const t = this.P(this.B, e); | ||
return new OrderedMapIterator(t, this.m); | ||
const t = this.C(this.B, e); | ||
return new OrderedMapIterator(t, this._); | ||
} | ||
upperBound(e) { | ||
const t = this.k(this.B, e); | ||
return new OrderedMapIterator(t, this.m); | ||
const t = this.P(this.B, e); | ||
return new OrderedMapIterator(t, this._); | ||
} | ||
reverseLowerBound(e) { | ||
const t = this.L(this.B, e); | ||
return new OrderedMapIterator(t, this.m); | ||
const t = this.k(this.B, e); | ||
return new OrderedMapIterator(t, this._); | ||
} | ||
reverseUpperBound(e) { | ||
const t = this.S(this.B, e); | ||
return new OrderedMapIterator(t, this.m); | ||
const t = this.L(this.B, e); | ||
return new OrderedMapIterator(t, this._); | ||
} | ||
@@ -784,3 +789,3 @@ setElement(e, t, i) { | ||
if (t !== undefined) { | ||
return new OrderedMapIterator(t, this.m); | ||
return new OrderedMapIterator(t, this._); | ||
} | ||
@@ -794,3 +799,3 @@ return this.end(); | ||
getElementByPos(e) { | ||
if (e < 0 || e > this.i - 1) { | ||
if (e < 0 || e > this.I - 1) { | ||
throw new RangeError; | ||
@@ -810,3 +815,6 @@ } | ||
union(e) { | ||
e.forEach((([e, t]) => this.setElement(e, t))); | ||
const t = this; | ||
e.forEach((function(e) { | ||
t.setElement(e[0], e[1]); | ||
})); | ||
} | ||
@@ -813,0 +821,0 @@ [Symbol.iterator]() { |
@@ -251,4 +251,4 @@ declare const enum IteratorType { | ||
/** | ||
* @description Remove the element of the specified _key. | ||
* @param key The _key you want to remove. | ||
* @description Remove the element of the specified key. | ||
* @param key The key you want to remove. | ||
*/ | ||
@@ -255,0 +255,0 @@ eraseElementByKey(key: K): void; |
@@ -43,12 +43,12 @@ var extendStatics = function(e, r) { | ||
} | ||
function step(a) { | ||
function step(f) { | ||
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]) { | ||
while (a && (a = 0, f[0] && (t = 0)), t) try { | ||
if (i = 1, n && (s = f[0] & 2 ? n["return"] : f[0] ? n["throw"] || ((s = n["return"]) && s.call(n), | ||
0) : n.next) && !(s = s.call(n, f[1])).done) return s; | ||
if (n = 0, s) f = [ f[0] & 2, s.value ]; | ||
switch (f[0]) { | ||
case 0: | ||
case 1: | ||
s = a; | ||
s = f; | ||
break; | ||
@@ -59,3 +59,3 @@ | ||
return { | ||
value: a[1], | ||
value: f[1], | ||
done: false | ||
@@ -66,8 +66,8 @@ }; | ||
t.label++; | ||
n = a[1]; | ||
a = [ 0 ]; | ||
n = f[1]; | ||
f = [ 0 ]; | ||
continue; | ||
case 7: | ||
a = t.ops.pop(); | ||
f = t.ops.pop(); | ||
t.trys.pop(); | ||
@@ -77,13 +77,13 @@ continue; | ||
default: | ||
if (!(s = t.trys, s = s.length > 0 && s[s.length - 1]) && (a[0] === 6 || a[0] === 2)) { | ||
if (!(s = t.trys, s = s.length > 0 && s[s.length - 1]) && (f[0] === 6 || f[0] === 2)) { | ||
t = 0; | ||
continue; | ||
} | ||
if (a[0] === 3 && (!s || a[1] > s[0] && a[1] < s[3])) { | ||
t.label = a[1]; | ||
if (f[0] === 3 && (!s || f[1] > s[0] && f[1] < s[3])) { | ||
t.label = f[1]; | ||
break; | ||
} | ||
if (a[0] === 6 && t.label < s[1]) { | ||
if (f[0] === 6 && t.label < s[1]) { | ||
t.label = s[1]; | ||
s = a; | ||
s = f; | ||
break; | ||
@@ -93,3 +93,3 @@ } | ||
t.label = s[2]; | ||
t.ops.push(a); | ||
t.ops.push(f); | ||
break; | ||
@@ -101,5 +101,5 @@ } | ||
} | ||
a = r.call(e, t); | ||
f = r.call(e, t); | ||
} catch (e) { | ||
a = [ 6, e ]; | ||
f = [ 6, e ]; | ||
n = 0; | ||
@@ -109,5 +109,5 @@ } finally { | ||
} | ||
if (a[0] & 5) throw a[1]; | ||
if (f[0] & 5) throw f[1]; | ||
return { | ||
value: a[0] ? a[1] : void 0, | ||
value: f[0] ? f[1] : void 0, | ||
done: true | ||
@@ -153,36 +153,6 @@ }; | ||
var ContainerIterator = function() { | ||
function ContainerIterator(e) { | ||
if (e === void 0) { | ||
e = 0; | ||
} | ||
this.iteratorType = e; | ||
} | ||
return ContainerIterator; | ||
}(); | ||
var Base = function() { | ||
function Base() { | ||
this.t = 0; | ||
} | ||
Base.prototype.size = function() { | ||
return this.t; | ||
}; | ||
Base.prototype.empty = function() { | ||
return this.t === 0; | ||
}; | ||
return Base; | ||
}(); | ||
var Container = function(e) { | ||
__extends(Container, e); | ||
function Container() { | ||
return e !== null && e.apply(this, arguments) || this; | ||
} | ||
return Container; | ||
}(Base); | ||
var TreeNode = function() { | ||
function TreeNode(e, r) { | ||
this.i = 1; | ||
this.t = 1; | ||
this.i = undefined; | ||
this.u = undefined; | ||
@@ -192,20 +162,19 @@ this.h = undefined; | ||
this.l = undefined; | ||
this.v = undefined; | ||
this.u = e; | ||
this.h = r; | ||
this.i = e; | ||
this.u = r; | ||
} | ||
TreeNode.prototype.pre = function() { | ||
var e = this; | ||
if (e.i === 1 && e.v.v === e) { | ||
e = e.l; | ||
} else if (e.o) { | ||
if (e.t === 1 && e.l.l === e) { | ||
e = e.o; | ||
while (e.l) { | ||
e = e.l; | ||
} else if (e.h) { | ||
e = e.h; | ||
while (e.o) { | ||
e = e.o; | ||
} | ||
} else { | ||
var r = e.v; | ||
while (r.o === e) { | ||
var r = e.l; | ||
while (r.h === e) { | ||
e = r; | ||
r = e.v; | ||
r = e.l; | ||
} | ||
@@ -218,15 +187,15 @@ e = r; | ||
var e = this; | ||
if (e.l) { | ||
e = e.l; | ||
while (e.o) { | ||
e = e.o; | ||
if (e.o) { | ||
e = e.o; | ||
while (e.h) { | ||
e = e.h; | ||
} | ||
return e; | ||
} else { | ||
var r = e.v; | ||
while (r.l === e) { | ||
var r = e.l; | ||
while (r.o === e) { | ||
e = r; | ||
r = e.v; | ||
r = e.l; | ||
} | ||
if (e.l !== r) { | ||
if (e.o !== r) { | ||
return r; | ||
@@ -237,23 +206,23 @@ } else return e; | ||
TreeNode.prototype.rotateLeft = function() { | ||
var e = this.v; | ||
var r = this.l; | ||
var t = r.o; | ||
if (e.v === this) e.v = r; else if (e.o === this) e.o = r; else e.l = r; | ||
r.v = e; | ||
r.o = this; | ||
this.v = r; | ||
this.l = t; | ||
if (t) t.v = this; | ||
var e = this.l; | ||
var r = this.o; | ||
var t = r.h; | ||
if (e.l === this) e.l = r; else if (e.h === this) e.h = r; else e.o = r; | ||
r.l = e; | ||
r.h = this; | ||
this.l = r; | ||
this.o = t; | ||
if (t) t.l = this; | ||
return r; | ||
}; | ||
TreeNode.prototype.rotateRight = function() { | ||
var e = this.v; | ||
var r = this.o; | ||
var t = r.l; | ||
if (e.v === this) e.v = r; else if (e.o === this) e.o = r; else e.l = r; | ||
r.v = e; | ||
r.l = this; | ||
this.v = r; | ||
this.o = t; | ||
if (t) t.v = this; | ||
var e = this.l; | ||
var r = this.h; | ||
var t = r.o; | ||
if (e.l === this) e.l = r; else if (e.h === this) e.h = r; else e.o = r; | ||
r.l = e; | ||
r.o = this; | ||
this.l = r; | ||
this.h = t; | ||
if (t) t.l = this; | ||
return r; | ||
@@ -268,6 +237,6 @@ }; | ||
var r = e !== null && e.apply(this, arguments) || this; | ||
r.h = undefined; | ||
r.o = undefined; | ||
r.l = undefined; | ||
r.v = undefined; | ||
r.p = 1; | ||
r.v = 1; | ||
return r; | ||
@@ -288,5 +257,5 @@ } | ||
TreeNodeEnableIndex.prototype.recount = function() { | ||
this.p = 1; | ||
if (this.o) this.p += this.o.p; | ||
if (this.l) this.p += this.l.p; | ||
this.v = 1; | ||
if (this.h) this.v += this.h.v; | ||
if (this.o) this.v += this.o.v; | ||
}; | ||
@@ -296,2 +265,33 @@ return TreeNodeEnableIndex; | ||
var ContainerIterator = function() { | ||
function ContainerIterator(e) { | ||
if (e === void 0) { | ||
e = 0; | ||
} | ||
this.iteratorType = e; | ||
} | ||
return ContainerIterator; | ||
}(); | ||
var Base = function() { | ||
function Base() { | ||
this.p = 0; | ||
} | ||
Base.prototype.size = function() { | ||
return this.p; | ||
}; | ||
Base.prototype.empty = function() { | ||
return this.p === 0; | ||
}; | ||
return Base; | ||
}(); | ||
var Container = function(e) { | ||
__extends(Container, e); | ||
function Container() { | ||
return e !== null && e.apply(this, arguments) || this; | ||
} | ||
return Container; | ||
}(Base); | ||
var TreeContainer = function(e) { | ||
@@ -312,25 +312,18 @@ __extends(TreeContainer, e); | ||
i.T = undefined; | ||
i._ = function(e, r) { | ||
if (e === undefined) return false; | ||
var t = i._(e.o, r); | ||
if (t) return true; | ||
if (r(e)) return true; | ||
return i._(e.l, r); | ||
}; | ||
i.O = r; | ||
if (t) { | ||
i.M = TreeNodeEnableIndex; | ||
i.I = function(e, r, t) { | ||
var i = this.C(e, r, t); | ||
i._ = TreeNodeEnableIndex; | ||
i.M = function(e, r, t) { | ||
var i = this.I(e, r, t); | ||
if (i) { | ||
var n = i.v; | ||
while (n !== this.N) { | ||
n.p += 1; | ||
n = n.v; | ||
var n = i.l; | ||
while (n !== this.C) { | ||
n.v += 1; | ||
n = n.l; | ||
} | ||
var s = this.g(i); | ||
var s = this.N(i); | ||
if (s) { | ||
var a = s, u = a.parentNode, f = a.grandParent, h = a.curNode; | ||
var a = s, f = a.parentNode, u = a.grandParent, h = a.curNode; | ||
f.recount(); | ||
u.recount(); | ||
f.recount(); | ||
h.recount(); | ||
@@ -340,85 +333,85 @@ } | ||
}; | ||
i.S = function(e) { | ||
var r = this.m(e); | ||
while (r !== this.N) { | ||
r.p -= 1; | ||
r = r.v; | ||
i.g = function(e) { | ||
var r = this.S(e); | ||
while (r !== this.C) { | ||
r.v -= 1; | ||
r = r.l; | ||
} | ||
}; | ||
} else { | ||
i.M = TreeNode; | ||
i.I = function(e, r, t) { | ||
var i = this.C(e, r, t); | ||
if (i) this.g(i); | ||
i._ = TreeNode; | ||
i.M = function(e, r, t) { | ||
var i = this.I(e, r, t); | ||
if (i) this.N(i); | ||
}; | ||
i.S = i.m; | ||
i.g = i.S; | ||
} | ||
i.N = new i.M; | ||
i.C = new i._; | ||
return i; | ||
} | ||
TreeContainer.prototype.R = function(e, r) { | ||
TreeContainer.prototype.m = function(e, r) { | ||
var t; | ||
while (e) { | ||
var i = this.O(e.u, r); | ||
var i = this.O(e.i, r); | ||
if (i < 0) { | ||
e = e.l; | ||
e = e.o; | ||
} else if (i > 0) { | ||
t = e; | ||
e = e.o; | ||
e = e.h; | ||
} else return e; | ||
} | ||
return t === undefined ? this.N : t; | ||
return t === undefined ? this.C : t; | ||
}; | ||
TreeContainer.prototype.k = function(e, r) { | ||
TreeContainer.prototype.R = function(e, r) { | ||
var t; | ||
while (e) { | ||
var i = this.O(e.u, r); | ||
var i = this.O(e.i, r); | ||
if (i <= 0) { | ||
e = e.l; | ||
e = e.o; | ||
} else { | ||
t = e; | ||
e = e.o; | ||
e = e.h; | ||
} | ||
} | ||
return t === undefined ? this.N : t; | ||
return t === undefined ? this.C : t; | ||
}; | ||
TreeContainer.prototype.j = function(e, r) { | ||
TreeContainer.prototype.k = function(e, r) { | ||
var t; | ||
while (e) { | ||
var i = this.O(e.u, r); | ||
var i = this.O(e.i, r); | ||
if (i < 0) { | ||
t = e; | ||
e = e.l; | ||
e = e.o; | ||
} else if (i > 0) { | ||
e = e.o; | ||
e = e.h; | ||
} else return e; | ||
} | ||
return t === undefined ? this.N : t; | ||
return t === undefined ? this.C : t; | ||
}; | ||
TreeContainer.prototype.B = function(e, r) { | ||
TreeContainer.prototype.j = function(e, r) { | ||
var t; | ||
while (e) { | ||
var i = this.O(e.u, r); | ||
var i = this.O(e.i, r); | ||
if (i < 0) { | ||
t = e; | ||
e = e.l; | ||
e = e.o; | ||
} else { | ||
e = e.o; | ||
e = e.h; | ||
} | ||
} | ||
return t === undefined ? this.N : t; | ||
return t === undefined ? this.C : t; | ||
}; | ||
TreeContainer.prototype.P = function(e) { | ||
TreeContainer.prototype.B = function(e) { | ||
while (true) { | ||
var r = e.v; | ||
if (r === this.N) return; | ||
if (e.i === 1) { | ||
e.i = 0; | ||
var r = e.l; | ||
if (r === this.C) return; | ||
if (e.t === 1) { | ||
e.t = 0; | ||
return; | ||
} | ||
if (e === r.o) { | ||
var t = r.l; | ||
if (t.i === 1) { | ||
t.i = 0; | ||
r.i = 1; | ||
if (e === r.h) { | ||
var t = r.o; | ||
if (t.t === 1) { | ||
t.t = 0; | ||
r.t = 1; | ||
if (r === this.T) { | ||
@@ -428,6 +421,6 @@ this.T = r.rotateLeft(); | ||
} else { | ||
if (t.l && t.l.i === 1) { | ||
t.i = r.i; | ||
r.i = 0; | ||
t.l.i = 0; | ||
if (t.o && t.o.t === 1) { | ||
t.t = r.t; | ||
r.t = 0; | ||
t.o.t = 0; | ||
if (r === this.T) { | ||
@@ -437,8 +430,8 @@ this.T = r.rotateLeft(); | ||
return; | ||
} else if (t.o && t.o.i === 1) { | ||
t.i = 1; | ||
t.o.i = 0; | ||
} else if (t.h && t.h.t === 1) { | ||
t.t = 1; | ||
t.h.t = 0; | ||
t.rotateRight(); | ||
} else { | ||
t.i = 1; | ||
t.t = 1; | ||
e = r; | ||
@@ -448,6 +441,6 @@ } | ||
} else { | ||
var t = r.o; | ||
if (t.i === 1) { | ||
t.i = 0; | ||
r.i = 1; | ||
var t = r.h; | ||
if (t.t === 1) { | ||
t.t = 0; | ||
r.t = 1; | ||
if (r === this.T) { | ||
@@ -457,6 +450,6 @@ this.T = r.rotateRight(); | ||
} else { | ||
if (t.o && t.o.i === 1) { | ||
t.i = r.i; | ||
r.i = 0; | ||
t.o.i = 0; | ||
if (t.h && t.h.t === 1) { | ||
t.t = r.t; | ||
r.t = 0; | ||
t.h.t = 0; | ||
if (r === this.T) { | ||
@@ -466,8 +459,8 @@ this.T = r.rotateRight(); | ||
return; | ||
} else if (t.l && t.l.i === 1) { | ||
t.i = 1; | ||
t.l.i = 0; | ||
} else if (t.o && t.o.t === 1) { | ||
t.t = 1; | ||
t.o.t = 0; | ||
t.rotateLeft(); | ||
} else { | ||
t.i = 1; | ||
t.t = 1; | ||
e = r; | ||
@@ -479,68 +472,75 @@ } | ||
}; | ||
TreeContainer.prototype.m = function(e) { | ||
TreeContainer.prototype.S = function(e) { | ||
var r, t; | ||
if (this.t === 1) { | ||
if (this.p === 1) { | ||
this.clear(); | ||
return this.N; | ||
return this.C; | ||
} | ||
var i = e; | ||
while (i.o || i.l) { | ||
if (i.l) { | ||
i = i.l; | ||
while (i.o) i = i.o; | ||
while (i.h || i.o) { | ||
if (i.o) { | ||
i = i.o; | ||
while (i.h) i = i.h; | ||
} else { | ||
i = i.o; | ||
i = i.h; | ||
} | ||
r = __read([ i.u, e.u ], 2), e.u = r[0], i.u = r[1]; | ||
t = __read([ i.h, e.h ], 2), e.h = t[0], i.h = t[1]; | ||
r = __read([ i.i, e.i ], 2), e.i = r[0], i.i = r[1]; | ||
t = __read([ i.u, e.u ], 2), e.u = t[0], i.u = t[1]; | ||
e = i; | ||
} | ||
if (this.N.o === i) { | ||
this.N.o = i.v; | ||
} else if (this.N.l === i) { | ||
this.N.l = i.v; | ||
if (this.C.h === i) { | ||
this.C.h = i.l; | ||
} else if (this.C.o === i) { | ||
this.C.o = i.l; | ||
} | ||
this.P(i); | ||
var n = i.v; | ||
if (i === n.o) { | ||
n.o = undefined; | ||
} else n.l = undefined; | ||
this.t -= 1; | ||
this.T.i = 0; | ||
this.B(i); | ||
var n = i.l; | ||
if (i === n.h) { | ||
n.h = undefined; | ||
} else n.o = undefined; | ||
this.p -= 1; | ||
this.T.t = 0; | ||
return n; | ||
}; | ||
TreeContainer.prototype.g = function(e) { | ||
TreeContainer.prototype.P = function(e, r) { | ||
if (e === undefined) return false; | ||
var t = this.P(e.h, r); | ||
if (t) return true; | ||
if (r(e)) return true; | ||
return this.P(e.o, r); | ||
}; | ||
TreeContainer.prototype.N = function(e) { | ||
while (true) { | ||
var r = e.v; | ||
if (r.i === 0) return; | ||
var t = r.v; | ||
if (r === t.o) { | ||
var i = t.l; | ||
if (i && i.i === 1) { | ||
i.i = r.i = 0; | ||
var r = e.l; | ||
if (r.t === 0) return; | ||
var t = r.l; | ||
if (r === t.h) { | ||
var i = t.o; | ||
if (i && i.t === 1) { | ||
i.t = r.t = 0; | ||
if (t === this.T) return; | ||
t.i = 1; | ||
t.t = 1; | ||
e = t; | ||
continue; | ||
} else if (e === r.l) { | ||
e.i = 0; | ||
if (e.o) e.o.v = r; | ||
if (e.l) e.l.v = t; | ||
r.l = e.o; | ||
t.o = e.l; | ||
e.o = r; | ||
e.l = t; | ||
} else if (e === r.o) { | ||
e.t = 0; | ||
if (e.h) e.h.l = r; | ||
if (e.o) e.o.l = t; | ||
r.o = e.h; | ||
t.h = e.o; | ||
e.h = r; | ||
e.o = t; | ||
if (t === this.T) { | ||
this.T = e; | ||
this.N.v = e; | ||
this.C.l = e; | ||
} else { | ||
var n = t.v; | ||
if (n.o === t) { | ||
n.o = e; | ||
} else n.l = e; | ||
var n = t.l; | ||
if (n.h === t) { | ||
n.h = e; | ||
} else n.o = e; | ||
} | ||
e.v = t.v; | ||
r.v = e; | ||
t.v = e; | ||
t.i = 1; | ||
e.l = t.l; | ||
r.l = e; | ||
t.l = e; | ||
t.t = 1; | ||
return { | ||
@@ -552,37 +552,37 @@ parentNode: r, | ||
} else { | ||
r.i = 0; | ||
r.t = 0; | ||
if (t === this.T) { | ||
this.T = t.rotateRight(); | ||
} else t.rotateRight(); | ||
t.i = 1; | ||
t.t = 1; | ||
} | ||
} else { | ||
var i = t.o; | ||
if (i && i.i === 1) { | ||
i.i = r.i = 0; | ||
var i = t.h; | ||
if (i && i.t === 1) { | ||
i.t = r.t = 0; | ||
if (t === this.T) return; | ||
t.i = 1; | ||
t.t = 1; | ||
e = t; | ||
continue; | ||
} else if (e === r.o) { | ||
e.i = 0; | ||
if (e.o) e.o.v = t; | ||
if (e.l) e.l.v = r; | ||
t.l = e.o; | ||
r.o = e.l; | ||
e.o = t; | ||
e.l = r; | ||
} else if (e === r.h) { | ||
e.t = 0; | ||
if (e.h) e.h.l = t; | ||
if (e.o) e.o.l = r; | ||
t.o = e.h; | ||
r.h = e.o; | ||
e.h = t; | ||
e.o = r; | ||
if (t === this.T) { | ||
this.T = e; | ||
this.N.v = e; | ||
this.C.l = e; | ||
} else { | ||
var n = t.v; | ||
if (n.o === t) { | ||
n.o = e; | ||
} else n.l = e; | ||
var n = t.l; | ||
if (n.h === t) { | ||
n.h = e; | ||
} else n.o = e; | ||
} | ||
e.v = t.v; | ||
r.v = e; | ||
t.v = e; | ||
t.i = 1; | ||
e.l = t.l; | ||
r.l = e; | ||
t.l = e; | ||
t.t = 1; | ||
return { | ||
@@ -594,7 +594,7 @@ parentNode: r, | ||
} else { | ||
r.i = 0; | ||
r.t = 0; | ||
if (t === this.T) { | ||
this.T = t.rotateLeft(); | ||
} else t.rotateLeft(); | ||
t.i = 1; | ||
t.t = 1; | ||
} | ||
@@ -605,57 +605,57 @@ } | ||
}; | ||
TreeContainer.prototype.C = function(e, r, t) { | ||
TreeContainer.prototype.I = function(e, r, t) { | ||
if (this.T === undefined) { | ||
this.t += 1; | ||
this.T = new this.M(e, r); | ||
this.T.i = 0; | ||
this.T.v = this.N; | ||
this.N.v = this.T; | ||
this.N.o = this.T; | ||
this.N.l = this.T; | ||
this.p += 1; | ||
this.T = new this._(e, r); | ||
this.T.t = 0; | ||
this.T.l = this.C; | ||
this.C.l = this.T; | ||
this.C.h = this.T; | ||
this.C.o = this.T; | ||
return; | ||
} | ||
var i; | ||
var n = this.N.o; | ||
var s = this.O(n.u, e); | ||
var n = this.C.h; | ||
var s = this.O(n.i, e); | ||
if (s === 0) { | ||
n.h = r; | ||
n.u = r; | ||
return; | ||
} else if (s > 0) { | ||
n.o = new this.M(e, r); | ||
n.o.v = n; | ||
i = n.o; | ||
this.N.o = i; | ||
n.h = new this._(e, r); | ||
n.h.l = n; | ||
i = n.h; | ||
this.C.h = i; | ||
} else { | ||
var a = this.N.l; | ||
var u = this.O(a.u, e); | ||
if (u === 0) { | ||
a.h = r; | ||
var a = this.C.o; | ||
var f = this.O(a.i, e); | ||
if (f === 0) { | ||
a.u = r; | ||
return; | ||
} else if (u < 0) { | ||
a.l = new this.M(e, r); | ||
a.l.v = a; | ||
i = a.l; | ||
this.N.l = i; | ||
} else if (f < 0) { | ||
a.o = new this._(e, r); | ||
a.o.l = a; | ||
i = a.o; | ||
this.C.o = i; | ||
} else { | ||
if (t !== undefined) { | ||
var f = t.A; | ||
if (f !== this.N) { | ||
var h = this.O(f.u, e); | ||
var u = t.A; | ||
if (u !== this.C) { | ||
var h = this.O(u.i, e); | ||
if (h === 0) { | ||
f.h = r; | ||
u.u = r; | ||
return; | ||
} else if (h > 0) { | ||
var o = f.pre(); | ||
var d = this.O(o.u, e); | ||
var o = u.pre(); | ||
var d = this.O(o.i, e); | ||
if (d === 0) { | ||
o.h = r; | ||
o.u = r; | ||
return; | ||
} else if (d < 0) { | ||
i = new this.M(e, r); | ||
if (o.l === undefined) { | ||
o.l = i; | ||
i.v = o; | ||
i = new this._(e, r); | ||
if (o.o === undefined) { | ||
o.o = i; | ||
i.l = o; | ||
} else { | ||
f.o = i; | ||
i.v = f; | ||
u.h = i; | ||
i.l = u; | ||
} | ||
@@ -669,7 +669,15 @@ } | ||
while (true) { | ||
var c = this.O(i.u, e); | ||
var c = this.O(i.i, e); | ||
if (c > 0) { | ||
if (i.h === undefined) { | ||
i.h = new this._(e, r); | ||
i.h.l = i; | ||
i = i.h; | ||
break; | ||
} | ||
i = i.h; | ||
} else if (c < 0) { | ||
if (i.o === undefined) { | ||
i.o = new this.M(e, r); | ||
i.o.v = i; | ||
i.o = new this._(e, r); | ||
i.o.l = i; | ||
i = i.o; | ||
@@ -679,12 +687,4 @@ break; | ||
i = i.o; | ||
} else if (c < 0) { | ||
if (i.l === undefined) { | ||
i.l = new this.M(e, r); | ||
i.l.v = i; | ||
i = i.l; | ||
break; | ||
} | ||
i = i.l; | ||
} else { | ||
i.h = r; | ||
i.u = r; | ||
return; | ||
@@ -696,23 +696,23 @@ } | ||
} | ||
this.t += 1; | ||
this.p += 1; | ||
return i; | ||
}; | ||
TreeContainer.prototype.clear = function() { | ||
this.t = 0; | ||
this.p = 0; | ||
this.T = undefined; | ||
this.N.v = undefined; | ||
this.N.o = this.N.l = undefined; | ||
this.C.l = undefined; | ||
this.C.h = this.C.o = undefined; | ||
}; | ||
TreeContainer.prototype.updateKeyByIterator = function(e, r) { | ||
var t = e.A; | ||
if (t === this.N) { | ||
if (t === this.C) { | ||
throw new TypeError("Invalid iterator!"); | ||
} | ||
if (this.t === 1) { | ||
t.u = r; | ||
if (this.p === 1) { | ||
t.i = r; | ||
return true; | ||
} | ||
if (t === this.N.o) { | ||
if (this.O(t.next().u, r) > 0) { | ||
t.u = r; | ||
if (t === this.C.h) { | ||
if (this.O(t.next().i, r) > 0) { | ||
t.i = r; | ||
return true; | ||
@@ -722,5 +722,5 @@ } | ||
} | ||
if (t === this.N.l) { | ||
if (this.O(t.pre().u, r) < 0) { | ||
t.u = r; | ||
if (t === this.C.o) { | ||
if (this.O(t.pre().i, r) < 0) { | ||
t.i = r; | ||
return true; | ||
@@ -730,21 +730,21 @@ } | ||
} | ||
var i = t.pre().u; | ||
var i = t.pre().i; | ||
if (this.O(i, r) >= 0) return false; | ||
var n = t.next().u; | ||
var n = t.next().i; | ||
if (this.O(n, r) <= 0) return false; | ||
t.u = r; | ||
t.i = r; | ||
return true; | ||
}; | ||
TreeContainer.prototype.eraseElementByPos = function(e) { | ||
var r = this; | ||
if (e < 0 || e > this.t - 1) { | ||
if (e < 0 || e > this.p - 1) { | ||
throw new RangeError; | ||
} | ||
var t = 0; | ||
this._(this.T, (function(i) { | ||
if (e === t) { | ||
r.S(i); | ||
var r = 0; | ||
var t = this; | ||
this.P(this.T, (function(i) { | ||
if (e === r) { | ||
t.g(i); | ||
return true; | ||
} | ||
t += 1; | ||
r += 1; | ||
return false; | ||
@@ -755,7 +755,7 @@ })); | ||
while (e) { | ||
var t = this.O(e.u, r); | ||
var t = this.O(e.i, r); | ||
if (t < 0) { | ||
e = e.l; | ||
e = e.o; | ||
} else if (t > 0) { | ||
e = e.o; | ||
e = e.h; | ||
} else return e; | ||
@@ -766,23 +766,23 @@ } | ||
TreeContainer.prototype.eraseElementByKey = function(e) { | ||
if (!this.t) return; | ||
if (!this.p) return; | ||
var r = this.G(this.T, e); | ||
if (r === undefined) return; | ||
this.S(r); | ||
this.g(r); | ||
}; | ||
TreeContainer.prototype.eraseElementByIterator = function(e) { | ||
var r = e.A; | ||
if (r === this.N) { | ||
if (r === this.C) { | ||
throw new RangeError("Invalid iterator"); | ||
} | ||
if (r.l === undefined) { | ||
if (r.o === undefined) { | ||
e = e.next(); | ||
} | ||
this.S(r); | ||
this.g(r); | ||
return e; | ||
}; | ||
TreeContainer.prototype.getHeight = function() { | ||
if (!this.t) return 0; | ||
if (!this.p) return 0; | ||
var traversal = function(e) { | ||
if (!e) return 0; | ||
return Math.max(traversal(e.o), traversal(e.l)) + 1; | ||
return Math.max(traversal(e.h), traversal(e.o)) + 1; | ||
}; | ||
@@ -799,6 +799,6 @@ return traversal(this.T); | ||
n.A = r; | ||
n.N = t; | ||
n.C = t; | ||
if (n.iteratorType === 0) { | ||
n.pre = function() { | ||
if (this.A === this.N.o) { | ||
if (this.A === this.C.h) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
@@ -810,3 +810,3 @@ } | ||
n.next = function() { | ||
if (this.A === this.N) { | ||
if (this.A === this.C) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
@@ -819,3 +819,3 @@ } | ||
n.pre = function() { | ||
if (this.A === this.N.l) { | ||
if (this.A === this.C.o) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
@@ -827,3 +827,3 @@ } | ||
n.next = function() { | ||
if (this.A === this.N) { | ||
if (this.A === this.C) { | ||
throw new RangeError("Tree iterator access denied!"); | ||
@@ -840,6 +840,6 @@ } | ||
var e = this.A; | ||
var r = this.N.v; | ||
if (e === this.N) { | ||
var r = this.C.l; | ||
if (e === this.C) { | ||
if (r) { | ||
return r.p - 1; | ||
return r.v - 1; | ||
} | ||
@@ -849,11 +849,11 @@ return 0; | ||
var t = 0; | ||
if (e.o) { | ||
t += e.o.p; | ||
if (e.h) { | ||
t += e.h.v; | ||
} | ||
while (e !== r) { | ||
var i = e.v; | ||
if (e === i.l) { | ||
var i = e.l; | ||
if (e === i.o) { | ||
t += 1; | ||
if (i.o) { | ||
t += i.o.p; | ||
if (i.h) { | ||
t += i.h.v; | ||
} | ||
@@ -881,9 +881,9 @@ } | ||
get: function() { | ||
var e = this; | ||
if (this.A === this.N) { | ||
if (this.A === this.C) { | ||
throw new RangeError("OrderedMap iterator access denied"); | ||
} | ||
var e = this; | ||
return new Proxy([], { | ||
get: function(r, t) { | ||
if (t === "0") return e.A.u; else if (t === "1") return e.A.h; | ||
if (t === "0") return e.A.i; else if (t === "1") return e.A.u; | ||
}, | ||
@@ -894,3 +894,3 @@ set: function(r, t, i) { | ||
} | ||
e.A.h = i; | ||
e.A.u = i; | ||
return true; | ||
@@ -904,3 +904,3 @@ } | ||
OrderedMapIterator.prototype.copy = function() { | ||
return new OrderedMapIterator(this.A, this.N, this.iteratorType); | ||
return new OrderedMapIterator(this.A, this.C, this.iteratorType); | ||
}; | ||
@@ -917,50 +917,50 @@ return OrderedMapIterator; | ||
var n = e.call(this, t, i) || this; | ||
n.q = function(e) { | ||
return __generator(this, (function(r) { | ||
switch (r.label) { | ||
case 0: | ||
if (e === undefined) return [ 2 ]; | ||
return [ 5, __values(this.q(e.o)) ]; | ||
var s = n; | ||
r.forEach((function(e) { | ||
s.setElement(e[0], e[1]); | ||
})); | ||
return n; | ||
} | ||
OrderedMap.prototype.q = function(e) { | ||
return __generator(this, (function(r) { | ||
switch (r.label) { | ||
case 0: | ||
if (e === undefined) return [ 2 ]; | ||
return [ 5, __values(this.q(e.h)) ]; | ||
case 1: | ||
r.sent(); | ||
return [ 4, [ e.u, e.h ] ]; | ||
case 1: | ||
r.sent(); | ||
return [ 4, [ e.i, e.u ] ]; | ||
case 2: | ||
r.sent(); | ||
return [ 5, __values(this.q(e.l)) ]; | ||
case 2: | ||
r.sent(); | ||
return [ 5, __values(this.q(e.o)) ]; | ||
case 3: | ||
r.sent(); | ||
return [ 2 ]; | ||
} | ||
})); | ||
}; | ||
r.forEach((function(e) { | ||
var r = __read(e, 2), t = r[0], i = r[1]; | ||
return n.setElement(t, i); | ||
case 3: | ||
r.sent(); | ||
return [ 2 ]; | ||
} | ||
})); | ||
return n; | ||
} | ||
}; | ||
OrderedMap.prototype.begin = function() { | ||
return new OrderedMapIterator(this.N.o || this.N, this.N); | ||
return new OrderedMapIterator(this.C.h || this.C, this.C); | ||
}; | ||
OrderedMap.prototype.end = function() { | ||
return new OrderedMapIterator(this.N, this.N); | ||
return new OrderedMapIterator(this.C, this.C); | ||
}; | ||
OrderedMap.prototype.rBegin = function() { | ||
return new OrderedMapIterator(this.N.l || this.N, this.N, 1); | ||
return new OrderedMapIterator(this.C.o || this.C, this.C, 1); | ||
}; | ||
OrderedMap.prototype.rEnd = function() { | ||
return new OrderedMapIterator(this.N, this.N, 1); | ||
return new OrderedMapIterator(this.C, this.C, 1); | ||
}; | ||
OrderedMap.prototype.front = function() { | ||
if (!this.t) return undefined; | ||
var e = this.N.o; | ||
return [ e.u, e.h ]; | ||
if (!this.p) return undefined; | ||
var e = this.C.h; | ||
return [ e.i, e.u ]; | ||
}; | ||
OrderedMap.prototype.back = function() { | ||
if (!this.t) return undefined; | ||
var e = this.N.l; | ||
return [ e.u, e.h ]; | ||
if (!this.p) return undefined; | ||
var e = this.C.o; | ||
return [ e.i, e.u ]; | ||
}; | ||
@@ -988,19 +988,19 @@ OrderedMap.prototype.forEach = function(e) { | ||
OrderedMap.prototype.lowerBound = function(e) { | ||
var r = this.R(this.T, e); | ||
return new OrderedMapIterator(r, this.N); | ||
var r = this.m(this.T, e); | ||
return new OrderedMapIterator(r, this.C); | ||
}; | ||
OrderedMap.prototype.upperBound = function(e) { | ||
var r = this.k(this.T, e); | ||
return new OrderedMapIterator(r, this.N); | ||
var r = this.R(this.T, e); | ||
return new OrderedMapIterator(r, this.C); | ||
}; | ||
OrderedMap.prototype.reverseLowerBound = function(e) { | ||
var r = this.j(this.T, e); | ||
return new OrderedMapIterator(r, this.N); | ||
var r = this.k(this.T, e); | ||
return new OrderedMapIterator(r, this.C); | ||
}; | ||
OrderedMap.prototype.reverseUpperBound = function(e) { | ||
var r = this.B(this.T, e); | ||
return new OrderedMapIterator(r, this.N); | ||
var r = this.j(this.T, e); | ||
return new OrderedMapIterator(r, this.C); | ||
}; | ||
OrderedMap.prototype.setElement = function(e, r, t) { | ||
this.I(e, r, t); | ||
this.M(e, r, t); | ||
}; | ||
@@ -1010,3 +1010,3 @@ OrderedMap.prototype.find = function(e) { | ||
if (r !== undefined) { | ||
return new OrderedMapIterator(r, this.N); | ||
return new OrderedMapIterator(r, this.C); | ||
} | ||
@@ -1017,7 +1017,7 @@ return this.end(); | ||
var r = this.G(this.T, e); | ||
return r ? r.h : undefined; | ||
return r ? r.u : undefined; | ||
}; | ||
OrderedMap.prototype.getElementByPos = function(e) { | ||
var r, t; | ||
if (e < 0 || e > this.t - 1) { | ||
if (e < 0 || e > this.p - 1) { | ||
throw new RangeError; | ||
@@ -1029,5 +1029,5 @@ } | ||
for (var s = __values(this), a = s.next(); !a.done; a = s.next()) { | ||
var u = a.value; | ||
var f = a.value; | ||
if (n === e) { | ||
i = u; | ||
i = f; | ||
break; | ||
@@ -1053,4 +1053,3 @@ } | ||
e.forEach((function(e) { | ||
var t = __read(e, 2), i = t[0], n = t[1]; | ||
return r.setElement(i, n); | ||
r.setElement(e[0], e[1]); | ||
})); | ||
@@ -1057,0 +1056,0 @@ }; |
/*! | ||
* @js-sdsl/ordered-map v4.2.0-beta.0 | ||
* @js-sdsl/ordered-map v4.2.0-beta.1 | ||
* https://github.com/js-sdsl/js-sdsl | ||
@@ -76,3 +76,3 @@ * (c) 2021-present ZLY201 <zilongyao1366@gmail.com> | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -176,49 +176,4 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
var ContainerIterator = /** @class */function () { | ||
function ContainerIterator(iteratorType) { | ||
if (iteratorType === void 0) { | ||
iteratorType = 0 /* IteratorType.NORMAL */; | ||
} | ||
this.iteratorType = iteratorType; | ||
} | ||
return ContainerIterator; | ||
}(); | ||
var Base = /** @class */function () { | ||
function Base() { | ||
/** | ||
* @description Container's size. | ||
* @internal | ||
*/ | ||
this._length = 0; | ||
} | ||
/** | ||
* @return The size of the container. | ||
* @example | ||
* const container = new Vector([1, 2]); | ||
* console.log(container.size()); // 2 | ||
*/ | ||
Base.prototype.size = function () { | ||
return this._length; | ||
}; | ||
/** | ||
* @return Boolean about if the container is empty. | ||
* @example | ||
* container.clear(); | ||
* console.log(container.empty()); // true | ||
*/ | ||
Base.prototype.empty = function () { | ||
return this._length === 0; | ||
}; | ||
return Base; | ||
}(); | ||
var Container = /** @class */function (_super) { | ||
__extends(Container, _super); | ||
function Container() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return Container; | ||
}(Base); | ||
var TreeNode = /** @class */function () { | ||
function TreeNode(_key, _value) { | ||
function TreeNode(key, value) { | ||
/** | ||
@@ -248,4 +203,4 @@ * @internal | ||
this._parent = undefined; | ||
this._key = _key; | ||
this._value = _value; | ||
this._key = key; | ||
this._value = value; | ||
} | ||
@@ -382,2 +337,47 @@ /** | ||
var ContainerIterator = /** @class */function () { | ||
function ContainerIterator(iteratorType) { | ||
if (iteratorType === void 0) { | ||
iteratorType = 0 /* IteratorType.NORMAL */; | ||
} | ||
this.iteratorType = iteratorType; | ||
} | ||
return ContainerIterator; | ||
}(); | ||
var Base = /** @class */function () { | ||
function Base() { | ||
/** | ||
* @description Container's size. | ||
* @internal | ||
*/ | ||
this._length = 0; | ||
} | ||
/** | ||
* @return The size of the container. | ||
* @example | ||
* const container = new Vector([1, 2]); | ||
* console.log(container.size()); // 2 | ||
*/ | ||
Base.prototype.size = function () { | ||
return this._length; | ||
}; | ||
/** | ||
* @return Boolean about if the container is empty. | ||
* @example | ||
* container.clear(); | ||
* console.log(container.empty()); // true | ||
*/ | ||
Base.prototype.empty = function () { | ||
return this._length === 0; | ||
}; | ||
return Base; | ||
}(); | ||
var Container = /** @class */function (_super) { | ||
__extends(Container, _super); | ||
function Container() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return Container; | ||
}(Base); | ||
var TreeContainer = /** @class */function (_super) { | ||
@@ -405,18 +405,7 @@ __extends(TreeContainer, _super); | ||
_this._root = undefined; | ||
/** | ||
* @description InOrder traversal the tree. | ||
* @internal | ||
*/ | ||
_this._inOrderTraversal = function (curNode, callback) { | ||
if (curNode === undefined) return false; | ||
var ifReturn = _this._inOrderTraversal(curNode._left, callback); | ||
if (ifReturn) return true; | ||
if (callback(curNode)) return true; | ||
return _this._inOrderTraversal(curNode._right, callback); | ||
}; | ||
_this._cmp = cmp; | ||
if (enableIndex) { | ||
_this._TreeNodeClass = TreeNodeEnableIndex; | ||
_this._set = function (_key, _value, hint) { | ||
var curNode = this._preSet(_key, _value, hint); | ||
_this._set = function (key, value, hint) { | ||
var curNode = this._preSet(key, value, hint); | ||
if (curNode) { | ||
@@ -461,3 +450,3 @@ var p = curNode._parent; | ||
* @param key The key you want to search. | ||
* @return TreeNode which _key is greater than or equals to the given key. | ||
* @return TreeNode which key is greater than or equals to the given key. | ||
* @internal | ||
@@ -481,3 +470,3 @@ */ | ||
* @param key The key you want to search. | ||
* @return TreeNode which _key is greater than the given key. | ||
* @return TreeNode which key is greater than the given key. | ||
* @internal | ||
@@ -640,4 +629,15 @@ */ | ||
/** | ||
* @description InOrder traversal the tree. | ||
* @internal | ||
*/ | ||
TreeContainer.prototype._inOrderTraversal = function (curNode, callback) { | ||
if (curNode === undefined) return false; | ||
var ifReturn = this._inOrderTraversal(curNode._left, callback); | ||
if (ifReturn) return true; | ||
if (callback(curNode)) return true; | ||
return this._inOrderTraversal(curNode._right, callback); | ||
}; | ||
/** | ||
* @internal | ||
*/ | ||
TreeContainer.prototype._insertNodeSelfBalance = function (curNode) { | ||
@@ -738,6 +738,6 @@ while (true) { | ||
*/ | ||
TreeContainer.prototype._preSet = function (key, _value, hint) { | ||
TreeContainer.prototype._preSet = function (key, value, hint) { | ||
if (this._root === undefined) { | ||
this._length += 1; | ||
this._root = new this._TreeNodeClass(key, _value); | ||
this._root = new this._TreeNodeClass(key, value); | ||
this._root._color = 0 /* TreeNodeColor.BLACK */; | ||
@@ -754,6 +754,6 @@ this._root._parent = this._header; | ||
if (compareToMin === 0) { | ||
minNode._value = _value; | ||
minNode._value = value; | ||
return; | ||
} else if (compareToMin > 0) { | ||
minNode._left = new this._TreeNodeClass(key, _value); | ||
minNode._left = new this._TreeNodeClass(key, value); | ||
minNode._left._parent = minNode; | ||
@@ -766,6 +766,6 @@ curNode = minNode._left; | ||
if (compareToMax === 0) { | ||
maxNode._value = _value; | ||
maxNode._value = value; | ||
return; | ||
} else if (compareToMax < 0) { | ||
maxNode._right = new this._TreeNodeClass(key, _value); | ||
maxNode._right = new this._TreeNodeClass(key, value); | ||
maxNode._right._parent = maxNode; | ||
@@ -780,3 +780,3 @@ curNode = maxNode._right; | ||
if (iterCmpRes === 0) { | ||
iterNode._value = _value; | ||
iterNode._value = value; | ||
return; | ||
@@ -787,6 +787,6 @@ } else /* istanbul ignore else */if (iterCmpRes > 0) { | ||
if (preCmpRes === 0) { | ||
preNode._value = _value; | ||
preNode._value = value; | ||
return; | ||
} else if (preCmpRes < 0) { | ||
curNode = new this._TreeNodeClass(key, _value); | ||
curNode = new this._TreeNodeClass(key, value); | ||
if (preNode._right === undefined) { | ||
@@ -809,3 +809,3 @@ preNode._right = curNode; | ||
if (curNode._left === undefined) { | ||
curNode._left = new this._TreeNodeClass(key, _value); | ||
curNode._left = new this._TreeNodeClass(key, value); | ||
curNode._left._parent = curNode; | ||
@@ -818,3 +818,3 @@ curNode = curNode._left; | ||
if (curNode._right === undefined) { | ||
curNode._right = new this._TreeNodeClass(key, _value); | ||
curNode._right = new this._TreeNodeClass(key, value); | ||
curNode._right._parent = curNode; | ||
@@ -826,3 +826,3 @@ curNode = curNode._right; | ||
} else { | ||
curNode._value = _value; | ||
curNode._value = value; | ||
return; | ||
@@ -884,3 +884,2 @@ } | ||
TreeContainer.prototype.eraseElementByPos = function (pos) { | ||
var _this = this; | ||
if (pos < 0 || pos > this._length - 1) { | ||
@@ -890,5 +889,6 @@ throw new RangeError(); | ||
var index = 0; | ||
var self = this; | ||
this._inOrderTraversal(this._root, function (curNode) { | ||
if (pos === index) { | ||
_this._eraseNode(curNode); | ||
self._eraseNode(curNode); | ||
return true; | ||
@@ -918,4 +918,4 @@ } | ||
/** | ||
* @description Remove the element of the specified _key. | ||
* @param key The _key you want to remove. | ||
* @description Remove the element of the specified key. | ||
* @param key The key you want to remove. | ||
*/ | ||
@@ -1048,9 +1048,9 @@ TreeContainer.prototype.eraseElementByKey = function (key) { | ||
get: function () { | ||
var _this = this; | ||
if (this._node === this._header) { | ||
throw new RangeError('OrderedMap iterator access denied'); | ||
} | ||
var self = this; | ||
return new Proxy([], { | ||
get: function (_, props) { | ||
if (props === '0') return _this._node._key;else if (props === '1') return _this._node._value; | ||
if (props === '0') return self._node._key;else if (props === '1') return self._node._value; | ||
}, | ||
@@ -1061,3 +1061,3 @@ set: function (_, props, newValue) { | ||
} | ||
_this._node._value = newValue; | ||
self._node._value = newValue; | ||
return true; | ||
@@ -1092,32 +1092,30 @@ } | ||
var _this = _super.call(this, cmp, enableIndex) || this; | ||
/** | ||
* @internal | ||
*/ | ||
_this._iterationFunc = function (curNode) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (curNode === undefined) return [2 /*return*/]; | ||
return [5 /*yield**/, __values(this._iterationFunc(curNode._left))]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, [curNode._key, curNode._value]]; | ||
case 2: | ||
_a.sent(); | ||
return [5 /*yield**/, __values(this._iterationFunc(curNode._right))]; | ||
case 3: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
container.forEach(function (_a) { | ||
var _b = __read(_a, 2), | ||
_key = _b[0], | ||
_value = _b[1]; | ||
return _this.setElement(_key, _value); | ||
var self = _this; | ||
container.forEach(function (el) { | ||
self.setElement(el[0], el[1]); | ||
}); | ||
return _this; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
OrderedMap.prototype._iterationFunc = function (curNode) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (curNode === undefined) return [2 /*return*/]; | ||
return [5 /*yield**/, __values(this._iterationFunc(curNode._left))]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, [curNode._key, curNode._value]]; | ||
case 2: | ||
_a.sent(); | ||
return [5 /*yield**/, __values(this._iterationFunc(curNode._right))]; | ||
case 3: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
OrderedMap.prototype.begin = function () { | ||
@@ -1242,8 +1240,5 @@ return new OrderedMapIterator(this._header._left || this._header, this._header); | ||
OrderedMap.prototype.union = function (other) { | ||
var _this = this; | ||
other.forEach(function (_a) { | ||
var _b = __read(_a, 2), | ||
_key = _b[0], | ||
_value = _b[1]; | ||
return _this.setElement(_key, _value); | ||
var self = this; | ||
other.forEach(function (el) { | ||
self.setElement(el[0], el[1]); | ||
}); | ||
@@ -1250,0 +1245,0 @@ }; |
/*! | ||
* @js-sdsl/ordered-map v4.2.0-beta.0 | ||
* @js-sdsl/ordered-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 e=function(t,r){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,r){t.__proto__=r}:function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}))(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 i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}function o(e,o){var n,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(i){return function(t){var r=[i,t];if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=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=o.call(e,u)}catch(t){r=[6,t],s=0}finally{n=h=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}}}function u(t){var r="function"==typeof Symbol&&Symbol.iterator,i=r&&t[r],e=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&e>=t.length?void 0:t)&&t[e++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function n(t,r){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var e,o,n=i.call(t),s=[];try{for(;(void 0===r||0<r--)&&!(e=n.next()).done;)s.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(o)throw o.error}}return s}function i(t){this.iteratorType=t=void 0===t?0:t}function s(){this.t=0}s.prototype.size=function(){return this.t},s.prototype.empty=function(){return 0===this.t};r(a,h=s);var h,f=a;function a(){return null!==h&&h.apply(this,arguments)||this}p.prototype.pre=function(){var t=this;if(1===t.i&&t.v.v===t)t=t.l;else if(t.o)for(t=t.o;t.l;)t=t.l;else{for(var r=t.v;r.o===t;)r=(t=r).v;t=r}return t},p.prototype.next=function(){var t=this;if(t.l){for(t=t.l;t.o;)t=t.o;return t}for(var r=t.v;r.l===t;)r=(t=r).v;return t.l!==r?r:t},p.prototype.rotateLeft=function(){var t=this.v,r=this.l,i=r.o;return t.v===this?t.v=r:t.o===this?t.o=r:t.l=r,r.v=t,(r.o=this).v=r,(this.l=i)&&(i.v=this),r},p.prototype.rotateRight=function(){var t=this.v,r=this.o,i=r.l;return t.v===this?t.v=r:t.o===this?t.o=r:t.l=r,r.v=t,(r.l=this).v=r,(this.o=i)&&(i.v=this),r};var l=p;function p(t,r){this.i=1,this.u=void 0,this.h=void 0,this.o=void 0,this.l=void 0,this.v=void 0,this.u=t,this.h=r}r(y,v=l),y.prototype.rotateLeft=function(){var t=v.prototype.rotateLeft.call(this);return this.recount(),t.recount(),t},y.prototype.rotateRight=function(){var t=v.prototype.rotateRight.call(this);return this.recount(),t.recount(),t},y.prototype.recount=function(){this.p=1,this.o&&(this.p+=this.o.p),this.l&&(this.p+=this.l.p)};var v,c=y;function y(){var t=null!==v&&v.apply(this,arguments)||this;return t.o=void 0,t.l=void 0,t.v=void 0,t.p=1,t}r(I,d=f),I.prototype.j=function(t,r){for(var i;t;){var e=this.O(t.u,r);if(e<0)t=t.l;else{if(!(0<e))return t;t=(i=t).o}}return void 0===i?this.I:i},I.prototype.R=function(t,r){for(var i;t;)t=this.O(t.u,r)<=0?t.l:(i=t).o;return void 0===i?this.I:i},I.prototype.k=function(t,r){for(var i;t;){var e=this.O(t.u,r);if(e<0)t=(i=t).l;else{if(!(0<e))return t;t=t.o}}return void 0===i?this.I:i},I.prototype.B=function(t,r){for(var i;t;)t=this.O(t.u,r)<0?(i=t).l:t.o;return void 0===i?this.I:i},I.prototype.P=function(t){for(;;){var r,i=t.v;if(i===this.I)return;if(1===t.i)return void(t.i=0);if(t===i.o)if(1===(r=i.l).i)r.i=0,i.i=1,i===this._?this._=i.rotateLeft():i.rotateLeft();else{if(r.l&&1===r.l.i)return r.i=i.i,i.i=0,r.l.i=0,void(i===this._?this._=i.rotateLeft():i.rotateLeft());r.o&&1===r.o.i?(r.i=1,r.o.i=0,r.rotateRight()):(r.i=1,t=i)}else if(1===(r=i.o).i)r.i=0,i.i=1,i===this._?this._=i.rotateRight():i.rotateRight();else{if(r.o&&1===r.o.i)return r.i=i.i,i.i=0,r.o.i=0,void(i===this._?this._=i.rotateRight():i.rotateRight());r.l&&1===r.l.i?(r.i=1,r.l.i=0,r.rotateLeft()):(r.i=1,t=i)}}},I.prototype.S=function(t){var r;if(1===this.t)return this.clear(),this.I;for(var i=t;i.o||i.l;){if(i.l)for(i=i.l;i.o;)i=i.o;else i=i.o;r=n([i.u,t.u],2),t.u=r[0],i.u=r[1],r=n([i.h,t.h],2),t.h=r[0],i.h=r[1],t=i}this.I.o===i?this.I.o=i.v:this.I.l===i&&(this.I.l=i.v),this.P(i);var e=i.v;return i===e.o?e.o=void 0:e.l=void 0,--this.t,this._.i=0,e},I.prototype.N=function(t){for(;;){var r=t.v;if(0===r.i)return;var i,e,o=r.v;if(r===o.o){if((i=o.l)&&1===i.i){if(i.i=r.i=0,o===this._)return;o.i=1,t=o;continue}if(t===r.l)return t.i=0,t.o&&(t.o.v=r),t.l&&(t.l.v=o),r.l=t.o,o.o=t.l,t.o=r,(t.l=o)===this._?(this._=t,this.I.v=t):(e=o.v).o===o?e.o=t:e.l=t,t.v=o.v,r.v=t,o.v=t,o.i=1,{parentNode:r,grandParent:o,curNode:t};r.i=0,o===this._?this._=o.rotateRight():o.rotateRight()}else{if((i=o.o)&&1===i.i){if(i.i=r.i=0,o===this._)return;o.i=1,t=o;continue}if(t===r.o)return t.i=0,t.o&&(t.o.v=o),t.l&&(t.l.v=r),o.l=t.o,r.o=t.l,t.o=o,t.l=r,o===this._?(this._=t,this.I.v=t):(e=o.v).o===o?e.o=t:e.l=t,t.v=o.v,r.v=t,o.v=t,o.i=1,{parentNode:r,grandParent:o,curNode:t};r.i=0,o===this._?this._=o.rotateLeft():o.rotateLeft()}return void(o.i=1)}},I.prototype.g=function(t,r,i){if(void 0===this._)this.t+=1,this._=new this.M(t,r),this._.i=0,this._.v=this.I,this.I.v=this._,this.I.o=this._,this.I.l=this._;else{var e,o=this.I.o,n=this.O(o.u,t);if(0!==n){if(0<n)o.o=new this.M(t,r),e=(o.o.v=o).o,this.I.o=e;else{var n=this.I.l,s=this.O(n.u,t);if(0===s)return void(n.h=r);if(s<0)n.l=new this.M(t,r),e=(n.l.v=n).l,this.I.l=e;else{if(void 0!==i){s=i.A;if(s!==this.I){n=this.O(s.u,t);if(0===n)return void(s.h=r);if(0<n){i=s.pre(),n=this.O(i.u,t);if(0===n)return void(i.h=r);n<0&&(e=new this.M(t,r),void 0===i.l?(i.l=e).v=i:(s.o=e).v=s)}}}if(void 0===e)for(e=this._;;){var h=this.O(e.u,t);if(0<h){if(void 0===e.o){e.o=new this.M(t,r),e=(e.o.v=e).o;break}e=e.o}else{if(!(h<0))return void(e.h=r);if(void 0===e.l){e.l=new this.M(t,r),e=(e.l.v=e).l;break}e=e.l}}}}return this.t+=1,e}o.h=r}},I.prototype.clear=function(){this.t=0,this._=void 0,this.I.v=void 0,this.I.o=this.I.l=void 0},I.prototype.updateKeyByIterator=function(t,r){t=t.A;if(t===this.I)throw new TypeError("Invalid iterator!");if(1!==this.t){if(t===this.I.o)return 0<this.O(t.next().u,r)&&(t.u=r,!0);if(t===this.I.l)return this.O(t.pre().u,r)<0&&(t.u=r,!0);var i=t.pre().u;if(0<=this.O(i,r))return!1;if(i=t.next().u,this.O(i,r)<=0)return!1}return t.u=r,!0},I.prototype.eraseElementByPos=function(r){var i=this;if(r<0||r>this.t-1)throw new RangeError;var e=0;this.T(this._,function(t){return r===e?(i.m(t),!0):(e+=1,!1)})},I.prototype.G=function(t,r){for(;t;){var i=this.O(t.u,r);if(i<0)t=t.l;else{if(!(0<i))return t;t=t.o}}return t},I.prototype.eraseElementByKey=function(t){this.t&&void 0!==(t=this.G(this._,t))&&this.m(t)},I.prototype.eraseElementByIterator=function(t){var r=t.A;if(r===this.I)throw new RangeError("Invalid iterator");return void 0===r.l&&(t=t.next()),this.m(r),t},I.prototype.getHeight=function(){var r;return this.t?(r=function(t){return t?Math.max(r(t.o),r(t.l))+1:0})(this._):0};var d,f=I;function I(t,r){void 0===t&&(t=function(t,r){return t<r?-1:r<t?1:0}),void 0===r&&(r=!1);var i=d.call(this)||this;return i._=void 0,i.T=function(t,r){return void 0!==t&&(!!i.T(t.o,r)||!!r(t)||i.T(t.l,r))},i.O=t,r?(i.M=c,i.C=function(t,r,i){t=this.g(t,r,i);if(t){for(var e=t.v;e!==this.I;)e.p+=1,e=e.v;var r=this.N(t);r&&(i=r.parentNode,t=r.grandParent,r=r.curNode,i.recount(),t.recount(),r.recount())}},i.m=function(t){for(var r=this.S(t);r!==this.I;)--r.p,r=r.v}):(i.M=l,i.C=function(t,r,i){t=this.g(t,r,i);t&&this.N(t)},i.m=i.S),i.I=new i.M,i}r(g,w=i),Object.defineProperty(g.prototype,"index",{get:function(){var t=this.A,r=this.I.v;if(t===this.I)return r?r.p-1:0;var i=0;for(t.o&&(i+=t.o.p);t!==r;){var e=t.v;t===e.l&&(i+=1,e.o)&&(i+=e.o.p),t=e}return i},enumerable:!1,configurable:!0}),g.prototype.equals=function(t){return this.A===t.A};var w,_=g;function g(t,r,i){i=w.call(this,i)||this;return i.A=t,i.I=r,0===i.iteratorType?(i.pre=function(){if(this.A===this.I.o)throw new RangeError("Tree iterator access denied!");return this.A=this.A.pre(),this},i.next=function(){if(this.A===this.I)throw new RangeError("Tree iterator access denied!");return this.A=this.A.next(),this}):(i.pre=function(){if(this.A===this.I.l)throw new RangeError("Tree iterator access denied!");return this.A=this.A.next(),this},i.next=function(){if(this.A===this.I)throw new RangeError("Tree iterator access denied!");return this.A=this.A.pre(),this}),i}r(O,b=_),Object.defineProperty(O.prototype,"pointer",{get:function(){var e=this;if(this.A===this.I)throw new RangeError("OrderedMap iterator access denied");return new Proxy([],{get:function(t,r){return"0"===r?e.A.u:"1"===r?e.A.h:void 0},set:function(t,r,i){if("1"!==r)throw new TypeError("props must be 1");return e.A.h=i,!0}})},enumerable:!1,configurable:!0}),O.prototype.copy=function(){return new O(this.A,this.I,this.iteratorType)};var b,m=O;function O(){return null!==b&&b.apply(this,arguments)||this}r(E,A=f),E.prototype.begin=function(){return new m(this.I.o||this.I,this.I)},E.prototype.end=function(){return new m(this.I,this.I)},E.prototype.rBegin=function(){return new m(this.I.l||this.I,this.I,1)},E.prototype.rEnd=function(){return new m(this.I,this.I,1)},E.prototype.front=function(){var t;if(this.t)return[(t=this.I.o).u,t.h]},E.prototype.back=function(){var t;if(this.t)return[(t=this.I.l).u,t.h]},E.prototype.forEach=function(t){var r,i,e=0;try{for(var o=u(this),n=o.next();!n.done;n=o.next())t(n.value,e++,this)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}},E.prototype.lowerBound=function(t){t=this.j(this._,t);return new m(t,this.I)},E.prototype.upperBound=function(t){t=this.R(this._,t);return new m(t,this.I)},E.prototype.reverseLowerBound=function(t){t=this.k(this._,t);return new m(t,this.I)},E.prototype.reverseUpperBound=function(t){t=this.B(this._,t);return new m(t,this.I)},E.prototype.setElement=function(t,r,i){this.C(t,r,i)},E.prototype.find=function(t){t=this.G(this._,t);return void 0!==t?new m(t,this.I):this.end()},E.prototype.getElementByKey=function(t){t=this.G(this._,t);return t?t.h:void 0},E.prototype.getElementByPos=function(t){var r,i,e;if(t<0||t>this.t-1)throw new RangeError;var o=0;try{for(var n=u(this),s=n.next();!s.done;s=n.next()){var h=s.value;if(o===t){e=h;break}o+=1}}catch(t){r={error:t}}finally{try{s&&!s.done&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}return e},E.prototype.union=function(t){var i=this;t.forEach(function(t){var t=n(t,2),r=t[0],t=t[1];return i.setElement(r,t)})},E.prototype[Symbol.iterator]=function(){return this.q(this._)};var A,_=E;function E(t,r,i){void 0===t&&(t=[]);var e=A.call(this,r,i)||this;return e.q=function(r){return o(this,function(t){switch(t.label){case 0:return void 0===r?[2]:[5,u(this.q(r.o))];case 1:return t.sent(),[4,[r.u,r.h]];case 2:return t.sent(),[5,u(this.q(r.l))];case 3:return t.sent(),[2]}})},t.forEach(function(t){var t=n(t,2),r=t[0],t=t[1];return e.setElement(r,t)}),e}t.OrderedMap=_,Object.defineProperty(t,"D",{value:!0})}); | ||
!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 e=function(t,r){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,r){t.__proto__=r}:function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}))(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 i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}function i(e,o){var n,h,s,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},f={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(f[Symbol.iterator]=function(){return this}),f;function t(i){return function(t){var r=[i,t];if(n)throw new TypeError("Generator is already executing.");for(;u=f&&r[f=0]?0:u;)try{if(n=1,h&&(s=2&r[0]?h.return:r[0]?h.throw||((s=h.return)&&s.call(h),0):h.next)&&!(s=s.call(h,r[1])).done)return s;switch(h=0,(r=s?[2&r[0],s.value]:r)[0]){case 0:case 1:s=r;break;case 4:return u.label++,{value:r[1],done:!1};case 5:u.label++,h=r[1],r=[0];continue;case 7:r=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===r[0]||2===r[0])){u=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3]))u.label=r[1];else if(6===r[0]&&u.label<s[1])u.label=s[1],s=r;else{if(!(s&&u.label<s[2])){s[2]&&u.ops.pop(),u.trys.pop();continue}u.label=s[2],u.ops.push(r)}}r=o.call(e,u)}catch(t){r=[6,t],h=0}finally{n=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}}}function u(t){var r="function"==typeof Symbol&&Symbol.iterator,i=r&&t[r],e=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&e>=t.length?void 0:t)&&t[e++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,r){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var e,o,n=i.call(t),h=[];try{for(;(void 0===r||0<r--)&&!(e=n.next()).done;)h.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(o)throw o.error}}return h}h.prototype.pre=function(){var t=this;if(1===t.t&&t.l.l===t)t=t.o;else if(t.h)for(t=t.h;t.o;)t=t.o;else{for(var r=t.l;r.h===t;)r=(t=r).l;t=r}return t},h.prototype.next=function(){var t=this;if(t.o){for(t=t.o;t.h;)t=t.h;return t}for(var r=t.l;r.o===t;)r=(t=r).l;return t.o!==r?r:t},h.prototype.rotateLeft=function(){var t=this.l,r=this.o,i=r.h;return t.l===this?t.l=r:t.h===this?t.h=r:t.o=r,r.l=t,(r.h=this).l=r,(this.o=i)&&(i.l=this),r},h.prototype.rotateRight=function(){var t=this.l,r=this.h,i=r.o;return t.l===this?t.l=r:t.h===this?t.h=r:t.o=r,r.l=t,(r.o=this).l=r,(this.h=i)&&(i.l=this),r};var n=h;function h(t,r){this.t=1,this.i=void 0,this.u=void 0,this.h=void 0,this.o=void 0,this.l=void 0,this.i=t,this.u=r}r(a,s=n),a.prototype.rotateLeft=function(){var t=s.prototype.rotateLeft.call(this);return this.recount(),t.recount(),t},a.prototype.rotateRight=function(){var t=s.prototype.rotateRight.call(this);return this.recount(),t.recount(),t},a.prototype.recount=function(){this.v=1,this.h&&(this.v+=this.h.v),this.o&&(this.v+=this.o.v)};var s,f=a;function a(){var t=null!==s&&s.apply(this,arguments)||this;return t.h=void 0,t.o=void 0,t.l=void 0,t.v=1,t}function l(t){this.iteratorType=t=void 0===t?0:t}function p(){this.p=0}p.prototype.size=function(){return this.p},p.prototype.empty=function(){return 0===this.p};r(y,c=p);var c,v=y;function y(){return null!==c&&c.apply(this,arguments)||this}r(g,d=v),g.prototype.S=function(t,r){for(var i;t;){var e=this._(t.i,r);if(e<0)t=t.o;else{if(!(0<e))return t;t=(i=t).h}}return void 0===i?this.g:i},g.prototype.j=function(t,r){for(var i;t;)t=this._(t.i,r)<=0?t.o:(i=t).h;return void 0===i?this.g:i},g.prototype.R=function(t,r){for(var i;t;){var e=this._(t.i,r);if(e<0)t=(i=t).o;else{if(!(0<e))return t;t=t.h}}return void 0===i?this.g:i},g.prototype.k=function(t,r){for(var i;t;)t=this._(t.i,r)<0?(i=t).o:t.h;return void 0===i?this.g:i},g.prototype.B=function(t){for(;;){var r,i=t.l;if(i===this.g)return;if(1===t.t)return void(t.t=0);if(t===i.h)if(1===(r=i.o).t)r.t=0,i.t=1,i===this.T?this.T=i.rotateLeft():i.rotateLeft();else{if(r.o&&1===r.o.t)return r.t=i.t,i.t=0,r.o.t=0,void(i===this.T?this.T=i.rotateLeft():i.rotateLeft());r.h&&1===r.h.t?(r.t=1,r.h.t=0,r.rotateRight()):(r.t=1,t=i)}else if(1===(r=i.h).t)r.t=0,i.t=1,i===this.T?this.T=i.rotateRight():i.rotateRight();else{if(r.h&&1===r.h.t)return r.t=i.t,i.t=0,r.h.t=0,void(i===this.T?this.T=i.rotateRight():i.rotateRight());r.o&&1===r.o.t?(r.t=1,r.o.t=0,r.rotateLeft()):(r.t=1,t=i)}}},g.prototype.m=function(t){var r;if(1===this.p)return this.clear(),this.g;for(var i=t;i.h||i.o;){if(i.o)for(i=i.o;i.h;)i=i.h;else i=i.h;r=o([i.i,t.i],2),t.i=r[0],i.i=r[1],r=o([i.u,t.u],2),t.u=r[0],i.u=r[1],t=i}this.g.h===i?this.g.h=i.l:this.g.o===i&&(this.g.o=i.l),this.B(i);var e=i.l;return i===e.h?e.h=void 0:e.o=void 0,--this.p,this.T.t=0,e},g.prototype.P=function(t,r){return void 0!==t&&(!!this.P(t.h,r)||!!r(t)||this.P(t.o,r))},g.prototype.I=function(t){for(;;){var r=t.l;if(0===r.t)return;var i,e,o=r.l;if(r===o.h){if((i=o.o)&&1===i.t){if(i.t=r.t=0,o===this.T)return;o.t=1,t=o;continue}if(t===r.o)return t.t=0,t.h&&(t.h.l=r),t.o&&(t.o.l=o),r.o=t.h,o.h=t.o,t.h=r,(t.o=o)===this.T?(this.T=t,this.g.l=t):(e=o.l).h===o?e.h=t:e.o=t,t.l=o.l,r.l=t,o.l=t,o.t=1,{parentNode:r,grandParent:o,curNode:t};r.t=0,o===this.T?this.T=o.rotateRight():o.rotateRight()}else{if((i=o.h)&&1===i.t){if(i.t=r.t=0,o===this.T)return;o.t=1,t=o;continue}if(t===r.h)return t.t=0,t.h&&(t.h.l=o),t.o&&(t.o.l=r),o.o=t.h,r.h=t.o,t.h=o,t.o=r,o===this.T?(this.T=t,this.g.l=t):(e=o.l).h===o?e.h=t:e.o=t,t.l=o.l,r.l=t,o.l=t,o.t=1,{parentNode:r,grandParent:o,curNode:t};r.t=0,o===this.T?this.T=o.rotateLeft():o.rotateLeft()}return void(o.t=1)}},g.prototype.C=function(t,r,i){if(void 0===this.T)this.p+=1,this.T=new this.O(t,r),this.T.t=0,this.T.l=this.g,this.g.l=this.T,this.g.h=this.T,this.g.o=this.T;else{var e,o=this.g.h,n=this._(o.i,t);if(0!==n){if(0<n)o.h=new this.O(t,r),e=(o.h.l=o).h,this.g.h=e;else{var n=this.g.o,h=this._(n.i,t);if(0===h)return void(n.u=r);if(h<0)n.o=new this.O(t,r),e=(n.o.l=n).o,this.g.o=e;else{if(void 0!==i){h=i.A;if(h!==this.g){n=this._(h.i,t);if(0===n)return void(h.u=r);if(0<n){i=h.pre(),n=this._(i.i,t);if(0===n)return void(i.u=r);n<0&&(e=new this.O(t,r),void 0===i.o?(i.o=e).l=i:(h.h=e).l=h)}}}if(void 0===e)for(e=this.T;;){var s=this._(e.i,t);if(0<s){if(void 0===e.h){e.h=new this.O(t,r),e=(e.h.l=e).h;break}e=e.h}else{if(!(s<0))return void(e.u=r);if(void 0===e.o){e.o=new this.O(t,r),e=(e.o.l=e).o;break}e=e.o}}}}return this.p+=1,e}o.u=r}},g.prototype.clear=function(){this.p=0,this.T=void 0,this.g.l=void 0,this.g.h=this.g.o=void 0},g.prototype.updateKeyByIterator=function(t,r){t=t.A;if(t===this.g)throw new TypeError("Invalid iterator!");if(1!==this.p){if(t===this.g.h)return 0<this._(t.next().i,r)&&(t.i=r,!0);if(t===this.g.o)return this._(t.pre().i,r)<0&&(t.i=r,!0);var i=t.pre().i;if(0<=this._(i,r))return!1;if(i=t.next().i,this._(i,r)<=0)return!1}return t.i=r,!0},g.prototype.eraseElementByPos=function(r){if(r<0||r>this.p-1)throw new RangeError;var i=0,e=this;this.P(this.T,function(t){return r===i?(e.N(t),!0):(i+=1,!1)})},g.prototype.G=function(t,r){for(;t;){var i=this._(t.i,r);if(i<0)t=t.o;else{if(!(0<i))return t;t=t.h}}return t},g.prototype.eraseElementByKey=function(t){this.p&&void 0!==(t=this.G(this.T,t))&&this.N(t)},g.prototype.eraseElementByIterator=function(t){var r=t.A;if(r===this.g)throw new RangeError("Invalid iterator");return void 0===r.o&&(t=t.next()),this.N(r),t},g.prototype.getHeight=function(){var r;return this.p?(r=function(t){return t?Math.max(r(t.h),r(t.o))+1:0})(this.T):0};var d,v=g;function g(t,r){void 0===t&&(t=function(t,r){return t<r?-1:r<t?1:0}),void 0===r&&(r=!1);var i=d.call(this)||this;return i.T=void 0,i._=t,r?(i.O=f,i.M=function(t,r,i){t=this.C(t,r,i);if(t){for(var e=t.l;e!==this.g;)e.v+=1,e=e.l;var r=this.I(t);r&&(i=r.parentNode,t=r.grandParent,r=r.curNode,i.recount(),t.recount(),r.recount())}},i.N=function(t){for(var r=this.m(t);r!==this.g;)--r.v,r=r.l}):(i.O=n,i.M=function(t,r,i){t=this.C(t,r,i);t&&this.I(t)},i.N=i.m),i.g=new i.O,i}r(b,w=l),Object.defineProperty(b.prototype,"index",{get:function(){var t=this.A,r=this.g.l;if(t===this.g)return r?r.v-1:0;var i=0;for(t.h&&(i+=t.h.v);t!==r;){var e=t.l;t===e.o&&(i+=1,e.h)&&(i+=e.h.v),t=e}return i},enumerable:!1,configurable:!0}),b.prototype.equals=function(t){return this.A===t.A};var w,T=b;function b(t,r,i){i=w.call(this,i)||this;return i.A=t,i.g=r,0===i.iteratorType?(i.pre=function(){if(this.A===this.g.h)throw new RangeError("Tree iterator access denied!");return this.A=this.A.pre(),this},i.next=function(){if(this.A===this.g)throw new RangeError("Tree iterator access denied!");return this.A=this.A.next(),this}):(i.pre=function(){if(this.A===this.g.o)throw new RangeError("Tree iterator access denied!");return this.A=this.A.next(),this},i.next=function(){if(this.A===this.g)throw new RangeError("Tree iterator access denied!");return this.A=this.A.pre(),this}),i}r(E,m=T),Object.defineProperty(E.prototype,"pointer",{get:function(){if(this.A===this.g)throw new RangeError("OrderedMap iterator access denied");var e=this;return new Proxy([],{get:function(t,r){return"0"===r?e.A.i:"1"===r?e.A.u:void 0},set:function(t,r,i){if("1"!==r)throw new TypeError("props must be 1");return e.A.u=i,!0}})},enumerable:!1,configurable:!0}),E.prototype.copy=function(){return new E(this.A,this.g,this.iteratorType)};var m,A=E;function E(){return null!==m&&m.apply(this,arguments)||this}r(_,x=v),_.prototype.q=function(r){return i(this,function(t){switch(t.label){case 0:return void 0===r?[2]:[5,u(this.q(r.h))];case 1:return t.sent(),[4,[r.i,r.u]];case 2:return t.sent(),[5,u(this.q(r.o))];case 3:return t.sent(),[2]}})},_.prototype.begin=function(){return new A(this.g.h||this.g,this.g)},_.prototype.end=function(){return new A(this.g,this.g)},_.prototype.rBegin=function(){return new A(this.g.o||this.g,this.g,1)},_.prototype.rEnd=function(){return new A(this.g,this.g,1)},_.prototype.front=function(){var t;if(this.p)return[(t=this.g.h).i,t.u]},_.prototype.back=function(){var t;if(this.p)return[(t=this.g.o).i,t.u]},_.prototype.forEach=function(t){var r,i,e=0;try{for(var o=u(this),n=o.next();!n.done;n=o.next())t(n.value,e++,this)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}},_.prototype.lowerBound=function(t){t=this.S(this.T,t);return new A(t,this.g)},_.prototype.upperBound=function(t){t=this.j(this.T,t);return new A(t,this.g)},_.prototype.reverseLowerBound=function(t){t=this.R(this.T,t);return new A(t,this.g)},_.prototype.reverseUpperBound=function(t){t=this.k(this.T,t);return new A(t,this.g)},_.prototype.setElement=function(t,r,i){this.M(t,r,i)},_.prototype.find=function(t){t=this.G(this.T,t);return void 0!==t?new A(t,this.g):this.end()},_.prototype.getElementByKey=function(t){t=this.G(this.T,t);return t?t.u:void 0},_.prototype.getElementByPos=function(t){var r,i,e;if(t<0||t>this.p-1)throw new RangeError;var o=0;try{for(var n=u(this),h=n.next();!h.done;h=n.next()){var s=h.value;if(o===t){e=s;break}o+=1}}catch(t){r={error:t}}finally{try{h&&!h.done&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}return e},_.prototype.union=function(t){var r=this;t.forEach(function(t){r.setElement(t[0],t[1])})},_.prototype[Symbol.iterator]=function(){return this.q(this.T)};var x,T=_;function _(t,r,i){void 0===t&&(t=[]);var r=x.call(this,r,i)||this,e=r;return t.forEach(function(t){e.setElement(t[0],t[1])}),r}t.OrderedMap=T,Object.defineProperty(t,"D",{value:!0})}); | ||
//# sourceMappingURL=ordered-map.min.js.map |
{ | ||
"name": "@js-sdsl/ordered-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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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) | [](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 not supported yet
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
398767
3.77%14
7.69%3706
0.05%297
30.84%0
-100%73
1.39%