Socket
Socket
Sign inDemoInstall

js-sdsl

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-sdsl - npm Package Compare versions

Comparing version 4.1.5-beta.1 to 4.1.5

7

CHANGELOG.md

@@ -7,2 +7,9 @@ # Change Log

## [4.1.5] - 2022.09.30
### Added
- Add `find`, `remove`, `updateItem` and `toArray` functions to `PriorityQueue`.
- Support single package release (use scope @js-sdsl).
## [4.1.5-beta.1] - 2022.09.23

@@ -9,0 +16,0 @@

2

dist/cjs/container/ContainerBase/index.d.ts

@@ -108,3 +108,3 @@ export declare const enum IteratorType {

/**
* @description Using for 'for...of' syntax like Array.
* @description Using for `for...of` syntax like Array.
*/

@@ -111,0 +111,0 @@ abstract [Symbol.iterator](): Generator<T, void, undefined>;

import { Base } from "../../ContainerBase";
export declare const enum HashContainerConst {
sigma = 0.75,
treeifyThreshold = 8,
untreeifyThreshold = 6,
minTreeifySize = 64,
maxBucketNum = 1073741824
}
declare abstract class HashContainer<K> extends Base {
protected constructor(initBucketNum?: number, hashFunc?: (x: K) => number);
clear(): void;
/**
* @description Iterate over all elements in the container.
* @param callback Callback function like Array.forEach.
*/
abstract forEach(callback: (element: unknown, index: number) => void): void;

@@ -23,4 +20,7 @@ /**

abstract find(key: K): void;
abstract [Symbol.iterator](): Generator<unknown, void, undefined>;
/**
* @description Using for `for...of` syntax like Array.
*/
abstract [Symbol.iterator](): Generator<K | [K, unknown], void, undefined>;
}
export default HashContainer;

@@ -30,3 +30,3 @@ "use strict";

}
this.u = this.J = e;
this.u = this.te = e;
this.l = t;

@@ -36,3 +36,3 @@ }

this.o = 0;
this.u = this.J;
this.u = this.te;
this.i = [];

@@ -39,0 +39,0 @@ }

@@ -6,13 +6,13 @@ import { Base, initContainer } from "../ContainerBase";

* @param container Initialize container, must have a forEach function.
* @param _cmp Compare function.
* @param cmp Compare function.
* @param copy When the container is an array, you can choose to directly operate on the original object of
* the array or perform a shallow copy. The default is shallow copy.
*/
constructor(container?: initContainer<T>, _cmp?: (x: T, y: T) => number, copy?: boolean);
constructor(container?: initContainer<T>, cmp?: (x: T, y: T) => number, copy?: boolean);
clear(): void;
/**
* @description Push element into a container in order.
* @param element The element you want to push.
* @param item The element you want to push.
*/
push(element: T): void;
push(item: T): void;
/**

@@ -26,3 +26,25 @@ * @description Removes the top element.

top(): T | undefined;
/**
* @description Check if element is in heap.
* @param item The item want to find.
* @return Boolean about if element is in heap.
*/
find(item: T): boolean;
/**
* @description Remove specified item from heap.
* @param item The item want to remove.
* @return Boolean about if remove success.
*/
remove(item: T): boolean;
/**
* @description Update item and it's pos in the heap.
* @param item The item want to update.
* @return Boolean about if update success.
*/
updateItem(item: T): boolean;
/**
* @return Return a copy array of heap.
*/
toArray(): T[];
}
export default PriorityQueue;

@@ -28,18 +28,31 @@ "use strict";

for (let t = this.o - 1 >> 1; t >= 0; --t) {
let s = t;
const i = this._[s];
while (s < e) {
let t = s << 1 | 1;
const e = t + 1;
let h = this._[t];
if (e < this.o && this.p(h, this._[e]) > 0) {
t = e;
h = this._[e];
}
if (this.p(h, i) >= 0) break;
this._[s] = h;
s = t;
this.v(t, e);
}
}
B(t) {
const s = this._[t];
while (t > 0) {
const i = t - 1 >> 1;
const e = this._[i];
if (this.p(e, s) <= 0) break;
this._[t] = e;
t = i;
}
this._[t] = s;
}
v(t, s) {
const i = this._[t];
while (t < s) {
let s = t << 1 | 1;
const e = s + 1;
let h = this._[s];
if (e < this.o && this.p(h, this._[e]) > 0) {
s = e;
h = this._[e];
}
this._[s] = i;
if (this.p(h, i) >= 0) break;
this._[t] = h;
t = s;
}
this._[t] = i;
}

@@ -51,13 +64,5 @@ clear() {

push(t) {
let s = this.o;
this._.push(t);
this.B(this.o);
this.o += 1;
this._.push(t);
while (s > 0) {
const i = s - 1 >> 1;
const e = this._[i];
if (this.p(e, t) <= 0) break;
this._[s] = e;
s = i;
}
this._[s] = t;
}

@@ -68,19 +73,6 @@ pop() {

this.o -= 1;
if (!this.o) return;
let s = 0;
const i = this.o >> 1;
while (s < i) {
let i = s << 1 | 1;
const e = i + 1;
let h = this._[i];
const r = this._[e];
if (e < this.o && this.p(h, r) > 0) {
i = e;
h = r;
}
if (this.p(h, t) >= 0) break;
this._[s] = h;
s = i;
if (this.o) {
this._[0] = t;
this.v(0, this.o >> 1);
}
this._[s] = t;
}

@@ -90,2 +82,31 @@ top() {

}
find(t) {
return this._.indexOf(t) >= 0;
}
remove(t) {
const s = this._.indexOf(t);
if (s < 0) return false;
if (s === 0) {
this.pop();
} else if (s === this.o - 1) {
this._.pop();
this.o -= 1;
} else {
this._.splice(s, 1, this._.pop());
this.o -= 1;
this.B(s);
this.v(s, this.o >> 1);
}
return true;
}
updateItem(t) {
const s = this._.indexOf(t);
if (s < 0) return false;
this.B(s);
this.v(s, this.o >> 1);
return true;
}
toArray() {
return [ ...this._ ];
}
}

@@ -92,0 +113,0 @@

@@ -14,3 +14,3 @@ "use strict";

super();
this.v = [];
this.C = [];
t.forEach((t => this.push(t)));

@@ -20,14 +20,14 @@ }

this.o = 0;
this.v.length = 0;
this.C.length = 0;
}
push(t) {
this.v.push(t);
this.C.push(t);
this.o += 1;
}
pop() {
this.v.pop();
this.C.pop();
if (this.o > 0) this.o -= 1;
}
top() {
return this.v[this.o - 1];
return this.C[this.o - 1];
}

@@ -34,0 +34,0 @@ }

@@ -1,6 +0,5 @@

import { ContainerIterator, IteratorType } from "../../ContainerBase";
import { ContainerIterator } from "../../ContainerBase";
export declare abstract class RandomIterator<T> extends ContainerIterator<T> {
pre: () => this;
next: () => this;
constructor(index: number, size: () => number, getElementByPos: (pos: number) => T, setElementByPos: (pos: number, element: T) => void, iteratorType?: IteratorType);
get pointer(): T;

@@ -7,0 +6,0 @@ set pointer(newValue: T);

@@ -15,5 +15,5 @@ "use strict";

this.I = t;
this.B = r;
this.D = e;
this.g = i;
this.D = r;
this.g = e;
this.m = i;
if (this.iteratorType === 0) {

@@ -28,3 +28,3 @@ this.pre = function() {

this.next = function() {
if (this.I === this.B()) {
if (this.I === this.D()) {
throw new RangeError("Random Iterator access denied!");

@@ -37,3 +37,3 @@ }

this.pre = function() {
if (this.I === this.B() - 1) {
if (this.I === this.D() - 1) {
throw new RangeError("Random iterator access denied!");

@@ -54,12 +54,12 @@ }

get pointer() {
if (this.I < 0 || this.I > this.B() - 1) {
if (this.I < 0 || this.I > this.D() - 1) {
throw new RangeError;
}
return this.D(this.I);
return this.g(this.I);
}
set pointer(t) {
if (this.I < 0 || this.I > this.B() - 1) {
if (this.I < 0 || this.I > this.D() - 1) {
throw new RangeError;
}
this.g(this.I, t);
this.m(this.I, t);
}

@@ -66,0 +66,0 @@ equals(t) {

@@ -21,3 +21,3 @@ "use strict";

copy() {
return new DequeIterator(this.I, this.B, this.D, this.g, this.iteratorType);
return new DequeIterator(this.I, this.D, this.g, this.m, this.iteratorType);
}

@@ -31,8 +31,8 @@ }

super();
this.m = 0;
this.R = 0;
this.k = 0;
this.N = 0;
this.M = 0;
this.u = 0;
this.M = [];
this.P = [];
let s;

@@ -50,10 +50,10 @@ if ("size" in t) {

}
this.P = i;
this.u = Math.max(Math.ceil(s / this.P), 1);
this.A = i;
this.u = Math.max(Math.ceil(s / this.A), 1);
for (let t = 0; t < this.u; ++t) {
this.M.push(new Array(this.P));
this.P.push(new Array(this.A));
}
const h = Math.ceil(s / this.P);
this.m = this.k = (this.u >> 1) - (h >> 1);
this.R = this.N = this.P - s % this.P >> 1;
const h = Math.ceil(s / this.A);
this.R = this.N = (this.u >> 1) - (h >> 1);
this.k = this.M = this.A - s % this.A >> 1;
t.forEach((t => this.pushBack(t)));

@@ -68,27 +68,27 @@ this.size = this.size.bind(this);

for (let s = 0; s < i; ++s) {
t[s] = new Array(this.P);
t[s] = new Array(this.A);
}
for (let i = this.m; i < this.u; ++i) {
t[t.length] = this.M[i];
for (let i = this.R; i < this.u; ++i) {
t[t.length] = this.P[i];
}
for (let i = 0; i < this.k; ++i) {
t[t.length] = this.M[i];
for (let i = 0; i < this.N; ++i) {
t[t.length] = this.P[i];
}
t[t.length] = [ ...this.M[this.k] ];
this.m = i;
this.k = t.length - 1;
t[t.length] = [ ...this.P[this.N] ];
this.R = i;
this.N = t.length - 1;
for (let s = 0; s < i; ++s) {
t[t.length] = new Array(this.P);
t[t.length] = new Array(this.A);
}
this.M = t;
this.P = t;
this.u = t.length;
}
A(t) {
const i = this.R + t + 1;
const s = i % this.P;
F(t) {
const i = this.k + t + 1;
const s = i % this.A;
let h = s - 1;
let e = this.m + (i - s) / this.P;
let e = this.R + (i - s) / this.A;
if (s === 0) e -= 1;
e %= this.u;
if (h < 0) h += this.P;
if (h < 0) h += this.A;
return {

@@ -100,12 +100,12 @@ curNodeBucketIndex: e,

clear() {
this.M = [ [] ];
this.P = [ [] ];
this.u = 1;
this.m = this.k = this.o = 0;
this.R = this.N = this.P >> 1;
this.R = this.N = this.o = 0;
this.k = this.M = this.A >> 1;
}
front() {
return this.M[this.m][this.R];
return this.P[this.R][this.k];
}
back() {
return this.M[this.k][this.N];
return this.P[this.N][this.M];
}

@@ -126,28 +126,28 @@ begin() {

if (this.o) {
if (this.N < this.P - 1) {
if (this.M < this.A - 1) {
this.M += 1;
} else if (this.N < this.u - 1) {
this.N += 1;
} else if (this.k < this.u - 1) {
this.k += 1;
this.N = 0;
this.M = 0;
} else {
this.k = 0;
this.N = 0;
this.M = 0;
}
if (this.k === this.m && this.N === this.R) this.h();
if (this.N === this.R && this.M === this.k) this.h();
}
this.o += 1;
this.M[this.k][this.N] = t;
this.P[this.N][this.M] = t;
}
popBack() {
if (!this.o) return;
this.M[this.k][this.N] = undefined;
this.P[this.N][this.M] = undefined;
if (this.o !== 1) {
if (this.N > 0) {
if (this.M > 0) {
this.M -= 1;
} else if (this.N > 0) {
this.N -= 1;
} else if (this.k > 0) {
this.k -= 1;
this.N = this.P - 1;
this.M = this.A - 1;
} else {
this.k = this.u - 1;
this.N = this.P - 1;
this.N = this.u - 1;
this.M = this.A - 1;
}

@@ -159,28 +159,28 @@ }

if (this.o) {
if (this.R > 0) {
if (this.k > 0) {
this.k -= 1;
} else if (this.R > 0) {
this.R -= 1;
} else if (this.m > 0) {
this.m -= 1;
this.R = this.P - 1;
this.k = this.A - 1;
} else {
this.m = this.u - 1;
this.R = this.P - 1;
this.R = this.u - 1;
this.k = this.A - 1;
}
if (this.m === this.k && this.R === this.N) this.h();
if (this.R === this.N && this.k === this.M) this.h();
}
this.o += 1;
this.M[this.m][this.R] = t;
this.P[this.R][this.k] = t;
}
popFront() {
if (!this.o) return;
this.M[this.m][this.R] = undefined;
this.P[this.R][this.k] = undefined;
if (this.o !== 1) {
if (this.R < this.P - 1) {
if (this.k < this.A - 1) {
this.k += 1;
} else if (this.R < this.u - 1) {
this.R += 1;
} else if (this.m < this.u - 1) {
this.m += 1;
this.R = 0;
this.k = 0;
} else {
this.m = 0;
this.R = 0;
this.k = 0;
}

@@ -199,4 +199,4 @@ }

}
const {curNodeBucketIndex: i, curNodePointerIndex: s} = this.A(t);
return this.M[i][s];
const {curNodeBucketIndex: i, curNodePointerIndex: s} = this.F(t);
return this.P[i][s];
}

@@ -207,4 +207,4 @@ setElementByPos(t, i) {

}
const {curNodeBucketIndex: s, curNodePointerIndex: h} = this.A(t);
this.M[s][h] = i;
const {curNodeBucketIndex: s, curNodePointerIndex: h} = this.F(t);
this.P[s][h] = i;
}

@@ -234,5 +234,5 @@ insert(t, i, s = 1) {

}
const {curNodeBucketIndex: i, curNodePointerIndex: s} = this.A(t);
this.k = i;
this.N = s;
const {curNodeBucketIndex: i, curNodePointerIndex: s} = this.F(t);
this.N = i;
this.M = s;
this.o = t + 1;

@@ -315,7 +315,7 @@ }

this.forEach((i => t.push(i)));
this.u = Math.max(Math.ceil(this.o / this.P), 1);
this.o = this.m = this.k = this.R = this.N = 0;
this.M = [];
this.u = Math.max(Math.ceil(this.o / this.A), 1);
this.o = this.R = this.N = this.k = this.M = 0;
this.P = [];
for (let t = 0; t < this.u; ++t) {
this.M.push(new Array(this.P));
this.P.push(new Array(this.A));
}

@@ -322,0 +322,0 @@ for (let i = 0; i < t.length; ++i) this.pushBack(t[i]);

import SequentialContainer from './Base';
import { ContainerIterator, initContainer, IteratorType } from "../ContainerBase";
export declare class LinkNode<T> {
value: T | undefined;
pre: LinkNode<T> | undefined;
next: LinkNode<T> | undefined;
constructor(element?: T);
}
import { ContainerIterator, initContainer } from "../ContainerBase";
export declare class LinkListIterator<T> extends ContainerIterator<T> {
pre: () => this;
next: () => this;
constructor(_node: LinkNode<T>, _header: LinkNode<T>, iteratorType?: IteratorType);
get pointer(): T;

@@ -30,3 +23,3 @@ set pointer(newValue: T);

eraseElementByPos(pos: number): void;
eraseElementByValue(value: T): void;
eraseElementByValue(_value: T): void;
eraseElementByIterator(iter: LinkListIterator<T>): LinkListIterator<T>;

@@ -33,0 +26,0 @@ pushBack(element: T): void;

@@ -21,6 +21,6 @@ "use strict";

constructor(t) {
this.value = undefined;
this.pre = undefined;
this.next = undefined;
this.value = t;
this.L = undefined;
this.j = undefined;
this.O = undefined;
this.L = t;
}

@@ -35,16 +35,16 @@ }

this.I = t;
this.L = i;
this.S = i;
if (this.iteratorType === 0) {
this.pre = function() {
if (this.I.pre === this.L) {
if (this.I.j === this.S) {
throw new RangeError("LinkList iterator access denied!");
}
this.I = this.I.pre;
this.I = this.I.j;
return this;
};
this.next = function() {
if (this.I === this.L) {
if (this.I === this.S) {
throw new RangeError("LinkList iterator access denied!");
}
this.I = this.I.next;
this.I = this.I.O;
return this;

@@ -54,13 +54,13 @@ };

this.pre = function() {
if (this.I.next === this.L) {
if (this.I.O === this.S) {
throw new RangeError("LinkList iterator access denied!");
}
this.I = this.I.next;
this.I = this.I.O;
return this;
};
this.next = function() {
if (this.I === this.L) {
if (this.I === this.S) {
throw new RangeError("LinkList iterator access denied!");
}
this.I = this.I.pre;
this.I = this.I.j;
return this;

@@ -71,12 +71,12 @@ };

get pointer() {
if (this.I === this.L) {
if (this.I === this.S) {
throw new RangeError("LinkList iterator access denied!");
}
return this.I.value;
return this.I.L;
}
set pointer(t) {
if (this.I === this.L) {
if (this.I === this.S) {
throw new RangeError("LinkList iterator access denied!");
}
this.I.value = t;
this.I.L = t;
}

@@ -87,3 +87,3 @@ equals(t) {

copy() {
return new LinkListIterator(this.I, this.L, this.iteratorType);
return new LinkListIterator(this.I, this.S, this.iteratorType);
}

@@ -97,5 +97,5 @@ }

super();
this.L = new LinkNode;
this.C = undefined;
this.F = undefined;
this.S = new LinkNode;
this.V = undefined;
this.G = undefined;
t.forEach((t => this.pushBack(t)));

@@ -105,30 +105,30 @@ }

this.o = 0;
this.C = this.F = undefined;
this.L.pre = this.L.next = undefined;
this.V = this.G = undefined;
this.S.j = this.S.O = undefined;
}
begin() {
return new LinkListIterator(this.C || this.L, this.L);
return new LinkListIterator(this.V || this.S, this.S);
}
end() {
return new LinkListIterator(this.L, this.L);
return new LinkListIterator(this.S, this.S);
}
rBegin() {
return new LinkListIterator(this.F || this.L, this.L, 1);
return new LinkListIterator(this.G || this.S, this.S, 1);
}
rEnd() {
return new LinkListIterator(this.L, this.L, 1);
return new LinkListIterator(this.S, this.S, 1);
}
front() {
return this.C ? this.C.value : undefined;
return this.V ? this.V.L : undefined;
}
back() {
return this.F ? this.F.value : undefined;
return this.G ? this.G.L : undefined;
}
forEach(t) {
if (!this.o) return;
let i = this.C;
let i = this.V;
let s = 0;
while (i !== this.L) {
t(i.value, s++);
i = i.next;
while (i !== this.S) {
t(i.L, s++);
i = i.O;
}

@@ -140,7 +140,7 @@ }

}
let i = this.C;
let i = this.V;
while (t--) {
i = i.next;
i = i.O;
}
return i.value;
return i.L;
}

@@ -152,11 +152,11 @@ eraseElementByPos(t) {

if (t === 0) this.popFront(); else if (t === this.o - 1) this.popBack(); else {
let i = this.C;
let i = this.V;
while (t--) {
i = i.next;
i = i.O;
}
i = i;
const s = i.pre;
const e = i.next;
e.pre = s;
s.next = e;
const s = i.j;
const e = i.O;
e.j = s;
s.O = e;
this.o -= 1;

@@ -166,15 +166,15 @@ }

eraseElementByValue(t) {
while (this.C && this.C.value === t) this.popFront();
while (this.F && this.F.value === t) this.popBack();
if (!this.C) return;
let i = this.C;
while (i !== this.L) {
if (i.value === t) {
const t = i.pre;
const s = i.next;
if (s) s.pre = t;
if (t) t.next = s;
while (this.V && this.V.L === t) this.popFront();
while (this.G && this.G.L === t) this.popBack();
if (!this.V) return;
let i = this.V;
while (i !== this.S) {
if (i.L === t) {
const t = i.j;
const s = i.O;
s.j = t;
t.O = s;
this.o -= 1;
}
i = i.next;
i = i.O;
}

@@ -184,11 +184,11 @@ }

const i = t.I;
if (i === this.L) {
if (i === this.S) {
throw new RangeError("Invalid iterator");
}
t = t.next();
if (this.C === i) this.popFront(); else if (this.F === i) this.popBack(); else {
const t = i.pre;
const s = i.next;
if (s) s.pre = t;
if (t) t.next = s;
if (this.V === i) this.popFront(); else if (this.G === i) this.popBack(); else {
const t = i.j;
const s = i.O;
s.j = t;
t.O = s;
this.o -= 1;

@@ -201,26 +201,25 @@ }

const i = new LinkNode(t);
if (!this.F) {
this.C = this.F = i;
this.L.next = this.C;
this.C.pre = this.L;
if (!this.G) {
this.V = this.G = i;
this.S.O = this.V;
this.V.j = this.S;
} else {
this.F.next = i;
i.pre = this.F;
this.F = i;
this.G.O = i;
i.j = this.G;
this.G = i;
}
this.F.next = this.L;
this.L.pre = this.F;
this.G.O = this.S;
this.S.j = this.G;
}
popBack() {
if (!this.F) return;
if (!this.G) return;
this.o -= 1;
if (this.C === this.F) {
this.C = this.F = undefined;
this.L.next = undefined;
if (this.V === this.G) {
this.V = this.G = undefined;
this.S.O = undefined;
} else {
this.F = this.F.pre;
if (this.F) this.F.next = undefined;
this.G = this.G.j;
this.G.O = this.S;
}
this.L.pre = this.F;
if (this.F) this.F.next = this.L;
this.S.j = this.G;
}

@@ -231,7 +230,7 @@ setElementByPos(t, i) {

}
let s = this.C;
let s = this.V;
while (t--) {
s = s.next;
s = s.O;
}
s.value = i;
s.L = i;
}

@@ -248,25 +247,25 @@ insert(t, i, s = 1) {

} else {
let e = this.C;
let e = this.V;
for (let i = 1; i < t; ++i) {
e = e.next;
e = e.O;
}
const h = e.next;
const h = e.O;
this.o += s;
while (s--) {
e.next = new LinkNode(i);
e.next.pre = e;
e = e.next;
e.O = new LinkNode(i);
e.O.j = e;
e = e.O;
}
e.next = h;
if (h) h.pre = e;
e.O = h;
h.j = e;
}
}
find(t) {
if (!this.C) return this.end();
let i = this.C;
while (i !== this.L) {
if (i.value === t) {
return new LinkListIterator(i, this.L);
if (!this.V) return this.end();
let i = this.V;
while (i !== this.S) {
if (i.L === t) {
return new LinkListIterator(i, this.S);
}
i = i.next;
i = i.O;
}

@@ -277,11 +276,11 @@ return this.end();

if (this.o <= 1) return;
let t = this.C;
let i = this.F;
let t = this.V;
let i = this.G;
let s = 0;
while (s << 1 < this.o) {
const e = t.value;
t.value = i.value;
i.value = e;
t = t.next;
i = i.pre;
const e = t.L;
t.L = i.L;
i.L = e;
t = t.O;
i = i.j;
s += 1;

@@ -292,12 +291,12 @@ }

if (this.o <= 1) return;
let t = this.C;
while (t !== this.L) {
let t = this.V;
while (t !== this.S) {
let i = t;
while (i.next && i.value === i.next.value) {
i = i.next;
while (i.O && i.L === i.O.L) {
i = i.O;
this.o -= 1;
}
t.next = i.next;
if (t.next) t.next.pre = t;
t = t.next;
t.O = i.O;
t.O.j = t;
t = t.O;
}

@@ -310,6 +309,6 @@ }

i.sort(t);
let s = this.C;
let s = this.V;
i.forEach((t => {
s.value = t;
s = s.next;
s.L = t;
s = s.O;
}));

@@ -320,49 +319,49 @@ }

const i = new LinkNode(t);
if (!this.C) {
this.C = this.F = i;
this.F.next = this.L;
this.L.pre = this.F;
if (!this.V) {
this.V = this.G = i;
this.G.O = this.S;
this.S.j = this.G;
} else {
i.next = this.C;
this.C.pre = i;
this.C = i;
i.O = this.V;
this.V.j = i;
this.V = i;
}
this.L.next = this.C;
this.C.pre = this.L;
this.S.O = this.V;
this.V.j = this.S;
}
popFront() {
if (!this.C) return;
if (!this.V) return;
this.o -= 1;
if (this.C === this.F) {
this.C = this.F = undefined;
this.L.pre = this.F;
if (this.V === this.G) {
this.V = this.G = undefined;
this.S.j = this.G;
} else {
this.C = this.C.next;
if (this.C) this.C.pre = this.L;
this.V = this.V.O;
this.V.j = this.S;
}
this.L.next = this.C;
this.S.O = this.V;
}
merge(t) {
if (!this.C) {
if (!this.V) {
t.forEach((t => this.pushBack(t)));
return;
}
let i = this.C;
let i = this.V;
t.forEach((t => {
while (i && i !== this.L && i.value <= t) {
i = i.next;
while (i && i !== this.S && i.L <= t) {
i = i.O;
}
if (i === this.L) {
if (i === this.S) {
this.pushBack(t);
i = this.F;
} else if (i === this.C) {
i = this.G;
} else if (i === this.V) {
this.pushFront(t);
i = this.C;
i = this.V;
} else {
this.o += 1;
const s = i.pre;
s.next = new LinkNode(t);
s.next.pre = s;
s.next.next = i;
i.pre = s.next;
const s = i.j;
s.O = new LinkNode(t);
s.O.j = s;
s.O.O = i;
i.j = s.O;
}

@@ -373,7 +372,7 @@ }));

return function*() {
if (!this.C) return;
let t = this.C;
while (t !== this.L) {
yield t.value;
t = t.next;
if (!this.V) return;
let t = this.V;
while (t !== this.S) {
yield t.L;
t = t.O;
}

@@ -380,0 +379,0 @@ }.bind(this)();

@@ -21,3 +21,3 @@ "use strict";

copy() {
return new VectorIterator(this.I, this.B, this.D, this.g, this.iteratorType);
return new VectorIterator(this.I, this.D, this.g, this.m, this.iteratorType);
}

@@ -32,6 +32,6 @@ }

if (Array.isArray(t)) {
this.V = e ? [ ...t ] : t;
this.H = e ? [ ...t ] : t;
this.o = t.length;
} else {
this.V = [];
this.H = [];
t.forEach((t => this.pushBack(t)));

@@ -45,3 +45,3 @@ }

this.o = 0;
this.V.length = 0;
this.H.length = 0;
}

@@ -61,10 +61,10 @@ begin() {

front() {
return this.V[0];
return this.H[0];
}
back() {
return this.V[this.o - 1];
return this.H[this.o - 1];
}
forEach(t) {
for (let e = 0; e < this.o; ++e) {
t(this.V[e], e);
t(this.H[e], e);
}

@@ -76,3 +76,3 @@ }

}
return this.V[t];
return this.H[t];
}

@@ -83,3 +83,3 @@ eraseElementByPos(t) {

}
this.V.splice(t, 1);
this.H.splice(t, 1);
this.o -= 1;

@@ -90,7 +90,7 @@ }

for (let r = 0; r < this.o; ++r) {
if (this.V[r] !== t) {
this.V[e++] = this.V[r];
if (this.H[r] !== t) {
this.H[e++] = this.H[r];
}
}
this.o = this.V.length = e;
this.o = this.H.length = e;
}

@@ -104,3 +104,3 @@ eraseElementByIterator(t) {

pushBack(t) {
this.V.push(t);
this.H.push(t);
this.o += 1;

@@ -110,3 +110,3 @@ }

if (!this.o) return;
this.V.pop();
this.H.pop();
this.o -= 1;

@@ -118,3 +118,3 @@ }

}
this.V[t] = e;
this.H[t] = e;
}

@@ -125,3 +125,3 @@ insert(t, e, r = 1) {

}
this.V.splice(t, 0, ...new Array(r).fill(e));
this.H.splice(t, 0, ...new Array(r).fill(e));
this.o += r;

@@ -131,3 +131,3 @@ }

for (let e = 0; e < this.o; ++e) {
if (this.V[e] === t) {
if (this.H[e] === t) {
return new VectorIterator(e, this.size, this.getElementByPos, this.getElementByPos);

@@ -139,3 +139,3 @@ }

reverse() {
this.V.reverse();
this.H.reverse();
}

@@ -145,14 +145,14 @@ unique() {

for (let e = 1; e < this.o; ++e) {
if (this.V[e] !== this.V[e - 1]) {
this.V[t++] = this.V[e];
if (this.H[e] !== this.H[e - 1]) {
this.H[t++] = this.H[e];
}
}
this.o = this.V.length = t;
this.o = this.H.length = t;
}
sort(t) {
this.V.sort(t);
this.H.sort(t);
}
[Symbol.iterator]() {
return function*() {
return yield* this.V;
return yield* this.H;
}.bind(this)();

@@ -159,0 +159,0 @@ }

import type TreeIterator from './TreeIterator';
import { Container } from "../../ContainerBase";
declare abstract class TreeContainer<K, V> extends Container<K | [K, V]> {
protected constructor(_cmp?: (x: K, y: K) => number, enableIndex?: boolean);
/**
* @param key The given key you want to compare.
* @return An iterator to the first element not less than the given key.
* @param cmp The compare function.
* @param enableIndex Whether to enable iterator indexing function.
*/
abstract lowerBound(key: K): TreeIterator<K, V>;
protected constructor(cmp?: (x: K, y: K) => number, enableIndex?: boolean);
/**
* @param key The given key you want to compare.
* @return An iterator to the first element greater than the given key.
* @param _key The given _key you want to compare.
* @return An iterator to the first element not less than the given _key.
*/
abstract upperBound(key: K): TreeIterator<K, V>;
abstract lowerBound(_key: K): TreeIterator<K, V>;
/**
* @param key The given key you want to compare.
* @return An iterator to the first element not greater than the given key.
* @param _key The given _key you want to compare.
* @return An iterator to the first element greater than the given _key.
*/
abstract reverseLowerBound(key: K): TreeIterator<K, V>;
abstract upperBound(_key: K): TreeIterator<K, V>;
/**
* @param key The given key you want to compare.
* @return An iterator to the first element less than the given key.
* @param _key The given _key you want to compare.
* @return An iterator to the first element not greater than the given _key.
*/
abstract reverseUpperBound(key: K): TreeIterator<K, V>;
abstract reverseLowerBound(_key: K): TreeIterator<K, V>;
/**
* @param _key The given _key you want to compare.
* @return An iterator to the first element less than the given _key.
*/
abstract reverseUpperBound(_key: K): TreeIterator<K, V>;
/**
* @description Union the other tree to self.
* <br/>
* Waiting for optimization, this is O(mlog(n+m)) algorithm now,
* but we expect it to be O(mlog(n/m+1)).<br/>
* More information =>
* https://en.wikipedia.org/wiki/Red_black_tree
* <br/>
* @param other The other tree container you want to merge.

@@ -38,14 +36,14 @@ */

/**
* @description Update node's key by iterator.
* @description Update node's _key by iterator.
* @param iter The iterator you want to change.
* @param key The key you want to update.
* @param _key The _key you want to update.
* @return Boolean about if the modification is successful.
*/
updateKeyByIterator(iter: TreeIterator<K, V>, key: K): boolean;
updateKeyByIterator(iter: TreeIterator<K, V>, _key: K): boolean;
eraseElementByPos(pos: number): void;
/**
* @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.
*/
eraseElementByKey(key: K): void;
eraseElementByKey(_key: K): void;
eraseElementByIterator(iter: TreeIterator<K, V>): TreeIterator<K, V>;

@@ -52,0 +50,0 @@ /**

@@ -20,22 +20,22 @@ "use strict";

super();
this.j = undefined;
this.W = (e, t) => {
this.X = undefined;
this.ie = (e, t) => {
if (e === undefined) return false;
const i = this.W(e.left, t);
const i = this.ie(e.U, t);
if (i) return true;
if (t(e)) return true;
return this.W(e.right, t);
return this.ie(e.J, t);
};
this.p = e;
if (t) {
this.X = _TreeNode.TreeNodeEnableIndex;
this.G = function(e, t, i) {
const s = this.Y(e, t, i);
this.ne = _TreeNode.TreeNodeEnableIndex;
this.ee = function(e, t, i) {
const s = this.he(e, t, i);
if (s) {
let e = s.parent;
while (e !== this.L) {
e.subTreeSize += 1;
e = e.parent;
let e = s.tt;
while (e !== this.S) {
e.et += 1;
e = e.tt;
}
const t = this.Z(s);
const t = this.fe(s);
if (t) {

@@ -49,102 +49,102 @@ const {parentNode: e, grandParent: i, curNode: s} = t;

};
this.$ = function(e) {
let t = this.ee(e);
while (t !== this.L) {
t.subTreeSize -= 1;
t = t.parent;
this.ue = function(e) {
let t = this.le(e);
while (t !== this.S) {
t.et -= 1;
t = t.tt;
}
};
} else {
this.X = _TreeNode.TreeNode;
this.G = function(e, t, i) {
const s = this.Y(e, t, i);
if (s) this.Z(s);
this.ne = _TreeNode.TreeNode;
this.ee = function(e, t, i) {
const s = this.he(e, t, i);
if (s) this.fe(s);
};
this.$ = this.ee;
this.ue = this.le;
}
this.L = new this.X;
this.S = new this.ne;
}
T(e, t) {
W(e, t) {
let i;
while (e) {
const s = this.p(e.key, t);
const s = this.p(e.T, t);
if (s < 0) {
e = e.right;
e = e.J;
} else if (s > 0) {
i = e;
e = e.left;
e = e.U;
} else return e;
}
return i === undefined ? this.L : i;
return i === undefined ? this.S : i;
}
K(e, t) {
Y(e, t) {
let i;
while (e) {
const s = this.p(e.key, t);
const s = this.p(e.T, t);
if (s <= 0) {
e = e.right;
} else if (s > 0) {
e = e.J;
} else {
i = e;
e = e.left;
e = e.U;
}
}
return i === undefined ? this.L : i;
return i === undefined ? this.S : i;
}
S(e, t) {
Z(e, t) {
let i;
while (e) {
const s = this.p(e.key, t);
const s = this.p(e.T, t);
if (s < 0) {
i = e;
e = e.right;
e = e.J;
} else if (s > 0) {
e = e.left;
e = e.U;
} else return e;
}
return i === undefined ? this.L : i;
return i === undefined ? this.S : i;
}
U(e, t) {
$(e, t) {
let i;
while (e) {
const s = this.p(e.key, t);
const s = this.p(e.T, t);
if (s < 0) {
i = e;
e = e.right;
} else if (s >= 0) {
e = e.left;
e = e.J;
} else {
e = e.U;
}
}
return i === undefined ? this.L : i;
return i === undefined ? this.S : i;
}
te(e) {
oe(e) {
while (true) {
const t = e.parent;
if (t === this.L) return;
if (e.color === 1) {
e.color = 0;
const t = e.tt;
if (t === this.S) return;
if (e.se === 1) {
e.se = 0;
return;
}
if (e === t.left) {
const i = t.right;
if (i.color === 1) {
i.color = 0;
t.color = 1;
if (t === this.j) {
this.j = t.rotateLeft();
if (e === t.U) {
const i = t.J;
if (i.se === 1) {
i.se = 0;
t.se = 1;
if (t === this.X) {
this.X = t.rotateLeft();
} else t.rotateLeft();
} else if (i.color === 0) {
if (i.right && i.right.color === 1) {
i.color = t.color;
t.color = 0;
i.right.color = 0;
if (t === this.j) {
this.j = t.rotateLeft();
} else {
if (i.J && i.J.se === 1) {
i.se = t.se;
t.se = 0;
i.J.se = 0;
if (t === this.X) {
this.X = t.rotateLeft();
} else t.rotateLeft();
return;
} else if (i.left && i.left.color === 1) {
i.color = 1;
i.left.color = 0;
} else if (i.U && i.U.se === 1) {
i.se = 1;
i.U.se = 0;
i.rotateRight();
} else {
i.color = 1;
i.se = 1;
e = t;

@@ -154,24 +154,24 @@ }

} else {
const i = t.left;
if (i.color === 1) {
i.color = 0;
t.color = 1;
if (t === this.j) {
this.j = t.rotateRight();
const i = t.U;
if (i.se === 1) {
i.se = 0;
t.se = 1;
if (t === this.X) {
this.X = t.rotateRight();
} else t.rotateRight();
} else {
if (i.left && i.left.color === 1) {
i.color = t.color;
t.color = 0;
i.left.color = 0;
if (t === this.j) {
this.j = t.rotateRight();
if (i.U && i.U.se === 1) {
i.se = t.se;
t.se = 0;
i.U.se = 0;
if (t === this.X) {
this.X = t.rotateRight();
} else t.rotateRight();
return;
} else if (i.right && i.right.color === 1) {
i.color = 1;
i.right.color = 0;
} else if (i.J && i.J.se === 1) {
i.se = 1;
i.J.se = 0;
i.rotateLeft();
} else {
i.color = 1;
i.se = 1;
e = t;

@@ -183,67 +183,67 @@ }

}
ee(e) {
le(e) {
if (this.o === 1) {
this.clear();
return this.L;
return this.S;
}
let t = e;
while (t.left || t.right) {
if (t.right) {
t = t.right;
while (t.left) t = t.left;
} else if (t.left) {
t = t.left;
while (t.U || t.J) {
if (t.J) {
t = t.J;
while (t.U) t = t.U;
} else {
t = t.U;
}
[e.key, t.key] = [ t.key, e.key ];
[e.value, t.value] = [ t.value, e.value ];
[e.T, t.T] = [ t.T, e.T ];
[e.L, t.L] = [ t.L, e.L ];
e = t;
}
if (this.L.left === t) {
this.L.left = t.parent;
} else if (this.L.right === t) {
this.L.right = t.parent;
if (this.S.U === t) {
this.S.U = t.tt;
} else if (this.S.J === t) {
this.S.J = t.tt;
}
this.te(t);
const i = t.parent;
if (t === i.left) {
i.left = undefined;
} else i.right = undefined;
this.oe(t);
const i = t.tt;
if (t === i.U) {
i.U = undefined;
} else i.J = undefined;
this.o -= 1;
this.j.color = 0;
this.X.se = 0;
return i;
}
Z(e) {
fe(e) {
while (true) {
const t = e.parent;
if (t.color === 0) return;
const i = t.parent;
if (t === i.left) {
const s = i.right;
if (s && s.color === 1) {
s.color = t.color = 0;
if (i === this.j) return;
i.color = 1;
const t = e.tt;
if (t.se === 0) return;
const i = t.tt;
if (t === i.U) {
const s = i.J;
if (s && s.se === 1) {
s.se = t.se = 0;
if (i === this.X) return;
i.se = 1;
e = i;
continue;
} else if (e === t.right) {
e.color = 0;
if (e.left) e.left.parent = t;
if (e.right) e.right.parent = i;
t.right = e.left;
i.left = e.right;
e.left = t;
e.right = i;
if (i === this.j) {
this.j = e;
this.L.parent = e;
} else if (e === t.J) {
e.se = 0;
if (e.U) e.U.tt = t;
if (e.J) e.J.tt = i;
t.J = e.U;
i.U = e.J;
e.U = t;
e.J = i;
if (i === this.X) {
this.X = e;
this.S.tt = e;
} else {
const t = i.parent;
if (t.left === i) {
t.left = e;
} else t.right = e;
const t = i.tt;
if (t.U === i) {
t.U = e;
} else t.J = e;
}
e.parent = i.parent;
t.parent = e;
i.parent = e;
i.color = 1;
e.tt = i.tt;
t.tt = e;
i.tt = e;
i.se = 1;
return {

@@ -255,37 +255,37 @@ parentNode: t,

} else {
t.color = 0;
if (i === this.j) {
this.j = i.rotateRight();
t.se = 0;
if (i === this.X) {
this.X = i.rotateRight();
} else i.rotateRight();
i.color = 1;
i.se = 1;
}
} else {
const s = i.left;
if (s && s.color === 1) {
s.color = t.color = 0;
if (i === this.j) return;
i.color = 1;
const s = i.U;
if (s && s.se === 1) {
s.se = t.se = 0;
if (i === this.X) return;
i.se = 1;
e = i;
continue;
} else if (e === t.left) {
e.color = 0;
if (e.left) e.left.parent = i;
if (e.right) e.right.parent = t;
i.right = e.left;
t.left = e.right;
e.left = i;
e.right = t;
if (i === this.j) {
this.j = e;
this.L.parent = e;
} else if (e === t.U) {
e.se = 0;
if (e.U) e.U.tt = i;
if (e.J) e.J.tt = t;
i.J = e.U;
t.U = e.J;
e.U = i;
e.J = t;
if (i === this.X) {
this.X = e;
this.S.tt = e;
} else {
const t = i.parent;
if (t.left === i) {
t.left = e;
} else t.right = e;
const t = i.tt;
if (t.U === i) {
t.U = e;
} else t.J = e;
}
e.parent = i.parent;
t.parent = e;
i.parent = e;
i.color = 1;
e.tt = i.tt;
t.tt = e;
i.tt = e;
i.se = 1;
return {

@@ -297,7 +297,7 @@ parentNode: t,

} else {
t.color = 0;
if (i === this.j) {
this.j = i.rotateLeft();
t.se = 0;
if (i === this.X) {
this.X = i.rotateLeft();
} else i.rotateLeft();
i.color = 1;
i.se = 1;
}

@@ -308,57 +308,57 @@ }

}
Y(e, t, i) {
if (this.j === undefined) {
he(e, t, i) {
if (this.X === undefined) {
this.o += 1;
this.j = new this.X(e, t);
this.j.color = 0;
this.j.parent = this.L;
this.L.parent = this.j;
this.L.left = this.j;
this.L.right = this.j;
this.X = new this.ne(e, t);
this.X.se = 0;
this.X.tt = this.S;
this.S.tt = this.X;
this.S.U = this.X;
this.S.J = this.X;
return;
}
let s;
const r = this.L.left;
const n = this.p(r.key, e);
const r = this.S.U;
const n = this.p(r.T, e);
if (n === 0) {
r.value = t;
r.L = t;
return;
} else if (n > 0) {
r.left = new this.X(e, t);
r.left.parent = r;
s = r.left;
this.L.left = s;
r.U = new this.ne(e, t);
r.U.tt = r;
s = r.U;
this.S.U = s;
} else {
const r = this.L.right;
const n = this.p(r.key, e);
const r = this.S.J;
const n = this.p(r.T, e);
if (n === 0) {
r.value = t;
r.L = t;
return;
} else if (n < 0) {
r.right = new this.X(e, t);
r.right.parent = r;
s = r.right;
this.L.right = s;
r.J = new this.ne(e, t);
r.J.tt = r;
s = r.J;
this.S.J = s;
} else {
if (i !== undefined) {
const r = i.I;
if (r !== this.L) {
const i = this.p(r.key, e);
if (r !== this.S) {
const i = this.p(r.T, e);
if (i === 0) {
r.value = t;
r.L = t;
return;
} else if (i > 0) {
const i = r.pre();
const n = this.p(i.key, e);
const n = this.p(i.T, e);
if (n === 0) {
i.value = t;
i.L = t;
return;
} else if (n < 0) {
s = new this.X(e, t);
if (i.right === undefined) {
i.right = s;
s.parent = i;
s = new this.ne(e, t);
if (i.J === undefined) {
i.J = s;
s.tt = i;
} else {
r.left = s;
s.parent = r;
r.U = s;
s.tt = r;
}

@@ -370,23 +370,23 @@ }

if (s === undefined) {
s = this.j;
s = this.X;
while (true) {
const i = this.p(s.key, e);
const i = this.p(s.T, e);
if (i > 0) {
if (s.left === undefined) {
s.left = new this.X(e, t);
s.left.parent = s;
s = s.left;
if (s.U === undefined) {
s.U = new this.ne(e, t);
s.U.tt = s;
s = s.U;
break;
}
s = s.left;
s = s.U;
} else if (i < 0) {
if (s.right === undefined) {
s.right = new this.X(e, t);
s.right.parent = s;
s = s.right;
if (s.J === undefined) {
s.J = new this.ne(e, t);
s.J.tt = s;
s = s.J;
break;
}
s = s.right;
s = s.J;
} else {
s.value = t;
s.L = t;
return;

@@ -403,18 +403,18 @@ }

this.o = 0;
this.j = undefined;
this.L.parent = undefined;
this.L.left = this.L.right = undefined;
this.X = undefined;
this.S.tt = undefined;
this.S.U = this.S.J = undefined;
}
updateKeyByIterator(e, t) {
const i = e.I;
if (i === this.L) {
if (i === this.S) {
throw new TypeError("Invalid iterator!");
}
if (this.o === 1) {
i.key = t;
i.T = t;
return true;
}
if (i === this.L.left) {
if (this.p(i.next().key, t) > 0) {
i.key = t;
if (i === this.S.U) {
if (this.p(i.next().T, t) > 0) {
i.T = t;
return true;

@@ -424,5 +424,5 @@ }

}
if (i === this.L.right) {
if (this.p(i.pre().key, t) < 0) {
i.key = t;
if (i === this.S.J) {
if (this.p(i.pre().T, t) < 0) {
i.T = t;
return true;

@@ -432,7 +432,7 @@ }

}
const s = i.pre().key;
const s = i.pre().T;
if (this.p(s, t) >= 0) return false;
const r = i.next().key;
const r = i.next().T;
if (this.p(r, t) <= 0) return false;
i.key = t;
i.T = t;
return true;

@@ -445,5 +445,5 @@ }

let t = 0;
this.W(this.j, (i => {
this.ie(this.X, (i => {
if (e === t) {
this.$(i);
this.ue(i);
return true;

@@ -455,9 +455,9 @@ }

}
H(e, t) {
re(e, t) {
while (e) {
const i = this.p(e.key, t);
const i = this.p(e.T, t);
if (i < 0) {
e = e.right;
e = e.J;
} else if (i > 0) {
e = e.left;
e = e.U;
} else return e;

@@ -469,15 +469,15 @@ }

if (!this.o) return;
const t = this.H(this.j, e);
const t = this.re(this.X, e);
if (t === undefined) return;
this.$(t);
this.ue(t);
}
eraseElementByIterator(e) {
const t = e.I;
if (t === this.L) {
if (t === this.S) {
throw new RangeError("Invalid iterator");
}
if (t.right === undefined) {
if (t.J === undefined) {
e = e.next();
}
this.$(t);
this.ue(t);
return e;

@@ -489,5 +489,5 @@ }

if (!e) return 0;
return Math.max(traversal(e.left), traversal(e.right)) + 1;
return Math.max(traversal(e.U), traversal(e.J)) + 1;
};
return traversal(this.j);
return traversal(this.X);
}

@@ -494,0 +494,0 @@ }

@@ -1,7 +0,12 @@

import { TreeNode } from './TreeNode';
import { ContainerIterator, IteratorType } from "../../ContainerBase";
import { ContainerIterator } from "../../ContainerBase";
declare abstract class TreeIterator<K, V> extends ContainerIterator<K | [K, V]> {
pre: () => this;
next: () => this;
constructor(_node: TreeNode<K, V>, _header: TreeNode<K, V>, iteratorType?: IteratorType);
/**
* @description Get the sequential index of the iterator in the tree container.<br/>
* <strong>
* Note:
* </strong>
* This function only takes effect when the specified tree container `enableIndex = true`.
*/
get index(): number;

@@ -8,0 +13,0 @@ equals(obj: TreeIterator<K, V>): boolean;

@@ -15,6 +15,6 @@ "use strict";

this.I = t;
this.L = e;
this.S = e;
if (this.iteratorType === 0) {
this.pre = function() {
if (this.I === this.L.left) {
if (this.I === this.S.U) {
throw new RangeError("Tree iterator access denied!");

@@ -26,3 +26,3 @@ }

this.next = function() {
if (this.I === this.L) {
if (this.I === this.S) {
throw new RangeError("Tree iterator access denied!");

@@ -35,3 +35,3 @@ }

this.pre = function() {
if (this.I === this.L.right) {
if (this.I === this.S.J) {
throw new RangeError("Tree iterator access denied!");

@@ -43,3 +43,3 @@ }

this.next = function() {
if (this.I === this.L) {
if (this.I === this.S) {
throw new RangeError("Tree iterator access denied!");

@@ -54,6 +54,6 @@ }

let t = this.I;
const e = this.L.parent;
if (t === this.L) {
const e = this.S.tt;
if (t === this.S) {
if (e) {
return e.subTreeSize - 1;
return e.et - 1;
}

@@ -63,11 +63,11 @@ return 0;

let r = 0;
if (t.left) {
r += t.left.subTreeSize;
if (t.U) {
r += t.U.et;
}
while (t !== e) {
const e = t.parent;
if (t === e.right) {
const e = t.tt;
if (t === e.J) {
r += 1;
if (e.left) {
r += e.left.subTreeSize;
if (e.U) {
r += e.U.et;
}

@@ -74,0 +74,0 @@ }

@@ -1,13 +0,3 @@

export declare const enum TreeNodeColor {
RED = 1,
BLACK = 0
}
export declare class TreeNode<K, V> {
color: TreeNodeColor;
key: K | undefined;
value: V | undefined;
left: TreeNode<K, V> | undefined;
right: TreeNode<K, V> | undefined;
parent: TreeNode<K, V> | undefined;
constructor(key?: K, value?: V);
constructor(_key?: K, _value?: V);
/**

@@ -24,3 +14,3 @@ * @description Get the pre node.

/**
* @description Rotate left.
* @description Rotate _left.
* @return TreeNode about moved to original position after rotation.

@@ -30,3 +20,3 @@ */

/**
* @description Rotate right.
* @description Rotate _right.
* @return TreeNode about moved to original position after rotation.

@@ -37,8 +27,4 @@ */

export declare class TreeNodeEnableIndex<K, V> extends TreeNode<K, V> {
left: TreeNodeEnableIndex<K, V> | undefined;
right: TreeNodeEnableIndex<K, V> | undefined;
parent: TreeNodeEnableIndex<K, V> | undefined;
subTreeSize: number;
/**
* @description Rotate left and do recount.
* @description Rotate _left and do recount.
* @return TreeNode about moved to original position after rotation.

@@ -48,3 +34,3 @@ */

/**
* @description Rotate right and do recount.
* @description Rotate _right and do recount.
* @return TreeNode about moved to original position after rotation.

@@ -51,0 +37,0 @@ */

@@ -11,25 +11,25 @@ "use strict";

constructor(e, t) {
this.color = 1;
this.key = undefined;
this.value = undefined;
this.left = undefined;
this.right = undefined;
this.parent = undefined;
this.key = e;
this.value = t;
this.se = 1;
this.T = undefined;
this.L = undefined;
this.U = undefined;
this.J = undefined;
this.tt = undefined;
this.T = e;
this.L = t;
}
pre() {
let e = this;
if (e.color === 1 && e.parent.parent === e) {
e = e.right;
} else if (e.left) {
e = e.left;
while (e.right) {
e = e.right;
if (e.se === 1 && e.tt.tt === e) {
e = e.J;
} else if (e.U) {
e = e.U;
while (e.J) {
e = e.J;
}
} else {
let t = e.parent;
while (t.left === e) {
let t = e.tt;
while (t.U === e) {
e = t;
t = e.parent;
t = e.tt;
}

@@ -42,41 +42,41 @@ e = t;

let e = this;
if (e.right) {
e = e.right;
while (e.left) {
e = e.left;
if (e.J) {
e = e.J;
while (e.U) {
e = e.U;
}
return e;
} else {
let t = e.parent;
while (t.right === e) {
let t = e.tt;
while (t.J === e) {
e = t;
t = e.parent;
t = e.tt;
}
if (e.right !== t) {
e = t;
}
if (e.J !== t) {
return t;
} else return e;
}
return e;
}
rotateLeft() {
const e = this.parent;
const t = this.right;
const s = t.left;
if (e.parent === this) e.parent = t; else if (e.left === this) e.left = t; else e.right = t;
t.parent = e;
t.left = this;
this.parent = t;
this.right = s;
if (s) s.parent = this;
const e = this.tt;
const t = this.J;
const s = t.U;
if (e.tt === this) e.tt = t; else if (e.U === this) e.U = t; else e.J = t;
t.tt = e;
t.U = this;
this.tt = t;
this.J = s;
if (s) s.tt = this;
return t;
}
rotateRight() {
const e = this.parent;
const t = this.left;
const s = t.right;
if (e.parent === this) e.parent = t; else if (e.left === this) e.left = t; else e.right = t;
t.parent = e;
t.right = this;
this.parent = t;
this.left = s;
if (s) s.parent = this;
const e = this.tt;
const t = this.U;
const s = t.J;
if (e.tt === this) e.tt = t; else if (e.U === this) e.U = t; else e.J = t;
t.tt = e;
t.J = this;
this.tt = t;
this.U = s;
if (s) s.tt = this;
return t;

@@ -91,6 +91,6 @@ }

super(...arguments);
this.left = undefined;
this.right = undefined;
this.parent = undefined;
this.subTreeSize = 1;
this.U = undefined;
this.J = undefined;
this.tt = undefined;
this.et = 1;
}

@@ -110,5 +110,5 @@ rotateLeft() {

recount() {
this.subTreeSize = 1;
if (this.left) this.subTreeSize += this.left.subTreeSize;
if (this.right) this.subTreeSize += this.right.subTreeSize;
this.et = 1;
if (this.U) this.et += this.U.et;
if (this.J) this.et += this.J.et;
}

@@ -115,0 +115,0 @@ }

@@ -9,2 +9,7 @@ import TreeContainer from './Base';

declare class OrderedMap<K, V> extends TreeContainer<K, V> {
/**
* @param container The initialization container.
* @param cmp The compare function.
* @param enableIndex Whether to enable iterator indexing function.
*/
constructor(container?: initContainer<[K, V]>, cmp?: (x: K, y: K) => number, enableIndex?: boolean);

@@ -18,18 +23,18 @@ begin(): OrderedMapIterator<K, V>;

forEach(callback: (element: [K, V], index: number) => void): void;
lowerBound(key: K): OrderedMapIterator<K, V>;
upperBound(key: K): OrderedMapIterator<K, V>;
reverseLowerBound(key: K): OrderedMapIterator<K, V>;
reverseUpperBound(key: K): OrderedMapIterator<K, V>;
lowerBound(_key: K): OrderedMapIterator<K, V>;
upperBound(_key: K): OrderedMapIterator<K, V>;
reverseLowerBound(_key: K): OrderedMapIterator<K, V>;
reverseUpperBound(_key: K): OrderedMapIterator<K, V>;
/**
* @description Insert a key-value pair or set value by the given key.
* @param key The key want to insert.
* @param value The value want to set.
* @description Insert a _key-_value pair or set _value by the given _key.
* @param _key The _key want to insert.
* @param _value The _value want to set.
* @param hint You can give an iterator hint to improve insertion efficiency.
*/
setElement(key: K, value: V, hint?: OrderedMapIterator<K, V>): void;
find(key: K): OrderedMapIterator<K, V>;
setElement(_key: K, _value: V, hint?: OrderedMapIterator<K, V>): void;
find(_key: K): OrderedMapIterator<K, V>;
/**
* @description Get the value of the element of the specified key.
* @description Get the _value of the element of the specified _key.
*/
getElementByKey(key: K): V | undefined;
getElementByKey(_key: K): V | undefined;
getElementByPos(pos: number): [K, V];

@@ -36,0 +41,0 @@ union(other: OrderedMap<K, V>): void;

@@ -21,3 +21,3 @@ "use strict";

get pointer() {
if (this.I === this.L) {
if (this.I === this.S) {
throw new RangeError("OrderedMap iterator access denied");

@@ -27,3 +27,3 @@ }

get: (e, r) => {
if (r === "0") return this.I.key; else if (r === "1") return this.I.value;
if (r === "0") return this.I.T; else if (r === "1") return this.I.L;
},

@@ -34,3 +34,3 @@ set: (e, r, t) => {

}
this.I.value = t;
this.I.L = t;
return true;

@@ -41,3 +41,3 @@ }

copy() {
return new OrderedMapIterator(this.I, this.L, this.iteratorType);
return new OrderedMapIterator(this.I, this.S, this.iteratorType);
}

@@ -51,7 +51,7 @@ }

super(r, t);
this.O = function*(e) {
this.K = function*(e) {
if (e === undefined) return;
yield* this.O(e.left);
yield [ e.key, e.value ];
yield* this.O(e.right);
yield* this.K(e.U);
yield [ e.T, e.L ];
yield* this.K(e.J);
};

@@ -61,22 +61,22 @@ e.forEach((([e, r]) => this.setElement(e, r)));

begin() {
return new OrderedMapIterator(this.L.left || this.L, this.L);
return new OrderedMapIterator(this.S.U || this.S, this.S);
}
end() {
return new OrderedMapIterator(this.L, this.L);
return new OrderedMapIterator(this.S, this.S);
}
rBegin() {
return new OrderedMapIterator(this.L.right || this.L, this.L, 1);
return new OrderedMapIterator(this.S.J || this.S, this.S, 1);
}
rEnd() {
return new OrderedMapIterator(this.L, this.L, 1);
return new OrderedMapIterator(this.S, this.S, 1);
}
front() {
if (!this.o) return undefined;
const e = this.L.left;
return [ e.key, e.value ];
const e = this.S.U;
return [ e.T, e.L ];
}
back() {
if (!this.o) return undefined;
const e = this.L.right;
return [ e.key, e.value ];
const e = this.S.J;
return [ e.T, e.L ];
}

@@ -88,24 +88,24 @@ forEach(e) {

lowerBound(e) {
const r = this.T(this.j, e);
return new OrderedMapIterator(r, this.L);
const r = this.W(this.X, e);
return new OrderedMapIterator(r, this.S);
}
upperBound(e) {
const r = this.K(this.j, e);
return new OrderedMapIterator(r, this.L);
const r = this.Y(this.X, e);
return new OrderedMapIterator(r, this.S);
}
reverseLowerBound(e) {
const r = this.S(this.j, e);
return new OrderedMapIterator(r, this.L);
const r = this.Z(this.X, e);
return new OrderedMapIterator(r, this.S);
}
reverseUpperBound(e) {
const r = this.U(this.j, e);
return new OrderedMapIterator(r, this.L);
const r = this.$(this.X, e);
return new OrderedMapIterator(r, this.S);
}
setElement(e, r, t) {
this.G(e, r, t);
this.ee(e, r, t);
}
find(e) {
const r = this.H(this.j, e);
const r = this.re(this.X, e);
if (r !== undefined) {
return new OrderedMapIterator(r, this.L);
return new OrderedMapIterator(r, this.S);
}

@@ -115,4 +115,4 @@ return this.end();

getElementByKey(e) {
const r = this.H(this.j, e);
return r ? r.value : undefined;
const r = this.re(this.X, e);
return r ? r.L : undefined;
}

@@ -138,3 +138,3 @@ getElementByPos(e) {

[Symbol.iterator]() {
return this.O(this.j);
return this.K(this.X);
}

@@ -141,0 +141,0 @@ }

@@ -9,2 +9,7 @@ import TreeContainer from './Base';

declare class OrderedSet<K> extends TreeContainer<K, undefined> {
/**
* @param container The initialization container.
* @param cmp The compare function.
* @param enableIndex Whether to enable iterator indexing function.
*/
constructor(container?: initContainer<K>, cmp?: (x: K, y: K) => number, enableIndex?: boolean);

@@ -21,11 +26,11 @@ begin(): OrderedSetIterator<K>;

* @description Insert element to set.
* @param key The key want to insert.
* @param _key The _key want to insert.
* @param hint You can give an iterator hint to improve insertion efficiency.
*/
insert(key: K, hint?: OrderedSetIterator<K>): void;
insert(_key: K, hint?: OrderedSetIterator<K>): void;
find(element: K): OrderedSetIterator<K>;
lowerBound(key: K): OrderedSetIterator<K>;
upperBound(key: K): OrderedSetIterator<K>;
reverseLowerBound(key: K): OrderedSetIterator<K>;
reverseUpperBound(key: K): OrderedSetIterator<K>;
lowerBound(_key: K): OrderedSetIterator<K>;
upperBound(_key: K): OrderedSetIterator<K>;
reverseLowerBound(_key: K): OrderedSetIterator<K>;
reverseUpperBound(_key: K): OrderedSetIterator<K>;
union(other: OrderedSet<K>): void;

@@ -32,0 +37,0 @@ [Symbol.iterator](): Generator<K, void, undefined>;

@@ -21,9 +21,9 @@ "use strict";

get pointer() {
if (this.I === this.L) {
if (this.I === this.S) {
throw new RangeError("OrderedSet iterator access denied!");
}
return this.I.key;
return this.I.T;
}
copy() {
return new OrderedSetIterator(this.I, this.L, this.iteratorType);
return new OrderedSetIterator(this.I, this.S, this.iteratorType);
}

@@ -37,7 +37,7 @@ }

super(t, r);
this.O = function*(e) {
this.K = function*(e) {
if (e === undefined) return;
yield* this.O(e.left);
yield e.key;
yield* this.O(e.right);
yield* this.K(e.U);
yield e.T;
yield* this.K(e.J);
};

@@ -47,18 +47,18 @@ e.forEach((e => this.insert(e)));

begin() {
return new OrderedSetIterator(this.L.left || this.L, this.L);
return new OrderedSetIterator(this.S.U || this.S, this.S);
}
end() {
return new OrderedSetIterator(this.L, this.L);
return new OrderedSetIterator(this.S, this.S);
}
rBegin() {
return new OrderedSetIterator(this.L.right || this.L, this.L, 1);
return new OrderedSetIterator(this.S.J || this.S, this.S, 1);
}
rEnd() {
return new OrderedSetIterator(this.L, this.L, 1);
return new OrderedSetIterator(this.S, this.S, 1);
}
front() {
return this.L.left ? this.L.left.key : undefined;
return this.S.U ? this.S.U.T : undefined;
}
back() {
return this.L.right ? this.L.right.key : undefined;
return this.S.J ? this.S.J.T : undefined;
}

@@ -85,8 +85,8 @@ forEach(e) {

insert(e, t) {
this.G(e, undefined, t);
this.ee(e, undefined, t);
}
find(e) {
const t = this.H(this.j, e);
const t = this.re(this.X, e);
if (t !== undefined) {
return new OrderedSetIterator(t, this.L);
return new OrderedSetIterator(t, this.S);
}

@@ -96,16 +96,16 @@ return this.end();

lowerBound(e) {
const t = this.T(this.j, e);
return new OrderedSetIterator(t, this.L);
const t = this.W(this.X, e);
return new OrderedSetIterator(t, this.S);
}
upperBound(e) {
const t = this.K(this.j, e);
return new OrderedSetIterator(t, this.L);
const t = this.Y(this.X, e);
return new OrderedSetIterator(t, this.S);
}
reverseLowerBound(e) {
const t = this.S(this.j, e);
return new OrderedSetIterator(t, this.L);
const t = this.Z(this.X, e);
return new OrderedSetIterator(t, this.S);
}
reverseUpperBound(e) {
const t = this.U(this.j, e);
return new OrderedSetIterator(t, this.L);
const t = this.$(this.X, e);
return new OrderedSetIterator(t, this.S);
}

@@ -116,3 +116,3 @@ union(e) {

[Symbol.iterator]() {
return this.O(this.j);
return this.K(this.X);
}

@@ -119,0 +119,0 @@ }

@@ -108,3 +108,3 @@ export declare const enum IteratorType {

/**
* @description Using for 'for...of' syntax like Array.
* @description Using for `for...of` syntax like Array.
*/

@@ -111,0 +111,0 @@ abstract [Symbol.iterator](): Generator<T, void, undefined>;

import { Base } from "../../ContainerBase";
export declare const enum HashContainerConst {
sigma = 0.75,
treeifyThreshold = 8,
untreeifyThreshold = 6,
minTreeifySize = 64,
maxBucketNum = 1073741824
}
declare abstract class HashContainer<K> extends Base {
protected constructor(initBucketNum?: number, hashFunc?: (x: K) => number);
clear(): void;
/**
* @description Iterate over all elements in the container.
* @param callback Callback function like Array.forEach.
*/
abstract forEach(callback: (element: unknown, index: number) => void): void;

@@ -23,4 +20,7 @@ /**

abstract find(key: K): void;
abstract [Symbol.iterator](): Generator<unknown, void, undefined>;
/**
* @description Using for `for...of` syntax like Array.
*/
abstract [Symbol.iterator](): Generator<K | [K, unknown], void, undefined>;
}
export default HashContainer;

@@ -50,3 +50,3 @@ var __extends = this && this.t || function() {

}
i.l = i.Z = t;
i.l = i.nn = t;
i.p = r;

@@ -57,3 +57,3 @@ return i;

this.o = 0;
this.l = this.Z;
this.l = this.nn;
this.h = [];

@@ -60,0 +60,0 @@ };

@@ -6,13 +6,13 @@ import { Base, initContainer } from "../ContainerBase";

* @param container Initialize container, must have a forEach function.
* @param _cmp Compare function.
* @param cmp Compare function.
* @param copy When the container is an array, you can choose to directly operate on the original object of
* the array or perform a shallow copy. The default is shallow copy.
*/
constructor(container?: initContainer<T>, _cmp?: (x: T, y: T) => number, copy?: boolean);
constructor(container?: initContainer<T>, cmp?: (x: T, y: T) => number, copy?: boolean);
clear(): void;
/**
* @description Push element into a container in order.
* @param element The element you want to push.
* @param item The element you want to push.
*/
push(element: T): void;
push(item: T): void;
/**

@@ -26,3 +26,25 @@ * @description Removes the top element.

top(): T | undefined;
/**
* @description Check if element is in heap.
* @param item The item want to find.
* @return Boolean about if element is in heap.
*/
find(item: T): boolean;
/**
* @description Remove specified item from heap.
* @param item The item want to remove.
* @return Boolean about if remove success.
*/
remove(item: T): boolean;
/**
* @description Update item and it's pos in the heap.
* @param item The item want to update.
* @return Boolean about if update success.
*/
updateItem(item: T): boolean;
/**
* @return Return a copy array of heap.
*/
toArray(): T[];
}
export default PriorityQueue;
var __extends = this && this.t || function() {
var extendStatics = function(r, i) {
var extendStatics = function(i, t) {
extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(r, i) {
r.__proto__ = i;
} || function(r, i) {
for (var t in i) if (Object.prototype.hasOwnProperty.call(i, t)) r[t] = i[t];
} instanceof Array && function(i, t) {
i.__proto__ = t;
} || function(i, t) {
for (var r in t) if (Object.prototype.hasOwnProperty.call(t, r)) i[r] = t[r];
};
return extendStatics(r, i);
return extendStatics(i, t);
};
return function(r, i) {
if (typeof i !== "function" && i !== null) throw new TypeError("Class extends value " + String(i) + " is not a constructor or null");
extendStatics(r, i);
return function(i, t) {
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
extendStatics(i, t);
function __() {
this.constructor = r;
this.constructor = i;
}
r.prototype = i === null ? Object.create(i) : (__.prototype = i.prototype, new __);
i.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
};
}();
var __read = this && this._ || function(r, i) {
var t = typeof Symbol === "function" && r[Symbol.iterator];
if (!t) return r;
var e = t.call(r), n, u = [], a;
var __read = this && this._ || function(i, t) {
var r = typeof Symbol === "function" && i[Symbol.iterator];
if (!r) return i;
var e = r.call(i), n, u = [], s;
try {
while ((i === void 0 || i-- > 0) && !(n = e.next()).done) u.push(n.value);
} catch (r) {
a = {
error: r
while ((t === void 0 || t-- > 0) && !(n = e.next()).done) u.push(n.value);
} catch (i) {
s = {
error: i
};
} finally {
try {
if (n && !n.done && (t = e["return"])) t.call(e);
if (n && !n.done && (r = e["return"])) r.call(e);
} finally {
if (a) throw a.error;
if (s) throw s.error;
}

@@ -42,10 +42,10 @@ }

var __spreadArray = this && this.P || function(r, i, t) {
if (t || arguments.length === 2) for (var e = 0, n = i.length, u; e < n; e++) {
if (u || !(e in i)) {
if (!u) u = Array.prototype.slice.call(i, 0, e);
u[e] = i[e];
var __spreadArray = this && this.P || function(i, t, r) {
if (r || arguments.length === 2) for (var e = 0, n = t.length, u; e < n; e++) {
if (u || !(e in t)) {
if (!u) u = Array.prototype.slice.call(t, 0, e);
u[e] = t[e];
}
}
return r.concat(u || Array.prototype.slice.call(i));
return i.concat(u || Array.prototype.slice.call(t));
};

@@ -55,12 +55,12 @@

var PriorityQueue = function(r) {
__extends(PriorityQueue, r);
function PriorityQueue(i, t, e) {
if (i === void 0) {
i = [];
var PriorityQueue = function(i) {
__extends(PriorityQueue, i);
function PriorityQueue(t, r, e) {
if (t === void 0) {
t = [];
}
if (t === void 0) {
t = function(r, i) {
if (r > i) return -1;
if (r < i) return 1;
if (r === void 0) {
r = function(i, t) {
if (i > t) return -1;
if (i < t) return 1;
return 0;

@@ -72,10 +72,10 @@ };

}
var n = r.call(this) || this;
n.A = t;
if (Array.isArray(i)) {
n.m = e ? __spreadArray([], __read(i), false) : i;
var n = i.call(this) || this;
n.A = r;
if (Array.isArray(t)) {
n.m = e ? __spreadArray([], __read(t), false) : t;
} else {
n.m = [];
i.forEach((function(r) {
return n.m.push(r);
t.forEach((function(i) {
return n.m.push(i);
}));

@@ -85,45 +85,20 @@ }

var u = n.o >> 1;
for (var a = n.o - 1 >> 1; a >= 0; --a) {
var o = a;
var f = n.m[o];
while (o < u) {
var s = o << 1 | 1;
var h = s + 1;
var v = n.m[s];
if (h < n.o && n.A(v, n.m[h]) > 0) {
s = h;
v = n.m[h];
}
if (n.A(v, f) >= 0) break;
n.m[o] = v;
o = s;
}
n.m[o] = f;
for (var s = n.o - 1 >> 1; s >= 0; --s) {
n.j(s, u);
}
return n;
}
PriorityQueue.prototype.clear = function() {
this.o = 0;
this.m.length = 0;
};
PriorityQueue.prototype.push = function(r) {
var i = this.o;
this.o += 1;
this.m.push(r);
PriorityQueue.prototype.B = function(i) {
var t = this.m[i];
while (i > 0) {
var t = i - 1 >> 1;
var e = this.m[t];
if (this.A(e, r) <= 0) break;
var r = i - 1 >> 1;
var e = this.m[r];
if (this.A(e, t) <= 0) break;
this.m[i] = e;
i = t;
i = r;
}
this.m[i] = r;
this.m[i] = t;
};
PriorityQueue.prototype.pop = function() {
if (!this.o) return;
var r = this.m.pop();
this.o -= 1;
if (!this.o) return;
var i = 0;
var t = this.o >> 1;
PriorityQueue.prototype.j = function(i, t) {
var r = this.m[i];
while (i < t) {

@@ -133,6 +108,5 @@ var e = i << 1 | 1;

var u = this.m[e];
var a = this.m[n];
if (n < this.o && this.A(u, a) > 0) {
if (n < this.o && this.A(u, this.m[n]) > 0) {
e = n;
u = a;
u = this.m[n];
}

@@ -145,5 +119,52 @@ if (this.A(u, r) >= 0) break;

};
PriorityQueue.prototype.clear = function() {
this.o = 0;
this.m.length = 0;
};
PriorityQueue.prototype.push = function(i) {
this.m.push(i);
this.B(this.o);
this.o += 1;
};
PriorityQueue.prototype.pop = function() {
if (!this.o) return;
var i = this.m.pop();
this.o -= 1;
if (this.o) {
this.m[0] = i;
this.j(0, this.o >> 1);
}
};
PriorityQueue.prototype.top = function() {
return this.m[0];
};
PriorityQueue.prototype.find = function(i) {
return this.m.indexOf(i) >= 0;
};
PriorityQueue.prototype.remove = function(i) {
var t = this.m.indexOf(i);
if (t < 0) return false;
if (t === 0) {
this.pop();
} else if (t === this.o - 1) {
this.m.pop();
this.o -= 1;
} else {
this.m.splice(t, 1, this.m.pop());
this.o -= 1;
this.B(t);
this.j(t, this.o >> 1);
}
return true;
};
PriorityQueue.prototype.updateItem = function(i) {
var t = this.m.indexOf(i);
if (t < 0) return false;
this.B(t);
this.j(t, this.o >> 1);
return true;
};
PriorityQueue.prototype.toArray = function() {
return __spreadArray([], __read(this.m), false);
};
return PriorityQueue;

@@ -150,0 +171,0 @@ }(Base);

@@ -1,6 +0,5 @@

import { ContainerIterator, IteratorType } from "../../ContainerBase";
import { ContainerIterator } from "../../ContainerBase";
export declare abstract class RandomIterator<T> extends ContainerIterator<T> {
pre: () => this;
next: () => this;
constructor(index: number, size: () => number, getElementByPos: (pos: number) => T, setElementByPos: (pos: number, element: T) => void, iteratorType?: IteratorType);
get pointer(): T;

@@ -7,0 +6,0 @@ set pointer(newValue: T);

@@ -172,5 +172,5 @@ var __extends = this && this.t || function() {

r.C = 0;
r.j = 0;
r.O = 0;
r.l = 0;
r.B = [];
r.N = [];
var s;

@@ -188,10 +188,10 @@ if ("size" in i) {

}
r.O = e;
r.l = Math.max(Math.ceil(s / r.O), 1);
r.T = e;
r.l = Math.max(Math.ceil(s / r.T), 1);
for (var h = 0; h < r.l; ++h) {
r.B.push(new Array(r.O));
r.N.push(new Array(r.T));
}
var n = Math.ceil(s / r.O);
var n = Math.ceil(s / r.T);
r.M = r.C = (r.l >> 1) - (n >> 1);
r.k = r.j = r.O - s % r.O >> 1;
r.k = r.O = r.T - s % r.T >> 1;
i.forEach((function(t) {

@@ -209,27 +209,27 @@ return r.pushBack(t);

for (var e = 0; e < i; ++e) {
t[e] = new Array(this.O);
t[e] = new Array(this.T);
}
for (var e = this.M; e < this.l; ++e) {
t[t.length] = this.B[e];
t[t.length] = this.N[e];
}
for (var e = 0; e < this.C; ++e) {
t[t.length] = this.B[e];
t[t.length] = this.N[e];
}
t[t.length] = __spreadArray([], __read(this.B[this.C]), false);
t[t.length] = __spreadArray([], __read(this.N[this.C]), false);
this.M = i;
this.C = t.length - 1;
for (var e = 0; e < i; ++e) {
t[t.length] = new Array(this.O);
t[t.length] = new Array(this.T);
}
this.B = t;
this.N = t;
this.l = t.length;
};
Deque.prototype.N = function(t) {
Deque.prototype.G = function(t) {
var i = this.k + t + 1;
var e = i % this.O;
var e = i % this.T;
var r = e - 1;
var s = this.M + (i - e) / this.O;
var s = this.M + (i - e) / this.T;
if (e === 0) s -= 1;
s %= this.l;
if (r < 0) r += this.O;
if (r < 0) r += this.T;
return {

@@ -241,12 +241,12 @@ curNodeBucketIndex: s,

Deque.prototype.clear = function() {
this.B = [ [] ];
this.N = [ [] ];
this.l = 1;
this.M = this.C = this.o = 0;
this.k = this.j = this.O >> 1;
this.k = this.O = this.T >> 1;
};
Deque.prototype.front = function() {
return this.B[this.M][this.k];
return this.N[this.M][this.k];
};
Deque.prototype.back = function() {
return this.B[this.C][this.j];
return this.N[this.C][this.O];
};

@@ -267,28 +267,28 @@ Deque.prototype.begin = function() {

if (this.o) {
if (this.j < this.O - 1) {
this.j += 1;
if (this.O < this.T - 1) {
this.O += 1;
} else if (this.C < this.l - 1) {
this.C += 1;
this.j = 0;
this.O = 0;
} else {
this.C = 0;
this.j = 0;
this.O = 0;
}
if (this.C === this.M && this.j === this.k) this.v();
if (this.C === this.M && this.O === this.k) this.v();
}
this.o += 1;
this.B[this.C][this.j] = t;
this.N[this.C][this.O] = t;
};
Deque.prototype.popBack = function() {
if (!this.o) return;
this.B[this.C][this.j] = undefined;
this.N[this.C][this.O] = undefined;
if (this.o !== 1) {
if (this.j > 0) {
this.j -= 1;
if (this.O > 0) {
this.O -= 1;
} else if (this.C > 0) {
this.C -= 1;
this.j = this.O - 1;
this.O = this.T - 1;
} else {
this.C = this.l - 1;
this.j = this.O - 1;
this.O = this.T - 1;
}

@@ -304,17 +304,17 @@ }

this.M -= 1;
this.k = this.O - 1;
this.k = this.T - 1;
} else {
this.M = this.l - 1;
this.k = this.O - 1;
this.k = this.T - 1;
}
if (this.M === this.C && this.k === this.j) this.v();
if (this.M === this.C && this.k === this.O) this.v();
}
this.o += 1;
this.B[this.M][this.k] = t;
this.N[this.M][this.k] = t;
};
Deque.prototype.popFront = function() {
if (!this.o) return;
this.B[this.M][this.k] = undefined;
this.N[this.M][this.k] = undefined;
if (this.o !== 1) {
if (this.k < this.O - 1) {
if (this.k < this.T - 1) {
this.k += 1;

@@ -340,4 +340,4 @@ } else if (this.M < this.l - 1) {

}
var i = this.N(t), e = i.curNodeBucketIndex, r = i.curNodePointerIndex;
return this.B[e][r];
var i = this.G(t), e = i.curNodeBucketIndex, r = i.curNodePointerIndex;
return this.N[e][r];
};

@@ -348,4 +348,4 @@ Deque.prototype.setElementByPos = function(t, i) {

}
var e = this.N(t), r = e.curNodeBucketIndex, s = e.curNodePointerIndex;
this.B[r][s] = i;
var e = this.G(t), r = e.curNodeBucketIndex, s = e.curNodePointerIndex;
this.N[r][s] = i;
};

@@ -378,5 +378,5 @@ Deque.prototype.insert = function(t, i, e) {

}
var i = this.N(t), e = i.curNodeBucketIndex, r = i.curNodePointerIndex;
var i = this.G(t), e = i.curNodeBucketIndex, r = i.curNodePointerIndex;
this.C = e;
this.j = r;
this.O = r;
this.o = t + 1;

@@ -464,7 +464,7 @@ };

}));
this.l = Math.max(Math.ceil(this.o / this.O), 1);
this.o = this.M = this.C = this.k = this.j = 0;
this.B = [];
this.l = Math.max(Math.ceil(this.o / this.T), 1);
this.o = this.M = this.C = this.k = this.O = 0;
this.N = [];
for (var i = 0; i < this.l; ++i) {
this.B.push(new Array(this.O));
this.N.push(new Array(this.T));
}

@@ -471,0 +471,0 @@ for (var i = 0; i < t.length; ++i) this.pushBack(t[i]);

import SequentialContainer from './Base';
import { ContainerIterator, initContainer, IteratorType } from "../ContainerBase";
export declare class LinkNode<T> {
value: T | undefined;
pre: LinkNode<T> | undefined;
next: LinkNode<T> | undefined;
constructor(element?: T);
}
import { ContainerIterator, initContainer } from "../ContainerBase";
export declare class LinkListIterator<T> extends ContainerIterator<T> {
pre: () => this;
next: () => this;
constructor(_node: LinkNode<T>, _header: LinkNode<T>, iteratorType?: IteratorType);
get pointer(): T;

@@ -30,3 +23,3 @@ set pointer(newValue: T);

eraseElementByPos(pos: number): void;
eraseElementByValue(value: T): void;
eraseElementByValue(_value: T): void;
eraseElementByIterator(iter: LinkListIterator<T>): LinkListIterator<T>;

@@ -33,0 +26,0 @@ pushBack(element: T): void;

@@ -31,3 +31,3 @@ var __extends = this && this.t || function() {

ops: []
}, e, r, s, h;
}, r, e, s, h;
return h = {

@@ -46,7 +46,7 @@ next: verb(0),

function step(h) {
if (e) throw new TypeError("Generator is already executing.");
if (r) throw new TypeError("Generator is already executing.");
while (n) try {
if (e = 1, r && (s = h[0] & 2 ? r["return"] : h[0] ? r["throw"] || ((s = r["return"]) && s.call(r),
0) : r.next) && !(s = s.call(r, h[1])).done) return s;
if (r = 0, s) h = [ h[0] & 2, s.value ];
if (r = 1, e && (s = h[0] & 2 ? e["return"] : h[0] ? e["throw"] || ((s = e["return"]) && s.call(e),
0) : e.next) && !(s = s.call(e, h[1])).done) return s;
if (e = 0, s) h = [ h[0] & 2, s.value ];
switch (h[0]) {

@@ -67,3 +67,3 @@ case 0:

n.label++;
r = h[1];
e = h[1];
h = [ 0 ];

@@ -103,5 +103,5 @@ continue;

h = [ 6, i ];
r = 0;
e = 0;
} finally {
e = s = 0;
r = s = 0;
}

@@ -122,6 +122,6 @@ if (h[0] & 5) throw h[1];

function LinkNode(i) {
this.value = undefined;
this.pre = undefined;
this.next = undefined;
this.value = i;
this.L = undefined;
this.F = undefined;
this.H = undefined;
this.L = i;
}

@@ -135,51 +135,51 @@ return LinkNode;

__extends(LinkListIterator, i);
function LinkListIterator(t, n, e) {
var r = i.call(this, e) || this;
r.D = t;
r.L = n;
if (r.iteratorType === 0) {
r.pre = function() {
if (this.D.pre === this.L) {
function LinkListIterator(t, n, r) {
var e = i.call(this, r) || this;
e.D = t;
e.J = n;
if (e.iteratorType === 0) {
e.pre = function() {
if (this.D.F === this.J) {
throw new RangeError("LinkList iterator access denied!");
}
this.D = this.D.pre;
this.D = this.D.F;
return this;
};
r.next = function() {
if (this.D === this.L) {
e.next = function() {
if (this.D === this.J) {
throw new RangeError("LinkList iterator access denied!");
}
this.D = this.D.next;
this.D = this.D.H;
return this;
};
} else {
r.pre = function() {
if (this.D.next === this.L) {
e.pre = function() {
if (this.D.H === this.J) {
throw new RangeError("LinkList iterator access denied!");
}
this.D = this.D.next;
this.D = this.D.H;
return this;
};
r.next = function() {
if (this.D === this.L) {
e.next = function() {
if (this.D === this.J) {
throw new RangeError("LinkList iterator access denied!");
}
this.D = this.D.pre;
this.D = this.D.F;
return this;
};
}
return r;
return e;
}
Object.defineProperty(LinkListIterator.prototype, "pointer", {
get: function() {
if (this.D === this.L) {
if (this.D === this.J) {
throw new RangeError("LinkList iterator access denied!");
}
return this.D.value;
return this.D.L;
},
set: function(i) {
if (this.D === this.L) {
if (this.D === this.J) {
throw new RangeError("LinkList iterator access denied!");
}
this.D.value = i;
this.D.L = i;
},

@@ -193,3 +193,3 @@ enumerable: false,

LinkListIterator.prototype.copy = function() {
return new LinkListIterator(this.D, this.L, this.iteratorType);
return new LinkListIterator(this.D, this.J, this.iteratorType);
};

@@ -208,5 +208,5 @@ return LinkListIterator;

var n = i.call(this) || this;
n.L = new LinkNode;
n.T = undefined;
n.G = undefined;
n.J = new LinkNode;
n.K = undefined;
n.U = undefined;
t.forEach((function(i) {

@@ -219,30 +219,30 @@ return n.pushBack(i);

this.o = 0;
this.T = this.G = undefined;
this.L.pre = this.L.next = undefined;
this.K = this.U = undefined;
this.J.F = this.J.H = undefined;
};
LinkList.prototype.begin = function() {
return new LinkListIterator(this.T || this.L, this.L);
return new LinkListIterator(this.K || this.J, this.J);
};
LinkList.prototype.end = function() {
return new LinkListIterator(this.L, this.L);
return new LinkListIterator(this.J, this.J);
};
LinkList.prototype.rBegin = function() {
return new LinkListIterator(this.G || this.L, this.L, 1);
return new LinkListIterator(this.U || this.J, this.J, 1);
};
LinkList.prototype.rEnd = function() {
return new LinkListIterator(this.L, this.L, 1);
return new LinkListIterator(this.J, this.J, 1);
};
LinkList.prototype.front = function() {
return this.T ? this.T.value : undefined;
return this.K ? this.K.L : undefined;
};
LinkList.prototype.back = function() {
return this.G ? this.G.value : undefined;
return this.U ? this.U.L : undefined;
};
LinkList.prototype.forEach = function(i) {
if (!this.o) return;
var t = this.T;
var t = this.K;
var n = 0;
while (t !== this.L) {
i(t.value, n++);
t = t.next;
while (t !== this.J) {
i(t.L, n++);
t = t.H;
}

@@ -254,7 +254,7 @@ };

}
var t = this.T;
var t = this.K;
while (i--) {
t = t.next;
t = t.H;
}
return t.value;
return t.L;
};

@@ -266,11 +266,11 @@ LinkList.prototype.eraseElementByPos = function(i) {

if (i === 0) this.popFront(); else if (i === this.o - 1) this.popBack(); else {
var t = this.T;
var t = this.K;
while (i--) {
t = t.next;
t = t.H;
}
t = t;
var n = t.pre;
var e = t.next;
e.pre = n;
n.next = e;
var n = t.F;
var r = t.H;
r.F = n;
n.H = r;
this.o -= 1;

@@ -280,15 +280,15 @@ }

LinkList.prototype.eraseElementByValue = function(i) {
while (this.T && this.T.value === i) this.popFront();
while (this.G && this.G.value === i) this.popBack();
if (!this.T) return;
var t = this.T;
while (t !== this.L) {
if (t.value === i) {
var n = t.pre;
var e = t.next;
if (e) e.pre = n;
if (n) n.next = e;
while (this.K && this.K.L === i) this.popFront();
while (this.U && this.U.L === i) this.popBack();
if (!this.K) return;
var t = this.K;
while (t !== this.J) {
if (t.L === i) {
var n = t.F;
var r = t.H;
r.F = n;
n.H = r;
this.o -= 1;
}
t = t.next;
t = t.H;
}

@@ -298,11 +298,11 @@ };

var t = i.D;
if (t === this.L) {
if (t === this.J) {
throw new RangeError("Invalid iterator");
}
i = i.next();
if (this.T === t) this.popFront(); else if (this.G === t) this.popBack(); else {
var n = t.pre;
var e = t.next;
if (e) e.pre = n;
if (n) n.next = e;
if (this.K === t) this.popFront(); else if (this.U === t) this.popBack(); else {
var n = t.F;
var r = t.H;
r.F = n;
n.H = r;
this.o -= 1;

@@ -315,26 +315,25 @@ }

var t = new LinkNode(i);
if (!this.G) {
this.T = this.G = t;
this.L.next = this.T;
this.T.pre = this.L;
if (!this.U) {
this.K = this.U = t;
this.J.H = this.K;
this.K.F = this.J;
} else {
this.G.next = t;
t.pre = this.G;
this.G = t;
this.U.H = t;
t.F = this.U;
this.U = t;
}
this.G.next = this.L;
this.L.pre = this.G;
this.U.H = this.J;
this.J.F = this.U;
};
LinkList.prototype.popBack = function() {
if (!this.G) return;
if (!this.U) return;
this.o -= 1;
if (this.T === this.G) {
this.T = this.G = undefined;
this.L.next = undefined;
if (this.K === this.U) {
this.K = this.U = undefined;
this.J.H = undefined;
} else {
this.G = this.G.pre;
if (this.G) this.G.next = undefined;
this.U = this.U.F;
this.U.H = this.J;
}
this.L.pre = this.G;
if (this.G) this.G.next = this.L;
this.J.F = this.U;
};

@@ -345,7 +344,7 @@ LinkList.prototype.setElementByPos = function(i, t) {

}
var n = this.T;
var n = this.K;
while (i--) {
n = n.next;
n = n.H;
}
n.value = t;
n.L = t;
};

@@ -365,25 +364,25 @@ LinkList.prototype.insert = function(i, t, n) {

} else {
var e = this.T;
for (var r = 1; r < i; ++r) {
e = e.next;
var r = this.K;
for (var e = 1; e < i; ++e) {
r = r.H;
}
var s = e.next;
var s = r.H;
this.o += n;
while (n--) {
e.next = new LinkNode(t);
e.next.pre = e;
e = e.next;
r.H = new LinkNode(t);
r.H.F = r;
r = r.H;
}
e.next = s;
if (s) s.pre = e;
r.H = s;
s.F = r;
}
};
LinkList.prototype.find = function(i) {
if (!this.T) return this.end();
var t = this.T;
while (t !== this.L) {
if (t.value === i) {
return new LinkListIterator(t, this.L);
if (!this.K) return this.end();
var t = this.K;
while (t !== this.J) {
if (t.L === i) {
return new LinkListIterator(t, this.J);
}
t = t.next;
t = t.H;
}

@@ -394,11 +393,11 @@ return this.end();

if (this.o <= 1) return;
var i = this.T;
var t = this.G;
var i = this.K;
var t = this.U;
var n = 0;
while (n << 1 < this.o) {
var e = i.value;
i.value = t.value;
t.value = e;
i = i.next;
t = t.pre;
var r = i.L;
i.L = t.L;
t.L = r;
i = i.H;
t = t.F;
n += 1;

@@ -409,12 +408,12 @@ }

if (this.o <= 1) return;
var i = this.T;
while (i !== this.L) {
var i = this.K;
while (i !== this.J) {
var t = i;
while (t.next && t.value === t.next.value) {
t = t.next;
while (t.H && t.L === t.H.L) {
t = t.H;
this.o -= 1;
}
i.next = t.next;
if (i.next) i.next.pre = i;
i = i.next;
i.H = t.H;
i.H.F = i;
i = i.H;
}

@@ -429,6 +428,6 @@ };

t.sort(i);
var n = this.T;
var n = this.K;
t.forEach((function(i) {
n.value = i;
n = n.next;
n.L = i;
n = n.H;
}));

@@ -439,29 +438,29 @@ };

var t = new LinkNode(i);
if (!this.T) {
this.T = this.G = t;
this.G.next = this.L;
this.L.pre = this.G;
if (!this.K) {
this.K = this.U = t;
this.U.H = this.J;
this.J.F = this.U;
} else {
t.next = this.T;
this.T.pre = t;
this.T = t;
t.H = this.K;
this.K.F = t;
this.K = t;
}
this.L.next = this.T;
this.T.pre = this.L;
this.J.H = this.K;
this.K.F = this.J;
};
LinkList.prototype.popFront = function() {
if (!this.T) return;
if (!this.K) return;
this.o -= 1;
if (this.T === this.G) {
this.T = this.G = undefined;
this.L.pre = this.G;
if (this.K === this.U) {
this.K = this.U = undefined;
this.J.F = this.U;
} else {
this.T = this.T.next;
if (this.T) this.T.pre = this.L;
this.K = this.K.H;
this.K.F = this.J;
}
this.L.next = this.T;
this.J.H = this.K;
};
LinkList.prototype.merge = function(i) {
var t = this;
if (!this.T) {
if (!this.K) {
i.forEach((function(i) {

@@ -472,20 +471,20 @@ return t.pushBack(i);

}
var n = this.T;
var n = this.K;
i.forEach((function(i) {
while (n && n !== t.L && n.value <= i) {
n = n.next;
while (n && n !== t.J && n.L <= i) {
n = n.H;
}
if (n === t.L) {
if (n === t.J) {
t.pushBack(i);
n = t.G;
} else if (n === t.T) {
n = t.U;
} else if (n === t.K) {
t.pushFront(i);
n = t.T;
n = t.K;
} else {
t.o += 1;
var e = n.pre;
e.next = new LinkNode(i);
e.next.pre = e;
e.next.next = n;
n.pre = e.next;
var r = n.F;
r.H = new LinkNode(i);
r.H.F = r;
r.H.H = n;
n.F = r.H;
}

@@ -500,13 +499,13 @@ }));

case 0:
if (!this.T) return [ 2 ];
i = this.T;
if (!this.K) return [ 2 ];
i = this.K;
t.label = 1;
case 1:
if (!(i !== this.L)) return [ 3, 3 ];
return [ 4, i.value ];
if (!(i !== this.J)) return [ 3, 3 ];
return [ 4, i.L ];
case 2:
t.sent();
i = i.next;
i = i.H;
return [ 3, 1 ];

@@ -513,0 +512,0 @@

import type TreeIterator from './TreeIterator';
import { Container } from "../../ContainerBase";
declare abstract class TreeContainer<K, V> extends Container<K | [K, V]> {
protected constructor(_cmp?: (x: K, y: K) => number, enableIndex?: boolean);
/**
* @param key The given key you want to compare.
* @return An iterator to the first element not less than the given key.
* @param cmp The compare function.
* @param enableIndex Whether to enable iterator indexing function.
*/
abstract lowerBound(key: K): TreeIterator<K, V>;
protected constructor(cmp?: (x: K, y: K) => number, enableIndex?: boolean);
/**
* @param key The given key you want to compare.
* @return An iterator to the first element greater than the given key.
* @param _key The given _key you want to compare.
* @return An iterator to the first element not less than the given _key.
*/
abstract upperBound(key: K): TreeIterator<K, V>;
abstract lowerBound(_key: K): TreeIterator<K, V>;
/**
* @param key The given key you want to compare.
* @return An iterator to the first element not greater than the given key.
* @param _key The given _key you want to compare.
* @return An iterator to the first element greater than the given _key.
*/
abstract reverseLowerBound(key: K): TreeIterator<K, V>;
abstract upperBound(_key: K): TreeIterator<K, V>;
/**
* @param key The given key you want to compare.
* @return An iterator to the first element less than the given key.
* @param _key The given _key you want to compare.
* @return An iterator to the first element not greater than the given _key.
*/
abstract reverseUpperBound(key: K): TreeIterator<K, V>;
abstract reverseLowerBound(_key: K): TreeIterator<K, V>;
/**
* @param _key The given _key you want to compare.
* @return An iterator to the first element less than the given _key.
*/
abstract reverseUpperBound(_key: K): TreeIterator<K, V>;
/**
* @description Union the other tree to self.
* <br/>
* Waiting for optimization, this is O(mlog(n+m)) algorithm now,
* but we expect it to be O(mlog(n/m+1)).<br/>
* More information =>
* https://en.wikipedia.org/wiki/Red_black_tree
* <br/>
* @param other The other tree container you want to merge.

@@ -38,14 +36,14 @@ */

/**
* @description Update node's key by iterator.
* @description Update node's _key by iterator.
* @param iter The iterator you want to change.
* @param key The key you want to update.
* @param _key The _key you want to update.
* @return Boolean about if the modification is successful.
*/
updateKeyByIterator(iter: TreeIterator<K, V>, key: K): boolean;
updateKeyByIterator(iter: TreeIterator<K, V>, _key: K): boolean;
eraseElementByPos(pos: number): void;
/**
* @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.
*/
eraseElementByKey(key: K): void;
eraseElementByKey(_key: K): void;
eraseElementByIterator(iter: TreeIterator<K, V>): TreeIterator<K, V>;

@@ -52,0 +50,0 @@ /**

@@ -60,22 +60,22 @@ var __extends = this && this.t || function() {

var t = e.call(this) || this;
t.J = undefined;
t.$ = function(e, i) {
t.rr = undefined;
t.ie = function(e, i) {
if (e === undefined) return false;
var r = t.$(e.left, i);
var r = t.ie(e.Y, i);
if (r) return true;
if (i(e)) return true;
return t.$(e.right, i);
return t.ie(e.Z, i);
};
t.A = i;
if (r) {
t.ee = TreeNodeEnableIndex;
t.X = function(e, i, r) {
var t = this.ie(e, i, r);
t.re = TreeNodeEnableIndex;
t.ir = function(e, i, r) {
var t = this.te(e, i, r);
if (t) {
var n = t.parent;
while (n !== this.L) {
n.subTreeSize += 1;
n = n.parent;
var n = t.tt;
while (n !== this.J) {
n.rt += 1;
n = n.tt;
}
var s = this.re(t);
var s = this.ne(t);
if (s) {

@@ -89,103 +89,103 @@ var f = s, h = f.parentNode, u = f.grandParent, a = f.curNode;

};
t.te = function(e) {
var i = this.ne(e);
while (i !== this.L) {
i.subTreeSize -= 1;
i = i.parent;
t.se = function(e) {
var i = this.fe(e);
while (i !== this.J) {
i.rt -= 1;
i = i.tt;
}
};
} else {
t.ee = TreeNode;
t.X = function(e, i, r) {
var t = this.ie(e, i, r);
if (t) this.re(t);
t.re = TreeNode;
t.ir = function(e, i, r) {
var t = this.te(e, i, r);
if (t) this.ne(t);
};
t.te = t.ne;
t.se = t.fe;
}
t.L = new t.ee;
t.J = new t.re;
return t;
}
TreeContainer.prototype.H = function(e, i) {
TreeContainer.prototype.$ = function(e, i) {
var r;
while (e) {
var t = this.A(e.key, i);
var t = this.A(e.W, i);
if (t < 0) {
e = e.right;
e = e.Z;
} else if (t > 0) {
r = e;
e = e.left;
e = e.Y;
} else return e;
}
return r === undefined ? this.L : r;
return r === undefined ? this.J : r;
};
TreeContainer.prototype.K = function(e, i) {
TreeContainer.prototype.er = function(e, i) {
var r;
while (e) {
var t = this.A(e.key, i);
var t = this.A(e.W, i);
if (t <= 0) {
e = e.right;
} else if (t > 0) {
e = e.Z;
} else {
r = e;
e = e.left;
e = e.Y;
}
}
return r === undefined ? this.L : r;
return r === undefined ? this.J : r;
};
TreeContainer.prototype.U = function(e, i) {
TreeContainer.prototype.tr = function(e, i) {
var r;
while (e) {
var t = this.A(e.key, i);
var t = this.A(e.W, i);
if (t < 0) {
r = e;
e = e.right;
e = e.Z;
} else if (t > 0) {
e = e.left;
e = e.Y;
} else return e;
}
return r === undefined ? this.L : r;
return r === undefined ? this.J : r;
};
TreeContainer.prototype.W = function(e, i) {
TreeContainer.prototype.nr = function(e, i) {
var r;
while (e) {
var t = this.A(e.key, i);
var t = this.A(e.W, i);
if (t < 0) {
r = e;
e = e.right;
} else if (t >= 0) {
e = e.left;
e = e.Z;
} else {
e = e.Y;
}
}
return r === undefined ? this.L : r;
return r === undefined ? this.J : r;
};
TreeContainer.prototype.se = function(e) {
TreeContainer.prototype.he = function(e) {
while (true) {
var i = e.parent;
if (i === this.L) return;
if (e.color === 1) {
e.color = 0;
var i = e.tt;
if (i === this.J) return;
if (e.ee === 1) {
e.ee = 0;
return;
}
if (e === i.left) {
var r = i.right;
if (r.color === 1) {
r.color = 0;
i.color = 1;
if (i === this.J) {
this.J = i.rotateLeft();
if (e === i.Y) {
var r = i.Z;
if (r.ee === 1) {
r.ee = 0;
i.ee = 1;
if (i === this.rr) {
this.rr = i.rotateLeft();
} else i.rotateLeft();
} else if (r.color === 0) {
if (r.right && r.right.color === 1) {
r.color = i.color;
i.color = 0;
r.right.color = 0;
if (i === this.J) {
this.J = i.rotateLeft();
} else {
if (r.Z && r.Z.ee === 1) {
r.ee = i.ee;
i.ee = 0;
r.Z.ee = 0;
if (i === this.rr) {
this.rr = i.rotateLeft();
} else i.rotateLeft();
return;
} else if (r.left && r.left.color === 1) {
r.color = 1;
r.left.color = 0;
} else if (r.Y && r.Y.ee === 1) {
r.ee = 1;
r.Y.ee = 0;
r.rotateRight();
} else {
r.color = 1;
r.ee = 1;
e = i;

@@ -195,24 +195,24 @@ }

} else {
var r = i.left;
if (r.color === 1) {
r.color = 0;
i.color = 1;
if (i === this.J) {
this.J = i.rotateRight();
var r = i.Y;
if (r.ee === 1) {
r.ee = 0;
i.ee = 1;
if (i === this.rr) {
this.rr = i.rotateRight();
} else i.rotateRight();
} else {
if (r.left && r.left.color === 1) {
r.color = i.color;
i.color = 0;
r.left.color = 0;
if (i === this.J) {
this.J = i.rotateRight();
if (r.Y && r.Y.ee === 1) {
r.ee = i.ee;
i.ee = 0;
r.Y.ee = 0;
if (i === this.rr) {
this.rr = i.rotateRight();
} else i.rotateRight();
return;
} else if (r.right && r.right.color === 1) {
r.color = 1;
r.right.color = 0;
} else if (r.Z && r.Z.ee === 1) {
r.ee = 1;
r.Z.ee = 0;
r.rotateLeft();
} else {
r.color = 1;
r.ee = 1;
e = i;

@@ -224,68 +224,68 @@ }

};
TreeContainer.prototype.ne = function(e) {
TreeContainer.prototype.fe = function(e) {
var i, r;
if (this.o === 1) {
this.clear();
return this.L;
return this.J;
}
var t = e;
while (t.left || t.right) {
if (t.right) {
t = t.right;
while (t.left) t = t.left;
} else if (t.left) {
t = t.left;
while (t.Y || t.Z) {
if (t.Z) {
t = t.Z;
while (t.Y) t = t.Y;
} else {
t = t.Y;
}
i = __read([ t.key, e.key ], 2), e.key = i[0], t.key = i[1];
r = __read([ t.value, e.value ], 2), e.value = r[0], t.value = r[1];
i = __read([ t.W, e.W ], 2), e.W = i[0], t.W = i[1];
r = __read([ t.L, e.L ], 2), e.L = r[0], t.L = r[1];
e = t;
}
if (this.L.left === t) {
this.L.left = t.parent;
} else if (this.L.right === t) {
this.L.right = t.parent;
if (this.J.Y === t) {
this.J.Y = t.tt;
} else if (this.J.Z === t) {
this.J.Z = t.tt;
}
this.se(t);
var n = t.parent;
if (t === n.left) {
n.left = undefined;
} else n.right = undefined;
this.he(t);
var n = t.tt;
if (t === n.Y) {
n.Y = undefined;
} else n.Z = undefined;
this.o -= 1;
this.J.color = 0;
this.rr.ee = 0;
return n;
};
TreeContainer.prototype.re = function(e) {
TreeContainer.prototype.ne = function(e) {
while (true) {
var i = e.parent;
if (i.color === 0) return;
var r = i.parent;
if (i === r.left) {
var t = r.right;
if (t && t.color === 1) {
t.color = i.color = 0;
if (r === this.J) return;
r.color = 1;
var i = e.tt;
if (i.ee === 0) return;
var r = i.tt;
if (i === r.Y) {
var t = r.Z;
if (t && t.ee === 1) {
t.ee = i.ee = 0;
if (r === this.rr) return;
r.ee = 1;
e = r;
continue;
} else if (e === i.right) {
e.color = 0;
if (e.left) e.left.parent = i;
if (e.right) e.right.parent = r;
i.right = e.left;
r.left = e.right;
e.left = i;
e.right = r;
if (r === this.J) {
this.J = e;
this.L.parent = e;
} else if (e === i.Z) {
e.ee = 0;
if (e.Y) e.Y.tt = i;
if (e.Z) e.Z.tt = r;
i.Z = e.Y;
r.Y = e.Z;
e.Y = i;
e.Z = r;
if (r === this.rr) {
this.rr = e;
this.J.tt = e;
} else {
var n = r.parent;
if (n.left === r) {
n.left = e;
} else n.right = e;
var n = r.tt;
if (n.Y === r) {
n.Y = e;
} else n.Z = e;
}
e.parent = r.parent;
i.parent = e;
r.parent = e;
r.color = 1;
e.tt = r.tt;
i.tt = e;
r.tt = e;
r.ee = 1;
return {

@@ -297,37 +297,37 @@ parentNode: i,

} else {
i.color = 0;
if (r === this.J) {
this.J = r.rotateRight();
i.ee = 0;
if (r === this.rr) {
this.rr = r.rotateRight();
} else r.rotateRight();
r.color = 1;
r.ee = 1;
}
} else {
var t = r.left;
if (t && t.color === 1) {
t.color = i.color = 0;
if (r === this.J) return;
r.color = 1;
var t = r.Y;
if (t && t.ee === 1) {
t.ee = i.ee = 0;
if (r === this.rr) return;
r.ee = 1;
e = r;
continue;
} else if (e === i.left) {
e.color = 0;
if (e.left) e.left.parent = r;
if (e.right) e.right.parent = i;
r.right = e.left;
i.left = e.right;
e.left = r;
e.right = i;
if (r === this.J) {
this.J = e;
this.L.parent = e;
} else if (e === i.Y) {
e.ee = 0;
if (e.Y) e.Y.tt = r;
if (e.Z) e.Z.tt = i;
r.Z = e.Y;
i.Y = e.Z;
e.Y = r;
e.Z = i;
if (r === this.rr) {
this.rr = e;
this.J.tt = e;
} else {
var n = r.parent;
if (n.left === r) {
n.left = e;
} else n.right = e;
var n = r.tt;
if (n.Y === r) {
n.Y = e;
} else n.Z = e;
}
e.parent = r.parent;
i.parent = e;
r.parent = e;
r.color = 1;
e.tt = r.tt;
i.tt = e;
r.tt = e;
r.ee = 1;
return {

@@ -339,7 +339,7 @@ parentNode: i,

} else {
i.color = 0;
if (r === this.J) {
this.J = r.rotateLeft();
i.ee = 0;
if (r === this.rr) {
this.rr = r.rotateLeft();
} else r.rotateLeft();
r.color = 1;
r.ee = 1;
}

@@ -350,57 +350,57 @@ }

};
TreeContainer.prototype.ie = function(e, i, r) {
if (this.J === undefined) {
TreeContainer.prototype.te = function(e, i, r) {
if (this.rr === undefined) {
this.o += 1;
this.J = new this.ee(e, i);
this.J.color = 0;
this.J.parent = this.L;
this.L.parent = this.J;
this.L.left = this.J;
this.L.right = this.J;
this.rr = new this.re(e, i);
this.rr.ee = 0;
this.rr.tt = this.J;
this.J.tt = this.rr;
this.J.Y = this.rr;
this.J.Z = this.rr;
return;
}
var t;
var n = this.L.left;
var s = this.A(n.key, e);
var n = this.J.Y;
var s = this.A(n.W, e);
if (s === 0) {
n.value = i;
n.L = i;
return;
} else if (s > 0) {
n.left = new this.ee(e, i);
n.left.parent = n;
t = n.left;
this.L.left = t;
n.Y = new this.re(e, i);
n.Y.tt = n;
t = n.Y;
this.J.Y = t;
} else {
var f = this.L.right;
var h = this.A(f.key, e);
var f = this.J.Z;
var h = this.A(f.W, e);
if (h === 0) {
f.value = i;
f.L = i;
return;
} else if (h < 0) {
f.right = new this.ee(e, i);
f.right.parent = f;
t = f.right;
this.L.right = t;
f.Z = new this.re(e, i);
f.Z.tt = f;
t = f.Z;
this.J.Z = t;
} else {
if (r !== undefined) {
var u = r.D;
if (u !== this.L) {
var a = this.A(u.key, e);
if (u !== this.J) {
var a = this.A(u.W, e);
if (a === 0) {
u.value = i;
u.L = i;
return;
} else if (a > 0) {
var o = u.pre();
var l = this.A(o.key, e);
var l = this.A(o.W, e);
if (l === 0) {
o.value = i;
o.L = i;
return;
} else if (l < 0) {
t = new this.ee(e, i);
if (o.right === undefined) {
o.right = t;
t.parent = o;
t = new this.re(e, i);
if (o.Z === undefined) {
o.Z = t;
t.tt = o;
} else {
u.left = t;
t.parent = u;
u.Y = t;
t.tt = u;
}

@@ -412,23 +412,23 @@ }

if (t === undefined) {
t = this.J;
t = this.rr;
while (true) {
var d = this.A(t.key, e);
var d = this.A(t.W, e);
if (d > 0) {
if (t.left === undefined) {
t.left = new this.ee(e, i);
t.left.parent = t;
t = t.left;
if (t.Y === undefined) {
t.Y = new this.re(e, i);
t.Y.tt = t;
t = t.Y;
break;
}
t = t.left;
t = t.Y;
} else if (d < 0) {
if (t.right === undefined) {
t.right = new this.ee(e, i);
t.right.parent = t;
t = t.right;
if (t.Z === undefined) {
t.Z = new this.re(e, i);
t.Z.tt = t;
t = t.Z;
break;
}
t = t.right;
t = t.Z;
} else {
t.value = i;
t.L = i;
return;

@@ -445,18 +445,18 @@ }

this.o = 0;
this.J = undefined;
this.L.parent = undefined;
this.L.left = this.L.right = undefined;
this.rr = undefined;
this.J.tt = undefined;
this.J.Y = this.J.Z = undefined;
};
TreeContainer.prototype.updateKeyByIterator = function(e, i) {
var r = e.D;
if (r === this.L) {
if (r === this.J) {
throw new TypeError("Invalid iterator!");
}
if (this.o === 1) {
r.key = i;
r.W = i;
return true;
}
if (r === this.L.left) {
if (this.A(r.next().key, i) > 0) {
r.key = i;
if (r === this.J.Y) {
if (this.A(r.next().W, i) > 0) {
r.W = i;
return true;

@@ -466,5 +466,5 @@ }

}
if (r === this.L.right) {
if (this.A(r.pre().key, i) < 0) {
r.key = i;
if (r === this.J.Z) {
if (this.A(r.pre().W, i) < 0) {
r.W = i;
return true;

@@ -474,7 +474,7 @@ }

}
var t = r.pre().key;
var t = r.pre().W;
if (this.A(t, i) >= 0) return false;
var n = r.next().key;
var n = r.next().W;
if (this.A(n, i) <= 0) return false;
r.key = i;
r.W = i;
return true;

@@ -488,5 +488,5 @@ };

var r = 0;
this.$(this.J, (function(t) {
this.ie(this.rr, (function(t) {
if (e === r) {
i.te(t);
i.se(t);
return true;

@@ -498,9 +498,9 @@ }

};
TreeContainer.prototype.Y = function(e, i) {
TreeContainer.prototype.ar = function(e, i) {
while (e) {
var r = this.A(e.key, i);
var r = this.A(e.W, i);
if (r < 0) {
e = e.right;
e = e.Z;
} else if (r > 0) {
e = e.left;
e = e.Y;
} else return e;

@@ -512,15 +512,15 @@ }

if (!this.o) return;
var i = this.Y(this.J, e);
var i = this.ar(this.rr, e);
if (i === undefined) return;
this.te(i);
this.se(i);
};
TreeContainer.prototype.eraseElementByIterator = function(e) {
var i = e.D;
if (i === this.L) {
if (i === this.J) {
throw new RangeError("Invalid iterator");
}
if (i.right === undefined) {
if (i.Z === undefined) {
e = e.next();
}
this.te(i);
this.se(i);
return e;

@@ -532,5 +532,5 @@ };

if (!e) return 0;
return Math.max(traversal(e.left), traversal(e.right)) + 1;
return Math.max(traversal(e.Y), traversal(e.Z)) + 1;
};
return traversal(this.J);
return traversal(this.rr);
};

@@ -537,0 +537,0 @@ return TreeContainer;

@@ -1,7 +0,12 @@

import { TreeNode } from './TreeNode';
import { ContainerIterator, IteratorType } from "../../ContainerBase";
import { ContainerIterator } from "../../ContainerBase";
declare abstract class TreeIterator<K, V> extends ContainerIterator<K | [K, V]> {
pre: () => this;
next: () => this;
constructor(_node: TreeNode<K, V>, _header: TreeNode<K, V>, iteratorType?: IteratorType);
/**
* @description Get the sequential index of the iterator in the tree container.<br/>
* <strong>
* Note:
* </strong>
* This function only takes effect when the specified tree container `enableIndex = true`.
*/
get index(): number;

@@ -8,0 +13,0 @@ equals(obj: TreeIterator<K, V>): boolean;

@@ -29,6 +29,6 @@ var __extends = this && this.t || function() {

i.D = r;
i.L = e;
i.J = e;
if (i.iteratorType === 0) {
i.pre = function() {
if (this.D === this.L.left) {
if (this.D === this.J.Y) {
throw new RangeError("Tree iterator access denied!");

@@ -40,3 +40,3 @@ }

i.next = function() {
if (this.D === this.L) {
if (this.D === this.J) {
throw new RangeError("Tree iterator access denied!");

@@ -49,3 +49,3 @@ }

i.pre = function() {
if (this.D === this.L.right) {
if (this.D === this.J.Z) {
throw new RangeError("Tree iterator access denied!");

@@ -57,3 +57,3 @@ }

i.next = function() {
if (this.D === this.L) {
if (this.D === this.J) {
throw new RangeError("Tree iterator access denied!");

@@ -70,6 +70,6 @@ }

var t = this.D;
var r = this.L.parent;
if (t === this.L) {
var r = this.J.tt;
if (t === this.J) {
if (r) {
return r.subTreeSize - 1;
return r.rt - 1;
}

@@ -79,11 +79,11 @@ return 0;

var e = 0;
if (t.left) {
e += t.left.subTreeSize;
if (t.Y) {
e += t.Y.rt;
}
while (t !== r) {
var n = t.parent;
if (t === n.right) {
var n = t.tt;
if (t === n.Z) {
e += 1;
if (n.left) {
e += n.left.subTreeSize;
if (n.Y) {
e += n.Y.rt;
}

@@ -90,0 +90,0 @@ }

@@ -1,13 +0,3 @@

export declare const enum TreeNodeColor {
RED = 1,
BLACK = 0
}
export declare class TreeNode<K, V> {
color: TreeNodeColor;
key: K | undefined;
value: V | undefined;
left: TreeNode<K, V> | undefined;
right: TreeNode<K, V> | undefined;
parent: TreeNode<K, V> | undefined;
constructor(key?: K, value?: V);
constructor(_key?: K, _value?: V);
/**

@@ -24,3 +14,3 @@ * @description Get the pre node.

/**
* @description Rotate left.
* @description Rotate _left.
* @return TreeNode about moved to original position after rotation.

@@ -30,3 +20,3 @@ */

/**
* @description Rotate right.
* @description Rotate _right.
* @return TreeNode about moved to original position after rotation.

@@ -37,8 +27,4 @@ */

export declare class TreeNodeEnableIndex<K, V> extends TreeNode<K, V> {
left: TreeNodeEnableIndex<K, V> | undefined;
right: TreeNodeEnableIndex<K, V> | undefined;
parent: TreeNodeEnableIndex<K, V> | undefined;
subTreeSize: number;
/**
* @description Rotate left and do recount.
* @description Rotate _left and do recount.
* @return TreeNode about moved to original position after rotation.

@@ -48,3 +34,3 @@ */

/**
* @description Rotate right and do recount.
* @description Rotate _right and do recount.
* @return TreeNode about moved to original position after rotation.

@@ -51,0 +37,0 @@ */

@@ -24,25 +24,25 @@ var __extends = this && this.t || function() {

function TreeNode(e, n) {
this.color = 1;
this.key = undefined;
this.value = undefined;
this.left = undefined;
this.right = undefined;
this.parent = undefined;
this.key = e;
this.value = n;
this.ee = 1;
this.W = undefined;
this.L = undefined;
this.Y = undefined;
this.Z = undefined;
this.tt = undefined;
this.W = e;
this.L = n;
}
TreeNode.prototype.pre = function() {
var e = this;
if (e.color === 1 && e.parent.parent === e) {
e = e.right;
} else if (e.left) {
e = e.left;
while (e.right) {
e = e.right;
if (e.ee === 1 && e.tt.tt === e) {
e = e.Z;
} else if (e.Y) {
e = e.Y;
while (e.Z) {
e = e.Z;
}
} else {
var n = e.parent;
while (n.left === e) {
var n = e.tt;
while (n.Y === e) {
e = n;
n = e.parent;
n = e.tt;
}

@@ -55,41 +55,41 @@ e = n;

var e = this;
if (e.right) {
e = e.right;
while (e.left) {
e = e.left;
if (e.Z) {
e = e.Z;
while (e.Y) {
e = e.Y;
}
return e;
} else {
var n = e.parent;
while (n.right === e) {
var n = e.tt;
while (n.Z === e) {
e = n;
n = e.parent;
n = e.tt;
}
if (e.right !== n) {
e = n;
}
if (e.Z !== n) {
return n;
} else return e;
}
return e;
};
TreeNode.prototype.rotateLeft = function() {
var e = this.parent;
var n = this.right;
var i = n.left;
if (e.parent === this) e.parent = n; else if (e.left === this) e.left = n; else e.right = n;
n.parent = e;
n.left = this;
this.parent = n;
this.right = i;
if (i) i.parent = this;
var e = this.tt;
var n = this.Z;
var i = n.Y;
if (e.tt === this) e.tt = n; else if (e.Y === this) e.Y = n; else e.Z = n;
n.tt = e;
n.Y = this;
this.tt = n;
this.Z = i;
if (i) i.tt = this;
return n;
};
TreeNode.prototype.rotateRight = function() {
var e = this.parent;
var n = this.left;
var i = n.right;
if (e.parent === this) e.parent = n; else if (e.left === this) e.left = n; else e.right = n;
n.parent = e;
n.right = this;
this.parent = n;
this.left = i;
if (i) i.parent = this;
var e = this.tt;
var n = this.Y;
var i = n.Z;
if (e.tt === this) e.tt = n; else if (e.Y === this) e.Y = n; else e.Z = n;
n.tt = e;
n.Z = this;
this.tt = n;
this.Y = i;
if (i) i.tt = this;
return n;

@@ -106,6 +106,6 @@ };

var n = e !== null && e.apply(this, arguments) || this;
n.left = undefined;
n.right = undefined;
n.parent = undefined;
n.subTreeSize = 1;
n.Y = undefined;
n.Z = undefined;
n.tt = undefined;
n.rt = 1;
return n;

@@ -126,5 +126,5 @@ }

TreeNodeEnableIndex.prototype.recount = function() {
this.subTreeSize = 1;
if (this.left) this.subTreeSize += this.left.subTreeSize;
if (this.right) this.subTreeSize += this.right.subTreeSize;
this.rt = 1;
if (this.Y) this.rt += this.Y.rt;
if (this.Z) this.rt += this.Z.rt;
};

@@ -131,0 +131,0 @@ return TreeNodeEnableIndex;

@@ -9,2 +9,7 @@ import TreeContainer from './Base';

declare class OrderedMap<K, V> extends TreeContainer<K, V> {
/**
* @param container The initialization container.
* @param cmp The compare function.
* @param enableIndex Whether to enable iterator indexing function.
*/
constructor(container?: initContainer<[K, V]>, cmp?: (x: K, y: K) => number, enableIndex?: boolean);

@@ -18,18 +23,18 @@ begin(): OrderedMapIterator<K, V>;

forEach(callback: (element: [K, V], index: number) => void): void;
lowerBound(key: K): OrderedMapIterator<K, V>;
upperBound(key: K): OrderedMapIterator<K, V>;
reverseLowerBound(key: K): OrderedMapIterator<K, V>;
reverseUpperBound(key: K): OrderedMapIterator<K, V>;
lowerBound(_key: K): OrderedMapIterator<K, V>;
upperBound(_key: K): OrderedMapIterator<K, V>;
reverseLowerBound(_key: K): OrderedMapIterator<K, V>;
reverseUpperBound(_key: K): OrderedMapIterator<K, V>;
/**
* @description Insert a key-value pair or set value by the given key.
* @param key The key want to insert.
* @param value The value want to set.
* @description Insert a _key-_value pair or set _value by the given _key.
* @param _key The _key want to insert.
* @param _value The _value want to set.
* @param hint You can give an iterator hint to improve insertion efficiency.
*/
setElement(key: K, value: V, hint?: OrderedMapIterator<K, V>): void;
find(key: K): OrderedMapIterator<K, V>;
setElement(_key: K, _value: V, hint?: OrderedMapIterator<K, V>): void;
find(_key: K): OrderedMapIterator<K, V>;
/**
* @description Get the value of the element of the specified key.
* @description Get the _value of the element of the specified _key.
*/
getElementByKey(key: K): V | undefined;
getElementByKey(_key: K): V | undefined;
getElementByPos(pos: number): [K, V];

@@ -36,0 +41,0 @@ union(other: OrderedMap<K, V>): void;

@@ -159,3 +159,3 @@ var __extends = this && this.t || function() {

var r = this;
if (this.D === this.L) {
if (this.D === this.J) {
throw new RangeError("OrderedMap iterator access denied");

@@ -165,3 +165,3 @@ }

get: function(e, t) {
if (t === "0") return r.D.key; else if (t === "1") return r.D.value;
if (t === "0") return r.D.W; else if (t === "1") return r.D.L;
},

@@ -172,3 +172,3 @@ set: function(e, t, n) {

}
r.D.value = n;
r.D.L = n;
return true;

@@ -182,3 +182,3 @@ }

OrderedMapIterator.prototype.copy = function() {
return new OrderedMapIterator(this.D, this.L, this.iteratorType);
return new OrderedMapIterator(this.D, this.J, this.iteratorType);
};

@@ -197,3 +197,3 @@ return OrderedMapIterator;

var i = r.call(this, t, n) || this;
i.F = function(r) {
i.X = function(r) {
return __generator(this, (function(e) {

@@ -203,11 +203,11 @@ switch (e.label) {

if (r === undefined) return [ 2 ];
return [ 5, __values(this.F(r.left)) ];
return [ 5, __values(this.X(r.Y)) ];
case 1:
e.sent();
return [ 4, [ r.key, r.value ] ];
return [ 4, [ r.W, r.L ] ];
case 2:
e.sent();
return [ 5, __values(this.F(r.right)) ];
return [ 5, __values(this.X(r.Z)) ];

@@ -227,22 +227,22 @@ case 3:

OrderedMap.prototype.begin = function() {
return new OrderedMapIterator(this.L.left || this.L, this.L);
return new OrderedMapIterator(this.J.Y || this.J, this.J);
};
OrderedMap.prototype.end = function() {
return new OrderedMapIterator(this.L, this.L);
return new OrderedMapIterator(this.J, this.J);
};
OrderedMap.prototype.rBegin = function() {
return new OrderedMapIterator(this.L.right || this.L, this.L, 1);
return new OrderedMapIterator(this.J.Z || this.J, this.J, 1);
};
OrderedMap.prototype.rEnd = function() {
return new OrderedMapIterator(this.L, this.L, 1);
return new OrderedMapIterator(this.J, this.J, 1);
};
OrderedMap.prototype.front = function() {
if (!this.o) return undefined;
var r = this.L.left;
return [ r.key, r.value ];
var r = this.J.Y;
return [ r.W, r.L ];
};
OrderedMap.prototype.back = function() {
if (!this.o) return undefined;
var r = this.L.right;
return [ r.key, r.value ];
var r = this.J.Z;
return [ r.W, r.L ];
};

@@ -270,24 +270,24 @@ OrderedMap.prototype.forEach = function(r) {

OrderedMap.prototype.lowerBound = function(r) {
var e = this.H(this.J, r);
return new OrderedMapIterator(e, this.L);
var e = this.$(this.rr, r);
return new OrderedMapIterator(e, this.J);
};
OrderedMap.prototype.upperBound = function(r) {
var e = this.K(this.J, r);
return new OrderedMapIterator(e, this.L);
var e = this.er(this.rr, r);
return new OrderedMapIterator(e, this.J);
};
OrderedMap.prototype.reverseLowerBound = function(r) {
var e = this.U(this.J, r);
return new OrderedMapIterator(e, this.L);
var e = this.tr(this.rr, r);
return new OrderedMapIterator(e, this.J);
};
OrderedMap.prototype.reverseUpperBound = function(r) {
var e = this.W(this.J, r);
return new OrderedMapIterator(e, this.L);
var e = this.nr(this.rr, r);
return new OrderedMapIterator(e, this.J);
};
OrderedMap.prototype.setElement = function(r, e, t) {
this.X(r, e, t);
this.ir(r, e, t);
};
OrderedMap.prototype.find = function(r) {
var e = this.Y(this.J, r);
var e = this.ar(this.rr, r);
if (e !== undefined) {
return new OrderedMapIterator(e, this.L);
return new OrderedMapIterator(e, this.J);
}

@@ -297,4 +297,4 @@ return this.end();

OrderedMap.prototype.getElementByKey = function(r) {
var e = this.Y(this.J, r);
return e ? e.value : undefined;
var e = this.ar(this.rr, r);
return e ? e.L : undefined;
};

@@ -338,3 +338,3 @@ OrderedMap.prototype.getElementByPos = function(r) {

OrderedMap.prototype[Symbol.iterator] = function() {
return this.F(this.J);
return this.X(this.rr);
};

@@ -341,0 +341,0 @@ return OrderedMap;

@@ -9,2 +9,7 @@ import TreeContainer from './Base';

declare class OrderedSet<K> extends TreeContainer<K, undefined> {
/**
* @param container The initialization container.
* @param cmp The compare function.
* @param enableIndex Whether to enable iterator indexing function.
*/
constructor(container?: initContainer<K>, cmp?: (x: K, y: K) => number, enableIndex?: boolean);

@@ -21,11 +26,11 @@ begin(): OrderedSetIterator<K>;

* @description Insert element to set.
* @param key The key want to insert.
* @param _key The _key want to insert.
* @param hint You can give an iterator hint to improve insertion efficiency.
*/
insert(key: K, hint?: OrderedSetIterator<K>): void;
insert(_key: K, hint?: OrderedSetIterator<K>): void;
find(element: K): OrderedSetIterator<K>;
lowerBound(key: K): OrderedSetIterator<K>;
upperBound(key: K): OrderedSetIterator<K>;
reverseLowerBound(key: K): OrderedSetIterator<K>;
reverseUpperBound(key: K): OrderedSetIterator<K>;
lowerBound(_key: K): OrderedSetIterator<K>;
upperBound(_key: K): OrderedSetIterator<K>;
reverseLowerBound(_key: K): OrderedSetIterator<K>;
reverseUpperBound(_key: K): OrderedSetIterator<K>;
union(other: OrderedSet<K>): void;

@@ -32,0 +37,0 @@ [Symbol.iterator](): Generator<K, void, undefined>;

@@ -138,6 +138,6 @@ var __extends = this && this.t || function() {

get: function() {
if (this.D === this.L) {
if (this.D === this.J) {
throw new RangeError("OrderedSet iterator access denied!");
}
return this.D.key;
return this.D.W;
},

@@ -148,3 +148,3 @@ enumerable: false,

OrderedSetIterator.prototype.copy = function() {
return new OrderedSetIterator(this.D, this.L, this.iteratorType);
return new OrderedSetIterator(this.D, this.J, this.iteratorType);
};

@@ -163,3 +163,3 @@ return OrderedSetIterator;

var i = e.call(this, t, n) || this;
i.F = function(e) {
i.X = function(e) {
return __generator(this, (function(r) {

@@ -169,11 +169,11 @@ switch (r.label) {

if (e === undefined) return [ 2 ];
return [ 5, __values(this.F(e.left)) ];
return [ 5, __values(this.X(e.Y)) ];
case 1:
r.sent();
return [ 4, e.key ];
return [ 4, e.W ];
case 2:
r.sent();
return [ 5, __values(this.F(e.right)) ];
return [ 5, __values(this.X(e.Z)) ];

@@ -192,18 +192,18 @@ case 3:

OrderedSet.prototype.begin = function() {
return new OrderedSetIterator(this.L.left || this.L, this.L);
return new OrderedSetIterator(this.J.Y || this.J, this.J);
};
OrderedSet.prototype.end = function() {
return new OrderedSetIterator(this.L, this.L);
return new OrderedSetIterator(this.J, this.J);
};
OrderedSet.prototype.rBegin = function() {
return new OrderedSetIterator(this.L.right || this.L, this.L, 1);
return new OrderedSetIterator(this.J.Z || this.J, this.J, 1);
};
OrderedSet.prototype.rEnd = function() {
return new OrderedSetIterator(this.L, this.L, 1);
return new OrderedSetIterator(this.J, this.J, 1);
};
OrderedSet.prototype.front = function() {
return this.L.left ? this.L.left.key : undefined;
return this.J.Y ? this.J.Y.W : undefined;
};
OrderedSet.prototype.back = function() {
return this.L.right ? this.L.right.key : undefined;
return this.J.Z ? this.J.Z.W : undefined;
};

@@ -260,8 +260,8 @@ OrderedSet.prototype.forEach = function(e) {

OrderedSet.prototype.insert = function(e, r) {
this.X(e, undefined, r);
this.ir(e, undefined, r);
};
OrderedSet.prototype.find = function(e) {
var r = this.Y(this.J, e);
var r = this.ar(this.rr, e);
if (r !== undefined) {
return new OrderedSetIterator(r, this.L);
return new OrderedSetIterator(r, this.J);
}

@@ -271,16 +271,16 @@ return this.end();

OrderedSet.prototype.lowerBound = function(e) {
var r = this.H(this.J, e);
return new OrderedSetIterator(r, this.L);
var r = this.$(this.rr, e);
return new OrderedSetIterator(r, this.J);
};
OrderedSet.prototype.upperBound = function(e) {
var r = this.K(this.J, e);
return new OrderedSetIterator(r, this.L);
var r = this.er(this.rr, e);
return new OrderedSetIterator(r, this.J);
};
OrderedSet.prototype.reverseLowerBound = function(e) {
var r = this.U(this.J, e);
return new OrderedSetIterator(r, this.L);
var r = this.tr(this.rr, e);
return new OrderedSetIterator(r, this.J);
};
OrderedSet.prototype.reverseUpperBound = function(e) {
var r = this.W(this.J, e);
return new OrderedSetIterator(r, this.L);
var r = this.nr(this.rr, e);
return new OrderedSetIterator(r, this.J);
};

@@ -294,3 +294,3 @@ OrderedSet.prototype.union = function(e) {

OrderedSet.prototype[Symbol.iterator] = function() {
return this.F(this.J);
return this.X(this.rr);
};

@@ -297,0 +297,0 @@ return OrderedSet;

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("sdsl",["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var I=function(t,e){return(I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}I(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function f(i,n){var o,s,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(r){return function(t){var e=[r,t];if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,s&&(h=2&e[0]?s.return:e[0]?s.throw||((h=s.return)&&h.call(s),0):s.next)&&!(h=h.call(s,e[1])).done)return h;switch(s=0,(e=h?[2&e[0],h.value]:e)[0]){case 0:case 1:h=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,s=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!h||e[1]>h[0]&&e[1]<h[3]))u.label=e[1];else if(6===e[0]&&u.label<h[1])u.label=h[1],h=e;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(e)}}e=n.call(i,u)}catch(t){e=[6,t],s=0}finally{o=h=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function p(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&i>=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function l(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||((i=i||Array.prototype.slice.call(e,0,n))[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function D(t){this.iteratorType=t=void 0===t?0:t}N.prototype.size=function(){return this.t},N.prototype.empty=function(){return 0===this.t};var r=N;function N(){this.t=0}e(j,_=r);var _,i=j;function j(){return null!==_&&_.apply(this,arguments)||this}e(n,A=r),n.prototype.clear=function(){this.t=0,this.i.length=0},n.prototype.push=function(t){this.i.push(t),this.t+=1},n.prototype.pop=function(){this.i.pop(),0<this.t&&--this.t},n.prototype.top=function(){return this.i[this.t-1]};var A,F=n;function n(t){void 0===t&&(t=[]);var e=A.call(this)||this;return e.i=[],t.forEach(function(t){return e.push(t)}),e}e($,K=i);var K,o=$;function $(){return null!==K&&K.apply(this,arguments)||this}e(s,Y=D),Object.defineProperty(s.prototype,"pointer",{get:function(){return this.o(this.h)},set:function(t){this.v(this.h,t)},enumerable:!1,configurable:!0}),s.prototype.equals=function(t){return this.h===t.h};var Y,H=s;function s(t,e,r,i,n){n=Y.call(this,n)||this;return n.h=t,n.u=e,n.o=r,n.v=i,0===n.iteratorType?(n.pre=function(){if(0===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this},n.next=function(){if(this.h===this.u())throw new RangeError("Random Iterator access denied!");return this.h+=1,this}):(n.pre=function(){if(this.h===this.u()-1)throw new RangeError("Random iterator access denied!");return this.h+=1,this},n.next=function(){if(-1===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this}),n}e(X,U=H),X.prototype.copy=function(){return new X(this.h,this.u,this.o,this.v,this.iteratorType)};var U,h=X;function X(){return null!==U&&U.apply(this,arguments)||this}e(u,G=o),u.prototype.I=function(){for(var t=[],e=Math.max(this.O>>1,1),r=0;r<e;++r)t[r]=new Array(this.S);for(r=this.l;r<this.O;++r)t[t.length]=this.k[r];for(r=0;r<this.L;++r)t[t.length]=this.k[r];t[t.length]=l([],c(this.k[this.L]),!1),this.l=e,this.L=t.length-1;for(r=0;r<e;++r)t[t.length]=new Array(this.S);this.k=t,this.O=t.length},u.prototype.g=function(t){var t=this._+t+1,e=t%this.S,r=e-1,t=this.l+(t-e)/this.S;return 0==e&&--t,t%=this.O,r<0&&(r+=this.S),{curNodeBucketIndex:t,curNodePointerIndex:r}},u.prototype.clear=function(){this.k=[[]],this.O=1,this.l=this.L=this.t=0,this._=this.p=this.S>>1},u.prototype.front=function(){return this.k[this.l][this._]},u.prototype.back=function(){return this.k[this.L][this.p]},u.prototype.begin=function(){return new h(0,this.size,this.getElementByPos,this.setElementByPos)},u.prototype.end=function(){return new h(this.t,this.size,this.getElementByPos,this.setElementByPos)},u.prototype.rBegin=function(){return new h(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},u.prototype.rEnd=function(){return new h(-1,this.size,this.getElementByPos,this.setElementByPos,1)},u.prototype.pushBack=function(t){this.t&&(this.p<this.S-1?this.p+=1:(this.L<this.O-1?this.L+=1:this.L=0,this.p=0),this.L===this.l&&this.p===this._&&this.I()),this.t+=1,this.k[this.L][this.p]=t},u.prototype.popBack=function(){this.t&&(this.k[this.L][this.p]=void 0,1!==this.t&&(0<this.p?--this.p:(0<this.L?--this.L:this.L=this.O-1,this.p=this.S-1)),--this.t)},u.prototype.pushFront=function(t){this.t&&(0<this._?--this._:(0<this.l?--this.l:this.l=this.O-1,this._=this.S-1),this.l===this.L&&this._===this.p&&this.I()),this.t+=1,this.k[this.l][this._]=t},u.prototype.popFront=function(){this.t&&(this.k[this.l][this._]=void 0,1!==this.t&&(this._<this.S-1?this._+=1:(this.l<this.O-1?this.l+=1:this.l=0,this._=0)),--this.t)},u.prototype.forEach=function(t){for(var e=0;e<this.t;++e)t(this.getElementByPos(e),e)},u.prototype.getElementByPos=function(t){var t=this.g(t),e=t.curNodeBucketIndex,t=t.curNodePointerIndex;return this.k[e][t]},u.prototype.setElementByPos=function(t,e){var t=this.g(t),r=t.curNodeBucketIndex,t=t.curNodePointerIndex;this.k[r][t]=e},u.prototype.insert=function(t,e,r){if(void 0===r&&(r=1),0===t)for(;r--;)this.pushFront(e);else if(t===this.t)for(;r--;)this.pushBack(e);else{for(var i=[],n=t;n<this.t;++n)i.push(this.getElementByPos(n));this.cut(t-1);for(n=0;n<r;++n)this.pushBack(e);for(n=0;n<i.length;++n)this.pushBack(i[n])}},u.prototype.cut=function(t){var e,r;t<0?this.clear():(e=(r=this.g(t)).curNodeBucketIndex,r=r.curNodePointerIndex,this.L=e,this.p=r,this.t=t+1)},u.prototype.eraseElementByPos=function(t){var e=this;if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var r=[],i=t+1;i<this.t;++i)r.push(this.getElementByPos(i));this.cut(t),this.popBack(),r.forEach(function(t){return e.pushBack(t)})}},u.prototype.eraseElementByValue=function(t){if(this.t){for(var e=[],r=0;r<this.t;++r){var i=this.getElementByPos(r);i!==t&&e.push(i)}for(var n=e.length,r=0;r<n;++r)this.setElementByPos(r,e[r]);this.cut(n-1)}},u.prototype.eraseElementByIterator=function(t){var e=t.h;return this.eraseElementByPos(e),t=t.next()},u.prototype.find=function(t){for(var e=0;e<this.t;++e)if(this.getElementByPos(e)===t)return new h(e,this.size,this.getElementByPos,this.setElementByPos);return this.end()},u.prototype.reverse=function(){for(var t=0,e=this.t-1;t<e;){var r=this.getElementByPos(t);this.setElementByPos(t,this.getElementByPos(e)),this.setElementByPos(e,r),t+=1,--e}},u.prototype.unique=function(){if(!(this.t<=1)){for(var t=1,e=this.getElementByPos(0),r=1;r<this.t;++r){var i=this.getElementByPos(r);i!==e&&this.setElementByPos(t++,e=i)}for(;this.t>t;)this.popBack()}},u.prototype.sort=function(t){for(var e=[],r=0;r<this.t;++r)e.push(this.getElementByPos(r));e.sort(t);for(r=0;r<this.t;++r)this.setElementByPos(r,e[r])},u.prototype.shrinkToFit=function(){if(this.t){var e=[];this.forEach(function(t){return e.push(t)}),this.O=Math.max(Math.ceil(this.t/this.S),1),this.t=this.l=this.L=this._=this.p=0,this.k=[];for(var t=0;t<this.O;++t)this.k.push(new Array(this.S));for(t=0;t<e.length;++t)this.pushBack(e[t])}},u.prototype[Symbol.iterator]=function(){return function(){var e;return f(this,function(t){switch(t.label){case 0:e=0,t.label=1;case 1:return e<this.t?[4,this.getElementByPos(e)]:[3,4];case 2:t.sent(),t.label=3;case 3:return++e,[3,1];case 4:return[2]}})}.bind(this)()};var G,J=u;function u(t,e){void 0===t&&(t=[]),void 0===e&&(e=4096);var r,i=G.call(this)||this;if(i.l=0,i._=0,i.L=0,i.p=0,i.O=0,i.k=[],"size"in t)r="number"==typeof t.size?t.size:t.size();else{if(!("length"in t))throw new RangeError("Can't get container's size!");r=t.length}i.S=e,i.O=Math.max(Math.ceil(r/i.S),1);for(var n=0;n<i.O;++n)i.k.push(new Array(i.S));e=Math.ceil(r/i.S);return i.l=i.L=(i.O>>1)-(e>>1),i._=i.p=i.S-r%i.S>>1,t.forEach(function(t){return i.pushBack(t)}),i.size=i.size.bind(i),i.getElementByPos=i.getElementByPos.bind(i),i.setElementByPos=i.setElementByPos.bind(i),i}e(a,Q=r),a.prototype.clear=function(){this.T.clear(),this.t=0},a.prototype.push=function(t){this.T.pushBack(t),this.t+=1},a.prototype.pop=function(){this.T.popFront(),this.t&&--this.t},a.prototype.front=function(){return this.T.front()};var Q,W=a;function a(t){void 0===t&&(t=[]);var e=Q.call(this)||this;return e.T=new J(t),e.t=e.T.size(),e}e(y,Z=r),y.prototype.clear=function(){this.t=0,this.q.length=0},y.prototype.push=function(t){var e=this.t;for(this.t+=1,this.q.push(t);0<e;){var r=e-1>>1,i=this.q[r];if(this.M(i,t)<=0)break;this.q[e]=i,e=r}this.q[e]=t},y.prototype.pop=function(){if(this.t){var t=this.q.pop();if(--this.t,this.t){for(var e=0,r=this.t>>1;e<r;){var i=e<<1|1,n=i+1,o=this.q[i],s=this.q[n];if(n<this.t&&0<this.M(o,s)&&(i=n,o=s),0<=this.M(o,t))break;this.q[e]=o,e=i}this.q[e]=t}}},y.prototype.top=function(){return this.q[0]};var Z,tt=y;function y(t,e,r){void 0===t&&(t=[]),void 0===e&&(e=function(t,e){return e<t?-1:t<e?1:0}),void 0===r&&(r=!0);for(var i=Z.call(this)||this,n=(i.M=e,Array.isArray(t)?i.q=r?l([],c(t),!1):t:(i.q=[],t.forEach(function(t){return i.q.push(t)})),i.t=i.q.length,i.t>>1),o=i.t-1>>1;0<=o;--o){for(var s=o,h=i.q[s];s<n;){var u=s<<1|1,a=u+1,f=i.q[u];if(a<i.t&&0<i.M(f,i.q[a])&&(f=i.q[u=a]),0<=i.M(f,h))break;i.q[s]=f,s=u}i.q[s]=h}return i}e(rt,et=H),rt.prototype.copy=function(){return new rt(this.h,this.u,this.o,this.v,this.iteratorType)};var et,v=rt;function rt(){return null!==et&&et.apply(this,arguments)||this}e(m,it=o),m.prototype.clear=function(){this.t=0,this.D.length=0},m.prototype.begin=function(){return new v(0,this.size,this.getElementByPos,this.setElementByPos)},m.prototype.end=function(){return new v(this.t,this.size,this.getElementByPos,this.setElementByPos)},m.prototype.rBegin=function(){return new v(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},m.prototype.rEnd=function(){return new v(-1,this.size,this.getElementByPos,this.setElementByPos,1)},m.prototype.front=function(){return this.D[0]},m.prototype.back=function(){return this.D[this.t-1]},m.prototype.forEach=function(t){for(var e=0;e<this.t;++e)t(this.D[e],e)},m.prototype.getElementByPos=function(t){return this.D[t]},m.prototype.eraseElementByPos=function(t){this.D.splice(t,1),--this.t},m.prototype.eraseElementByValue=function(t){for(var e=0,r=0;r<this.t;++r)this.D[r]!==t&&(this.D[e++]=this.D[r]);this.t=this.D.length=e},m.prototype.eraseElementByIterator=function(t){var e=t.h;return t=t.next(),this.eraseElementByPos(e),t},m.prototype.pushBack=function(t){this.D.push(t),this.t+=1},m.prototype.popBack=function(){this.t&&(this.D.pop(),--this.t)},m.prototype.setElementByPos=function(t,e){this.D[t]=e},m.prototype.insert=function(t,e,r){var i;void 0===r&&(r=1),(i=this.D).splice.apply(i,l([t,0],c(new Array(r).fill(e)),!1)),this.t+=r},m.prototype.find=function(t){for(var e=0;e<this.t;++e)if(this.D[e]===t)return new v(e,this.size,this.getElementByPos,this.getElementByPos);return this.end()},m.prototype.reverse=function(){this.D.reverse()},m.prototype.unique=function(){for(var t=1,e=1;e<this.t;++e)this.D[e]!==this.D[e-1]&&(this.D[t++]=this.D[e]);this.t=this.D.length=t},m.prototype.sort=function(t){this.D.sort(t)},m.prototype[Symbol.iterator]=function(){return function(){return f(this,function(t){switch(t.label){case 0:return[5,p(this.D)];case 1:return[2,t.sent()]}})}.bind(this)()};var it,d=m;function m(t,e){void 0===t&&(t=[]),void 0===e&&(e=!0);var r=it.call(this)||this;return Array.isArray(t)?(r.D=e?l([],c(t),!1):t,r.t=t.length):(r.D=[],t.forEach(function(t){return r.pushBack(t)})),r.size=r.size.bind(r),r.getElementByPos=r.getElementByPos.bind(r),r.setElementByPos=r.setElementByPos.bind(r),r}var nt,g=function(t){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=t},w=(e(E,nt=D),Object.defineProperty(E.prototype,"pointer",{get:function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h.value},set:function(t){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");this.h.value=t},enumerable:!1,configurable:!0}),E.prototype.equals=function(t){return this.h===t.h},E.prototype.copy=function(){return new E(this.h,this.m,this.iteratorType)},E);function E(t,e,r){r=nt.call(this,r)||this;return r.h=t,r.m=e,0===r.iteratorType?(r.pre=function(){if(this.h.pre===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.pre,this},r.next=function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.next,this}):(r.pre=function(){if(this.h.next===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.next,this},r.next=function(){if(this.h===this.m)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.pre,this}),r}e(B,ot=o),B.prototype.clear=function(){this.t=0,this.C=this.R=void 0,this.m.pre=this.m.next=void 0},B.prototype.begin=function(){return new w(this.C||this.m,this.m)},B.prototype.end=function(){return new w(this.m,this.m)},B.prototype.rBegin=function(){return new w(this.R||this.m,this.m,1)},B.prototype.rEnd=function(){return new w(this.m,this.m,1)},B.prototype.front=function(){return this.C?this.C.value:void 0},B.prototype.back=function(){return this.R?this.R.value:void 0},B.prototype.forEach=function(t){if(this.t)for(var e=this.C,r=0;e!==this.m;)t(e.value,r++),e=e.next},B.prototype.getElementByPos=function(t){for(var e=this.C;t--;)e=e.next;return e.value},B.prototype.eraseElementByPos=function(t){if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var e=this.C;t--;)e=e.next;var r=e.pre,i=e.next;(i.pre=r).next=i,--this.t}},B.prototype.eraseElementByValue=function(t){for(;this.C&&this.C.value===t;)this.popFront();for(;this.R&&this.R.value===t;)this.popBack();if(this.C)for(var e,r,i=this.C;i!==this.m;)i.value===t&&(e=i.pre,(r=i.next)&&(r.pre=e),e&&(e.next=r),--this.t),i=i.next},B.prototype.eraseElementByIterator=function(t){var e,r=t.h;if(r===this.m)throw new RangeError("Invalid iterator");return t=t.next(),this.C===r?this.popFront():this.R===r?this.popBack():(e=r.pre,(r=r.next)&&(r.pre=e),e&&(e.next=r),--this.t),t},B.prototype.pushBack=function(t){this.t+=1;t=new g(t);this.R?((this.R.next=t).pre=this.R,this.R=t):(this.C=this.R=t,this.m.next=this.C,this.C.pre=this.m),this.R.next=this.m,this.m.pre=this.R},B.prototype.popBack=function(){this.R&&(--this.t,this.C===this.R?(this.C=this.R=void 0,this.m.next=void 0):(this.R=this.R.pre,this.R&&(this.R.next=void 0)),this.m.pre=this.R,this.R&&(this.R.next=this.m))},B.prototype.setElementByPos=function(t,e){for(var r=this.C;t--;)r=r.next;r.value=e},B.prototype.insert=function(t,e,r){if(!((r=void 0===r?1:r)<=0))if(0===t)for(;r--;)this.pushFront(e);else if(t===this.t)for(;r--;)this.pushBack(e);else{for(var i=this.C,n=1;n<t;++n)i=i.next;var o=i.next;for(this.t+=r;r--;)i.next=new g(e),i=(i.next.pre=i).next;(i.next=o)&&(o.pre=i)}},B.prototype.find=function(t){if(this.C)for(var e=this.C;e!==this.m;){if(e.value===t)return new w(e,this.m);e=e.next}return this.end()},B.prototype.reverse=function(){if(!(this.t<=1))for(var t=this.C,e=this.R,r=0;r<<1<this.t;){var i=t.value;t.value=e.value,e.value=i,t=t.next,e=e.pre,r+=1}},B.prototype.unique=function(){if(!(this.t<=1))for(var t=this.C;t!==this.m;){for(var e=t;e.next&&e.value===e.next.value;)e=e.next,--this.t;t.next=e.next,t.next&&(t.next.pre=t),t=t.next}},B.prototype.sort=function(t){var e,r;this.t<=1||(e=[],this.forEach(function(t){return e.push(t)}),e.sort(t),r=this.C,e.forEach(function(t){r.value=t,r=r.next}))},B.prototype.pushFront=function(t){this.t+=1;t=new g(t);this.C?(t.next=this.C,this.C.pre=t,this.C=t):(this.C=this.R=t,this.R.next=this.m,this.m.pre=this.R),this.m.next=this.C,this.C.pre=this.m},B.prototype.popFront=function(){this.C&&(--this.t,this.C===this.R?(this.C=this.R=void 0,this.m.pre=this.R):(this.C=this.C.next,this.C&&(this.C.pre=this.m)),this.m.next=this.C)},B.prototype.merge=function(t){var r,i=this;this.C?(r=this.C,t.forEach(function(t){for(;r&&r!==i.m&&r.value<=t;)r=r.next;var e;r===i.m?(i.pushBack(t),r=i.R):r===i.C?(i.pushFront(t),r=i.C):(i.t+=1,(e=r.pre).next=new g(t),((e.next.pre=e).next.next=r).pre=e.next)})):t.forEach(function(t){return i.pushBack(t)})},B.prototype[Symbol.iterator]=function(){return function(){var e;return f(this,function(t){switch(t.label){case 0:if(!this.C)return[2];e=this.C,t.label=1;case 1:return e===this.m?[3,3]:[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})}.bind(this)()};var ot,H=B;function B(t){void 0===t&&(t=[]);var e=ot.call(this)||this;return e.m=new g,e.C=void 0,e.R=void 0,t.forEach(function(t){return e.pushBack(t)}),e}b.prototype.pre=function(){var t=this;if(1===t.color&&t.parent.parent===t)t=t.right;else if(t.left)for(t=t.left;t.right;)t=t.right;else{for(var e=t.parent;e.left===t;)e=(t=e).parent;t=e}return t},b.prototype.next=function(){var t=this;if(t.right)for(t=t.right;t.left;)t=t.left;else{for(var e=t.parent;e.right===t;)e=(t=e).parent;t.right!==e&&(t=e)}return t},b.prototype.rotateLeft=function(){var t=this.parent,e=this.right,r=e.left;return t.parent===this?t.parent=e:t.left===this?t.left=e:t.right=e,e.parent=t,(e.left=this).parent=e,(this.right=r)&&(r.parent=this),e},b.prototype.rotateRight=function(){var t=this.parent,e=this.left,r=e.right;return t.parent===this?t.parent=e:t.left===this?t.left=e:t.right=e,e.parent=t,(e.right=this).parent=e,(this.left=r)&&(r.parent=this),e};var st=b;function b(t,e){this.color=1,this.key=void 0,this.value=void 0,this.left=void 0,this.right=void 0,this.parent=void 0,this.key=t,this.value=e}e(k,x=st),k.prototype.rotateLeft=function(){var t=x.prototype.rotateLeft.call(this);return this.recount(),t.recount(),t},k.prototype.rotateRight=function(){var t=x.prototype.rotateRight.call(this);return this.recount(),t.recount(),t},k.prototype.recount=function(){this.subTreeSize=1,this.left&&(this.subTreeSize+=this.left.subTreeSize),this.right&&(this.subTreeSize+=this.right.subTreeSize)};var x,ht=k;function k(){var t=null!==x&&x.apply(this,arguments)||this;return t.left=void 0,t.right=void 0,t.parent=void 0,t.subTreeSize=1,t}e(P,ut=i),P.prototype.J=function(t,e){for(var r;t;){var i=this.M(t.key,e);if(i<0)t=t.right;else{if(!(0<i))return t;t=(r=t).left}}return void 0===r?this.m:r},P.prototype.F=function(t,e){for(var r;t;){var i=this.M(t.key,e);i<=0?t=t.right:0<i&&(t=(r=t).left)}return void 0===r?this.m:r},P.prototype.K=function(t,e){for(var r;t;){var i=this.M(t.key,e);if(i<0)t=(r=t).right;else{if(!(0<i))return t;t=t.left}}return void 0===r?this.m:r},P.prototype.U=function(t,e){for(var r;t;){var i=this.M(t.key,e);i<0?t=(r=t).right:0<=i&&(t=t.left)}return void 0===r?this.m:r},P.prototype.W=function(t){for(;;){var e,r=t.parent;if(r===this.m)return;if(1===t.color)return void(t.color=0);if(t===r.left){if(1===(e=r.right).color)e.color=0,r.color=1,r===this.V?this.V=r.rotateLeft():r.rotateLeft();else if(0===e.color){if(e.right&&1===e.right.color)return e.color=r.color,r.color=0,e.right.color=0,void(r===this.V?this.V=r.rotateLeft():r.rotateLeft());e.left&&1===e.left.color?(e.color=1,e.left.color=0,e.rotateRight()):(e.color=1,t=r)}}else if(1===(e=r.left).color)e.color=0,r.color=1,r===this.V?this.V=r.rotateRight():r.rotateRight();else{if(e.left&&1===e.left.color)return e.color=r.color,r.color=0,e.left.color=0,void(r===this.V?this.V=r.rotateRight():r.rotateRight());e.right&&1===e.right.color?(e.color=1,e.right.color=0,e.rotateLeft()):(e.color=1,t=r)}}},P.prototype.G=function(t){var e;if(1===this.t)return this.clear(),this.m;for(var r=t;r.left||r.right;){if(r.right)for(r=r.right;r.left;)r=r.left;else r.left&&(r=r.left);e=c([r.key,t.key],2),t.key=e[0],r.key=e[1],e=c([r.value,t.value],2),t.value=e[0],r.value=e[1],t=r}this.m.left===r?this.m.left=r.parent:this.m.right===r&&(this.m.right=r.parent),this.W(r);var i=r.parent;return r===i.left?i.left=void 0:i.right=void 0,--this.t,this.V.color=0,i},P.prototype.P=function(t){for(;;){var e=t.parent;if(0===e.color)return;var r,i,n=e.parent;if(e===n.left){if((r=n.right)&&1===r.color){if(r.color=e.color=0,n===this.V)return;n.color=1,t=n;continue}if(t===e.right)return t.color=0,t.left&&(t.left.parent=e),t.right&&(t.right.parent=n),e.right=t.left,n.left=t.right,t.left=e,(t.right=n)===this.V?(this.V=t,this.m.parent=t):(i=n.parent).left===n?i.left=t:i.right=t,t.parent=n.parent,e.parent=t,n.parent=t,n.color=1,{parentNode:e,grandParent:n,curNode:t};e.color=0,n===this.V?this.V=n.rotateRight():n.rotateRight()}else{if((r=n.left)&&1===r.color){if(r.color=e.color=0,n===this.V)return;n.color=1,t=n;continue}if(t===e.left)return t.color=0,t.left&&(t.left.parent=n),t.right&&(t.right.parent=e),n.right=t.left,e.left=t.right,t.left=n,t.right=e,n===this.V?(this.V=t,this.m.parent=t):(i=n.parent).left===n?i.left=t:i.right=t,t.parent=n.parent,e.parent=t,n.parent=t,n.color=1,{parentNode:e,grandParent:n,curNode:t};e.color=0,n===this.V?this.V=n.rotateLeft():n.rotateLeft()}return void(n.color=1)}},P.prototype.A=function(t,e,r){if(void 0===this.V)this.t+=1,this.V=new this.N(t,e),this.V.color=0,this.V.parent=this.m,this.m.parent=this.V,this.m.left=this.V,this.m.right=this.V;else{var i,n=this.m.left,o=this.M(n.key,t);if(0!==o){if(0<o)n.left=new this.N(t,e),i=(n.left.parent=n).left,this.m.left=i;else{var o=this.m.right,s=this.M(o.key,t);if(0===s)return void(o.value=e);if(s<0)o.right=new this.N(t,e),i=(o.right.parent=o).right,this.m.right=i;else{if(void 0!==r){s=r.h;if(s!==this.m){o=this.M(s.key,t);if(0===o)return void(s.value=e);if(0<o){r=s.pre(),o=this.M(r.key,t);if(0===o)return void(r.value=e);o<0&&(i=new this.N(t,e),void 0===r.right?(r.right=i).parent=r:(s.left=i).parent=s)}}}if(void 0===i)for(i=this.V;;){var h=this.M(i.key,t);if(0<h){if(void 0===i.left){i.left=new this.N(t,e),i=(i.left.parent=i).left;break}i=i.left}else{if(!(h<0))return void(i.value=e);if(void 0===i.right){i.right=new this.N(t,e),i=(i.right.parent=i).right;break}i=i.right}}}}return this.t+=1,i}n.value=e}},P.prototype.clear=function(){this.t=0,this.V=void 0,this.m.parent=void 0,this.m.left=this.m.right=void 0},P.prototype.updateKeyByIterator=function(t,e){t=t.h;if(t===this.m)throw new TypeError("Invalid iterator!");if(1!==this.t){if(t===this.m.left)return 0<this.M(t.next().key,e)&&(t.key=e,!0);if(t===this.m.right)return this.M(t.pre().key,e)<0&&(t.key=e,!0);var r=t.pre().key;if(0<=this.M(r,e))return!1;if(r=t.next().key,this.M(r,e)<=0)return!1}return t.key=e,!0},P.prototype.eraseElementByPos=function(e){var r=this,i=0;this.H(this.V,function(t){return e===i?(r.B(t),!0):(i+=1,!1)})},P.prototype.X=function(t,e){for(;t;){var r=this.M(t.key,e);if(r<0)t=t.right;else{if(!(0<r))return t;t=t.left}}return t},P.prototype.eraseElementByKey=function(t){!this.t||void 0!==(t=this.X(this.V,t))&&this.B(t)},P.prototype.eraseElementByIterator=function(t){var e=t.h;if(e===this.m)throw new RangeError("Invalid iterator");return void 0===e.right&&(t=t.next()),this.B(e),t},P.prototype.getHeight=function(){var e;return this.t?(e=function(t){return t?Math.max(e(t.left),e(t.right))+1:0})(this.V):0};var ut,o=P;function P(t,e){void 0===t&&(t=function(t,e){return t<e?-1:e<t?1:0}),void 0===e&&(e=!1);var r=ut.call(this)||this;return r.V=void 0,r.H=function(t,e){return void 0!==t&&(!!r.H(t.left,e)||(!!e(t)||r.H(t.right,e)))},r.M=t,e?(r.N=ht,r.j=function(t,e,r){t=this.A(t,e,r);if(t){for(var i=t.parent;i!==this.m;)i.subTreeSize+=1,i=i.parent;var e=this.P(t);e&&(r=e.parentNode,t=e.grandParent,e=e.curNode,r.recount(),t.recount(),e.recount())}},r.B=function(t){for(var e=this.G(t);e!==this.m;)--e.subTreeSize,e=e.parent}):(r.N=st,r.j=function(t,e,r){t=this.A(t,e,r);t&&this.P(t)},r.B=r.G),r.m=new r.N,r}e(ft,at=D),Object.defineProperty(ft.prototype,"index",{get:function(){var t=this.h,e=this.m.parent;if(t===this.m)return e?e.subTreeSize-1:0;var r=0;for(t.left&&(r+=t.left.subTreeSize);t!==e;){var i=t.parent;t===i.right&&(r+=1,i.left&&(r+=i.left.subTreeSize)),t=i}return r},enumerable:!1,configurable:!0}),ft.prototype.equals=function(t){return this.h===t.h};var at,i=ft;function ft(t,e,r){r=at.call(this,r)||this;return r.h=t,r.m=e,0===r.iteratorType?(r.pre=function(){if(this.h===this.m.left)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this},r.next=function(){if(this.h===this.m)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this}):(r.pre=function(){if(this.h===this.m.right)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this},r.next=function(){if(this.h===this.m)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this}),r}e(O,pt=i),Object.defineProperty(O.prototype,"pointer",{get:function(){if(this.h===this.m)throw new RangeError("OrderedSet iterator access denied!");return this.h.key},enumerable:!1,configurable:!0}),O.prototype.copy=function(){return new O(this.h,this.m,this.iteratorType)};var pt,R=O;function O(){return null!==pt&&pt.apply(this,arguments)||this}e(C,ct=o),C.prototype.begin=function(){return new R(this.m.left||this.m,this.m)},C.prototype.end=function(){return new R(this.m,this.m)},C.prototype.rBegin=function(){return new R(this.m.right||this.m,this.m,1)},C.prototype.rEnd=function(){return new R(this.m,this.m,1)},C.prototype.front=function(){return this.m.left?this.m.left.key:void 0},C.prototype.back=function(){return this.m.right?this.m.right.key:void 0},C.prototype.forEach=function(t){var e,r,i=0;try{for(var n=p(this),o=n.next();!o.done;o=n.next())t(o.value,i++)}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},C.prototype.getElementByPos=function(t){var e,r,i,n=0;try{for(var o=p(this),s=o.next();!s.done;s=o.next()){var h=s.value;if(n===t){i=h;break}n+=1}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},C.prototype.insert=function(t,e){this.j(t,void 0,e)},C.prototype.find=function(t){t=this.X(this.V,t);return void 0!==t?new R(t,this.m):this.end()},C.prototype.lowerBound=function(t){t=this.J(this.V,t);return new R(t,this.m)},C.prototype.upperBound=function(t){t=this.F(this.V,t);return new R(t,this.m)},C.prototype.reverseLowerBound=function(t){t=this.K(this.V,t);return new R(t,this.m)},C.prototype.reverseUpperBound=function(t){t=this.U(this.V,t);return new R(t,this.m)},C.prototype.union=function(t){var e=this;t.forEach(function(t){return e.insert(t)})},C.prototype[Symbol.iterator]=function(){return this.Y(this.V)};var ct,V=C;function C(t,e,r){void 0===t&&(t=[]);var i=ct.call(this,e,r)||this;return i.Y=function(e){return f(this,function(t){switch(t.label){case 0:return void 0===e?[2]:[5,p(this.Y(e.left))];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,p(this.Y(e.right))];case 3:return t.sent(),[2]}})},t.forEach(function(t){return i.insert(t)}),i}e(L,lt=i),Object.defineProperty(L.prototype,"pointer",{get:function(){var i=this;if(this.h===this.m)throw new RangeError("OrderedMap iterator access denied");return new Proxy([],{get:function(t,e){return"0"===e?i.h.key:"1"===e?i.h.value:void 0},set:function(t,e,r){if("1"!==e)throw new TypeError("props must be 1");return i.h.value=r,!0}})},enumerable:!1,configurable:!0}),L.prototype.copy=function(){return new L(this.h,this.m,this.iteratorType)};var lt,S=L;function L(){return null!==lt&&lt.apply(this,arguments)||this}e(T,yt=o),T.prototype.begin=function(){return new S(this.m.left||this.m,this.m)},T.prototype.end=function(){return new S(this.m,this.m)},T.prototype.rBegin=function(){return new S(this.m.right||this.m,this.m,1)},T.prototype.rEnd=function(){return new S(this.m,this.m,1)},T.prototype.front=function(){var t;if(this.t)return[(t=this.m.left).key,t.value]},T.prototype.back=function(){var t;if(this.t)return[(t=this.m.right).key,t.value]},T.prototype.forEach=function(t){var e,r,i=0;try{for(var n=p(this),o=n.next();!o.done;o=n.next())t(o.value,i++)}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},T.prototype.lowerBound=function(t){t=this.J(this.V,t);return new S(t,this.m)},T.prototype.upperBound=function(t){t=this.F(this.V,t);return new S(t,this.m)},T.prototype.reverseLowerBound=function(t){t=this.K(this.V,t);return new S(t,this.m)},T.prototype.reverseUpperBound=function(t){t=this.U(this.V,t);return new S(t,this.m)},T.prototype.setElement=function(t,e,r){this.j(t,e,r)},T.prototype.find=function(t){t=this.X(this.V,t);return void 0!==t?new S(t,this.m):this.end()},T.prototype.getElementByKey=function(t){t=this.X(this.V,t);return t?t.value:void 0},T.prototype.getElementByPos=function(t){var e,r,i,n=0;try{for(var o=p(this),s=o.next();!s.done;s=o.next()){var h=s.value;if(n===t){i=h;break}n+=1}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},T.prototype.union=function(t){var r=this;t.forEach(function(t){var t=c(t,2),e=t[0],t=t[1];return r.setElement(e,t)})},T.prototype[Symbol.iterator]=function(){return this.Y(this.V)};var yt,z=T;function T(t,e,r){void 0===t&&(t=[]);var i=yt.call(this,e,r)||this;return i.Y=function(e){return f(this,function(t){switch(t.label){case 0:return void 0===e?[2]:[5,p(this.Y(e.left))];case 1:return t.sent(),[4,[e.key,e.value]];case 2:return t.sent(),[5,p(this.Y(e.right))];case 3:return t.sent(),[2]}})},t.forEach(function(t){var t=c(t,2),e=t[0],t=t[1];return i.setElement(e,t)}),i}e(dt,vt=r),dt.prototype.clear=function(){this.t=0,this.O=this.Z,this.tt=[]};var vt,i=dt;function dt(t,e){void 0===t&&(t=16),void 0===e&&(e=function(t){for(var e="string"!=typeof t?JSON.stringify(t):t,r=0,i=e.length,n=0;n<i;n++){r=(r<<5)-r+e.charCodeAt(n);r|=0}return r>>>0});var r=vt.call(this)||this;if(t<16||0!=(t&t-1))throw new RangeError("InitBucketNum range error");return r.O=r.Z=t,r.$=e,r}e(q,mt=i),q.prototype.I=function(){var o=this;if(!(1073741824<=this.O)){for(var s=[],h=this.O,u=(this.O<<=1,Object.keys(this.tt)),t=u.length,a=this,e=0;e<t;++e)!function(t){var e,r,t=parseInt(u[t]),i=a.tt[t],n=i.size();0===n||(1===n?(n=i.front(),s[a.$(n)&a.O-1]=new d([n],!1)):(e=[],r=[],i.forEach(function(t){(0==(o.$(t)&h)?e:r).push(t)}),i instanceof V?(6<e.length?s[t]=new V(e):s[t]=new d(e,!1),6<r.length?s[t+h]=new V(r):s[t+h]=new d(r,!1)):(s[t]=new d(e,!1),s[t+h]=new d(r,!1))))}(e);this.tt=s}},q.prototype.forEach=function(e){for(var t=Object.values(this.tt),r=t.length,i=0,n=0;n<r;++n)t[n].forEach(function(t){return e(t,i++)})},q.prototype.insert=function(t){var e=this.$(t)&this.O-1,r=this.tt[e];if(r){var i=r.size();if(r instanceof d){if(!r.find(t).equals(r.end()))return;if(r.pushBack(t),8<=i+1){if(this.O<=64)return this.t+=1,void this.I();this.tt[e]=new V(r)}this.t+=1}else{r.insert(t);r=r.size();this.t+=r-i}}else this.tt[e]=new d([t],!1),this.t+=1;this.t>.75*this.O&&this.I()},q.prototype.eraseElementByKey=function(t){var e,r,i=this.$(t)&this.O-1,n=this.tt[i];!n||0!==(e=n.size())&&(n instanceof d?(n.eraseElementByValue(t),r=n.size(),this.t+=r-e):(n.eraseElementByKey(t),r=n.size(),this.t+=r-e,r<=6&&(this.tt[i]=new d(n))))},q.prototype.find=function(t){var e=this.$(t)&this.O-1,e=this.tt[e];return!!e&&!e.find(t).equals(e.end())},q.prototype[Symbol.iterator]=function(){return function(){var e,r,i,n,o,s,h,u,a;return f(this,function(t){switch(t.label){case 0:e=Object.values(this.tt),r=e.length,i=0,t.label=1;case 1:if(!(i<r))return[3,10];n=e[i],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,o=p(n),s=o.next(),t.label=3;case 3:return s.done?[3,6]:[4,s.value];case 4:t.sent(),t.label=5;case 5:return s=o.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(u)throw u.error}return[7];case 9:return++i,[3,1];case 10:return[2]}})}.bind(this)()};var mt,o=q;function q(t,e,r){void 0===t&&(t=[]);var i=mt.call(this,e,r)||this;return i.tt=[],t.forEach(function(t){return i.insert(t)}),i}e(M,gt=i),M.prototype.I=function(){var o=this;if(!(1073741824<=this.O)){for(var s=[],h=this.O,u=(this.O<<=1,Object.keys(this.tt)),t=u.length,a=this,e=0;e<t;++e)!function(t){var e,r,t=parseInt(u[t]),i=a.tt[t],n=i.size();0===n||(1===n?(n=i.front(),s[a.$(n[0])&a.O-1]=new d([n],!1)):(e=[],r=[],i.forEach(function(t){(0==(o.$(t[0])&h)?e:r).push(t)}),i instanceof z?(6<e.length?s[t]=new z(e):s[t]=new d(e,!1),6<r.length?s[t+h]=new z(r):s[t+h]=new d(r,!1)):(s[t]=new d(e,!1),s[t+h]=new d(r,!1))))}(e);this.tt=s}},M.prototype.forEach=function(e){for(var t=Object.values(this.tt),r=t.length,i=0,n=0;n<r;++n)t[n].forEach(function(t){return e(t,i++)})},M.prototype.setElement=function(t,e){var r,i=this.$(t)&this.O-1,n=this.tt[i];if(n){var o=n.size();if(n instanceof d){try{for(var s=p(n),h=s.next();!h.done;h=s.next()){var u=h.value;if(u[0]===t)return void(u[1]=e)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}if(n.pushBack([t,e]),8<=o+1){if(this.O<=64)return this.t+=1,void this.I();this.tt[i]=new z(this.tt[i])}this.t+=1}else{n.setElement(t,e);var a=n.size();this.t+=a-o}}else this.t+=1,this.tt[i]=new d([[t,e]],!1);this.t>.75*this.O&&this.I()},M.prototype.getElementByKey=function(t){var e,r,i=this.$(t)&this.O-1,i=this.tt[i];if(i){if(i instanceof z)return i.getElementByKey(t);try{for(var n=p(i),o=n.next();!o.done;o=n.next()){var s=o.value;if(s[0]===t)return s[1]}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}},M.prototype.eraseElementByKey=function(t){var e=this.$(t)&this.O-1,r=this.tt[e];if(r)if(r instanceof d){var i=0;try{for(var n=p(r),o=n.next();!o.done;o=n.next()){if(o.value[0]===t)return r.eraseElementByPos(i),void--this.t;i+=1}}catch(t){h={error:t}}finally{try{o&&!o.done&&(s=n.return)&&s.call(n)}finally{if(h)throw h.error}}}else{var s=r.size(),h=(r.eraseElementByKey(t),r.size());this.t+=h-s,h<=6&&(this.tt[e]=new d(r))}},M.prototype.find=function(t){var e,r,i=this.$(t)&this.O-1,i=this.tt[i];if(i){if(i instanceof z)return!i.find(t).equals(i.end());try{for(var n=p(i),o=n.next();!o.done;o=n.next())if(o.value[0]===t)return!0}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}return!1},M.prototype[Symbol.iterator]=function(){return function(){var e,r,i,n,o,s,h,u,a;return f(this,function(t){switch(t.label){case 0:e=Object.values(this.tt),r=e.length,i=0,t.label=1;case 1:if(!(i<r))return[3,10];n=e[i],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,o=p(n),s=o.next(),t.label=3;case 3:return s.done?[3,6]:[4,s.value];case 4:t.sent(),t.label=5;case 5:return s=o.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{s&&!s.done&&(a=o.return)&&a.call(o)}finally{if(u)throw u.error}return[7];case 9:return++i,[3,1];case 10:return[2]}})}.bind(this)()};var gt,r=M;function M(t,e,r){void 0===t&&(t=[]);var i=gt.call(this,e,r)||this;return i.tt=[],t.forEach(function(t){return i.setElement(t[0],t[1])}),i}t.Deque=J,t.HashMap=r,t.HashSet=o,t.LinkList=H,t.OrderedMap=z,t.OrderedSet=V,t.PriorityQueue=tt,t.Queue=W,t.Stack=F,t.Vector=d,Object.defineProperty(t,"it",{value:!0})});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define("sdsl",["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var L=function(t,i){return(L=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])})(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function e(){this.constructor=t}L(t,i),t.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)}function a(r,n){var s,o,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},t={next:i(0),throw:i(1),return:i(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function i(e){return function(t){var i=[e,t];if(s)throw new TypeError("Generator is already executing.");for(;u;)try{if(s=1,o&&(h=2&i[0]?o.return:i[0]?o.throw||((h=o.return)&&h.call(o),0):o.next)&&!(h=h.call(o,i[1])).done)return h;switch(o=0,(i=h?[2&i[0],h.value]:i)[0]){case 0:case 1:h=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,o=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!h||i[1]>h[0]&&i[1]<h[3]))u.label=i[1];else if(6===i[0]&&u.label<h[1])u.label=h[1],h=i;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(i)}}i=n.call(r,u)}catch(t){i=[6,t],o=0}finally{s=h=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}function c(t){var i="function"==typeof Symbol&&Symbol.iterator,e=i&&t[i],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(i?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,i){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,n,s=e.call(t),o=[];try{for(;(void 0===i||0<i--)&&!(r=s.next()).done;)o.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(n)throw n.error}}return o}function h(t,i,e){if(e||2===arguments.length)for(var r,n=0,s=i.length;n<s;n++)!r&&n in i||((r=r||Array.prototype.slice.call(i,0,n))[n]=i[n]);return t.concat(r||Array.prototype.slice.call(i))}function S(t){this.iteratorType=t=void 0===t?0:t}q.prototype.size=function(){return this.t},q.prototype.empty=function(){return 0===this.t};var e=q;function q(){this.t=0}i(z,V=e);var V,r=z;function z(){return null!==V&&V.apply(this,arguments)||this}i(n,I=e),n.prototype.clear=function(){this.t=0,this.i.length=0},n.prototype.push=function(t){this.i.push(t),this.t+=1},n.prototype.pop=function(){this.i.pop(),0<this.t&&--this.t},n.prototype.top=function(){return this.i[this.t-1]};var I,M=n;function n(t){void 0===t&&(t=[]);var i=I.call(this)||this;return i.i=[],t.forEach(function(t){return i.push(t)}),i}i(T,C=r);var C,s=T;function T(){return null!==C&&C.apply(this,arguments)||this}i(u,_=S),Object.defineProperty(u.prototype,"pointer",{get:function(){return this.o(this.h)},set:function(t){this.v(this.h,t)},enumerable:!1,configurable:!0}),u.prototype.equals=function(t){return this.h===t.h};var _,K=u;function u(t,i,e,r,n){n=_.call(this,n)||this;return n.h=t,n.u=i,n.o=e,n.v=r,0===n.iteratorType?(n.pre=function(){if(0===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this},n.next=function(){if(this.h===this.u())throw new RangeError("Random Iterator access denied!");return this.h+=1,this}):(n.pre=function(){if(this.h===this.u()-1)throw new RangeError("Random iterator access denied!");return this.h+=1,this},n.next=function(){if(-1===this.h)throw new RangeError("Random iterator access denied!");return--this.h,this}),n}i(D,X=K),D.prototype.copy=function(){return new D(this.h,this.u,this.o,this.v,this.iteratorType)};var X,f=D;function D(){return null!==X&&X.apply(this,arguments)||this}i(p,W=s),p.prototype.I=function(){for(var t=[],i=Math.max(this.O>>1,1),e=0;e<i;++e)t[e]=new Array(this.S);for(e=this.l;e<this.O;++e)t[t.length]=this.k[e];for(e=0;e<this.L;++e)t[t.length]=this.k[e];t[t.length]=h([],o(this.k[this.L]),!1),this.l=i,this.L=t.length-1;for(e=0;e<i;++e)t[t.length]=new Array(this.S);this.k=t,this.O=t.length},p.prototype.g=function(t){var t=this._+t+1,i=t%this.S,e=i-1,t=this.l+(t-i)/this.S;return 0==i&&--t,t%=this.O,e<0&&(e+=this.S),{curNodeBucketIndex:t,curNodePointerIndex:e}},p.prototype.clear=function(){this.k=[[]],this.O=1,this.l=this.L=this.t=0,this._=this.p=this.S>>1},p.prototype.front=function(){return this.k[this.l][this._]},p.prototype.back=function(){return this.k[this.L][this.p]},p.prototype.begin=function(){return new f(0,this.size,this.getElementByPos,this.setElementByPos)},p.prototype.end=function(){return new f(this.t,this.size,this.getElementByPos,this.setElementByPos)},p.prototype.rBegin=function(){return new f(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},p.prototype.rEnd=function(){return new f(-1,this.size,this.getElementByPos,this.setElementByPos,1)},p.prototype.pushBack=function(t){this.t&&(this.p<this.S-1?this.p+=1:(this.L<this.O-1?this.L+=1:this.L=0,this.p=0),this.L===this.l&&this.p===this._&&this.I()),this.t+=1,this.k[this.L][this.p]=t},p.prototype.popBack=function(){this.t&&(this.k[this.L][this.p]=void 0,1!==this.t&&(0<this.p?--this.p:(0<this.L?--this.L:this.L=this.O-1,this.p=this.S-1)),--this.t)},p.prototype.pushFront=function(t){this.t&&(0<this._?--this._:(0<this.l?--this.l:this.l=this.O-1,this._=this.S-1),this.l===this.L&&this._===this.p&&this.I()),this.t+=1,this.k[this.l][this._]=t},p.prototype.popFront=function(){this.t&&(this.k[this.l][this._]=void 0,1!==this.t&&(this._<this.S-1?this._+=1:(this.l<this.O-1?this.l+=1:this.l=0,this._=0)),--this.t)},p.prototype.forEach=function(t){for(var i=0;i<this.t;++i)t(this.getElementByPos(i),i)},p.prototype.getElementByPos=function(t){var t=this.g(t),i=t.curNodeBucketIndex,t=t.curNodePointerIndex;return this.k[i][t]},p.prototype.setElementByPos=function(t,i){var t=this.g(t),e=t.curNodeBucketIndex,t=t.curNodePointerIndex;this.k[e][t]=i},p.prototype.insert=function(t,i,e){if(void 0===e&&(e=1),0===t)for(;e--;)this.pushFront(i);else if(t===this.t)for(;e--;)this.pushBack(i);else{for(var r=[],n=t;n<this.t;++n)r.push(this.getElementByPos(n));this.cut(t-1);for(n=0;n<e;++n)this.pushBack(i);for(n=0;n<r.length;++n)this.pushBack(r[n])}},p.prototype.cut=function(t){var i,e;t<0?this.clear():(i=(e=this.g(t)).curNodeBucketIndex,e=e.curNodePointerIndex,this.L=i,this.p=e,this.t=t+1)},p.prototype.eraseElementByPos=function(t){var i=this;if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var e=[],r=t+1;r<this.t;++r)e.push(this.getElementByPos(r));this.cut(t),this.popBack(),e.forEach(function(t){return i.pushBack(t)})}},p.prototype.eraseElementByValue=function(t){if(this.t){for(var i=[],e=0;e<this.t;++e){var r=this.getElementByPos(e);r!==t&&i.push(r)}for(var n=i.length,e=0;e<n;++e)this.setElementByPos(e,i[e]);this.cut(n-1)}},p.prototype.eraseElementByIterator=function(t){var i=t.h;return this.eraseElementByPos(i),t=t.next()},p.prototype.find=function(t){for(var i=0;i<this.t;++i)if(this.getElementByPos(i)===t)return new f(i,this.size,this.getElementByPos,this.setElementByPos);return this.end()},p.prototype.reverse=function(){for(var t=0,i=this.t-1;t<i;){var e=this.getElementByPos(t);this.setElementByPos(t,this.getElementByPos(i)),this.setElementByPos(i,e),t+=1,--i}},p.prototype.unique=function(){if(!(this.t<=1)){for(var t=1,i=this.getElementByPos(0),e=1;e<this.t;++e){var r=this.getElementByPos(e);r!==i&&this.setElementByPos(t++,i=r)}for(;this.t>t;)this.popBack()}},p.prototype.sort=function(t){for(var i=[],e=0;e<this.t;++e)i.push(this.getElementByPos(e));i.sort(t);for(e=0;e<this.t;++e)this.setElementByPos(e,i[e])},p.prototype.shrinkToFit=function(){if(this.t){var i=[];this.forEach(function(t){return i.push(t)}),this.O=Math.max(Math.ceil(this.t/this.S),1),this.t=this.l=this.L=this._=this.p=0,this.k=[];for(var t=0;t<this.O;++t)this.k.push(new Array(this.S));for(t=0;t<i.length;++t)this.pushBack(i[t])}},p.prototype[Symbol.iterator]=function(){return function(){var i;return a(this,function(t){switch(t.label){case 0:i=0,t.label=1;case 1:return i<this.t?[4,this.getElementByPos(i)]:[3,4];case 2:t.sent(),t.label=3;case 3:return++i,[3,1];case 4:return[2]}})}.bind(this)()};var W,Y=p;function p(t,i){void 0===t&&(t=[]),void 0===i&&(i=4096);var e,r=W.call(this)||this;if(r.l=0,r._=0,r.L=0,r.p=0,r.O=0,r.k=[],"size"in t)e="number"==typeof t.size?t.size:t.size();else{if(!("length"in t))throw new RangeError("Can't get container's size!");e=t.length}r.S=i,r.O=Math.max(Math.ceil(e/r.S),1);for(var n=0;n<r.O;++n)r.k.push(new Array(r.S));i=Math.ceil(e/r.S);return r.l=r.L=(r.O>>1)-(i>>1),r._=r.p=r.S-e%r.S>>1,t.forEach(function(t){return r.pushBack(t)}),r.size=r.size.bind(r),r.getElementByPos=r.getElementByPos.bind(r),r.setElementByPos=r.setElementByPos.bind(r),r}i(l,Z=e),l.prototype.clear=function(){this.T.clear(),this.t=0},l.prototype.push=function(t){this.T.pushBack(t),this.t+=1},l.prototype.pop=function(){this.T.popFront(),this.t&&--this.t},l.prototype.front=function(){return this.T.front()};var Z,$=l;function l(t){void 0===t&&(t=[]);var i=Z.call(this)||this;return i.T=new Y(t),i.t=i.T.size(),i}i(y,Q=e),y.prototype.m=function(t){for(var i=this.q[t];0<t;){var e=t-1>>1,r=this.q[e];if(this.M(r,i)<=0)break;this.q[t]=r,t=e}this.q[t]=i},y.prototype.D=function(t,i){for(var e=this.q[t];t<i;){var r=t<<1|1,n=r+1,s=this.q[r];if(n<this.t&&0<this.M(s,this.q[n])&&(s=this.q[r=n]),0<=this.M(s,e))break;this.q[t]=s,t=r}this.q[t]=e},y.prototype.clear=function(){this.t=0,this.q.length=0},y.prototype.push=function(t){this.q.push(t),this.m(this.t),this.t+=1},y.prototype.pop=function(){var t;this.t&&(t=this.q.pop(),--this.t,this.t&&(this.q[0]=t,this.D(0,this.t>>1)))},y.prototype.top=function(){return this.q[0]},y.prototype.find=function(t){return 0<=this.q.indexOf(t)},y.prototype.remove=function(t){t=this.q.indexOf(t);return!(t<0)&&(0===t?this.pop():t===this.t-1?(this.q.pop(),--this.t):(this.q.splice(t,1,this.q.pop()),--this.t,this.m(t),this.D(t,this.t>>1)),!0)},y.prototype.updateItem=function(t){t=this.q.indexOf(t);return!(t<0)&&(this.m(t),this.D(t,this.t>>1),!0)},y.prototype.toArray=function(){return h([],o(this.q),!1)};var Q,tt=y;function y(t,i,e){void 0===t&&(t=[]),void 0===i&&(i=function(t,i){return i<t?-1:t<i?1:0}),void 0===e&&(e=!0);for(var r=Q.call(this)||this,n=(r.M=i,Array.isArray(t)?r.q=e?h([],o(t),!1):t:(r.q=[],t.forEach(function(t){return r.q.push(t)})),r.t=r.q.length,r.t>>1),s=r.t-1>>1;0<=s;--s)r.D(s,n);return r}i(et,it=K),et.prototype.copy=function(){return new et(this.h,this.u,this.o,this.v,this.iteratorType)};var it,v=et;function et(){return null!==it&&it.apply(this,arguments)||this}i(w,rt=s),w.prototype.clear=function(){this.t=0,this.C.length=0},w.prototype.begin=function(){return new v(0,this.size,this.getElementByPos,this.setElementByPos)},w.prototype.end=function(){return new v(this.t,this.size,this.getElementByPos,this.setElementByPos)},w.prototype.rBegin=function(){return new v(this.t-1,this.size,this.getElementByPos,this.setElementByPos,1)},w.prototype.rEnd=function(){return new v(-1,this.size,this.getElementByPos,this.setElementByPos,1)},w.prototype.front=function(){return this.C[0]},w.prototype.back=function(){return this.C[this.t-1]},w.prototype.forEach=function(t){for(var i=0;i<this.t;++i)t(this.C[i],i)},w.prototype.getElementByPos=function(t){return this.C[t]},w.prototype.eraseElementByPos=function(t){this.C.splice(t,1),--this.t},w.prototype.eraseElementByValue=function(t){for(var i=0,e=0;e<this.t;++e)this.C[e]!==t&&(this.C[i++]=this.C[e]);this.t=this.C.length=i},w.prototype.eraseElementByIterator=function(t){var i=t.h;return t=t.next(),this.eraseElementByPos(i),t},w.prototype.pushBack=function(t){this.C.push(t),this.t+=1},w.prototype.popBack=function(){this.t&&(this.C.pop(),--this.t)},w.prototype.setElementByPos=function(t,i){this.C[t]=i},w.prototype.insert=function(t,i,e){var r;void 0===e&&(e=1),(r=this.C).splice.apply(r,h([t,0],o(new Array(e).fill(i)),!1)),this.t+=e},w.prototype.find=function(t){for(var i=0;i<this.t;++i)if(this.C[i]===t)return new v(i,this.size,this.getElementByPos,this.getElementByPos);return this.end()},w.prototype.reverse=function(){this.C.reverse()},w.prototype.unique=function(){for(var t=1,i=1;i<this.t;++i)this.C[i]!==this.C[i-1]&&(this.C[t++]=this.C[i]);this.t=this.C.length=t},w.prototype.sort=function(t){this.C.sort(t)},w.prototype[Symbol.iterator]=function(){return function(){return a(this,function(t){switch(t.label){case 0:return[5,c(this.C)];case 1:return[2,t.sent()]}})}.bind(this)()};var rt,d=w;function w(t,i){void 0===t&&(t=[]),void 0===i&&(i=!0);var e=rt.call(this)||this;return Array.isArray(t)?(e.C=i?h([],o(t),!1):t,e.t=t.length):(e.C=[],t.forEach(function(t){return e.pushBack(t)})),e.size=e.size.bind(e),e.getElementByPos=e.getElementByPos.bind(e),e.setElementByPos=e.setElementByPos.bind(e),e}var nt,B=function(t){this.R=void 0,this.V=void 0,this.H=void 0,this.R=t},E=(i(g,nt=S),Object.defineProperty(g.prototype,"pointer",{get:function(){if(this.h===this.N)throw new RangeError("LinkList iterator access denied!");return this.h.R},set:function(t){if(this.h===this.N)throw new RangeError("LinkList iterator access denied!");this.h.R=t},enumerable:!1,configurable:!0}),g.prototype.equals=function(t){return this.h===t.h},g.prototype.copy=function(){return new g(this.h,this.N,this.iteratorType)},g);function g(t,i,e){e=nt.call(this,e)||this;return e.h=t,e.N=i,0===e.iteratorType?(e.pre=function(){if(this.h.V===this.N)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.V,this},e.next=function(){if(this.h===this.N)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.H,this}):(e.pre=function(){if(this.h.H===this.N)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.H,this},e.next=function(){if(this.h===this.N)throw new RangeError("LinkList iterator access denied!");return this.h=this.h.V,this}),e}i(N,st=s),N.prototype.clear=function(){this.t=0,this.j=this.P=void 0,this.N.V=this.N.H=void 0},N.prototype.begin=function(){return new E(this.j||this.N,this.N)},N.prototype.end=function(){return new E(this.N,this.N)},N.prototype.rBegin=function(){return new E(this.P||this.N,this.N,1)},N.prototype.rEnd=function(){return new E(this.N,this.N,1)},N.prototype.front=function(){return this.j?this.j.R:void 0},N.prototype.back=function(){return this.P?this.P.R:void 0},N.prototype.forEach=function(t){if(this.t)for(var i=this.j,e=0;i!==this.N;)t(i.R,e++),i=i.H},N.prototype.getElementByPos=function(t){for(var i=this.j;t--;)i=i.H;return i.R},N.prototype.eraseElementByPos=function(t){if(0===t)this.popFront();else if(t===this.t-1)this.popBack();else{for(var i=this.j;t--;)i=i.H;var e=i.V,r=i.H;(r.V=e).H=r,--this.t}},N.prototype.eraseElementByValue=function(t){for(;this.j&&this.j.R===t;)this.popFront();for(;this.P&&this.P.R===t;)this.popBack();if(this.j)for(var i,e,r=this.j;r!==this.N;)r.R===t&&(i=r.V,((e=r.H).V=i).H=e,--this.t),r=r.H},N.prototype.eraseElementByIterator=function(t){var i,e=t.h;if(e===this.N)throw new RangeError("Invalid iterator");return t=t.next(),this.j===e?this.popFront():this.P===e?this.popBack():(i=e.V,((e=e.H).V=i).H=e,--this.t),t},N.prototype.pushBack=function(t){this.t+=1;t=new B(t);this.P?((this.P.H=t).V=this.P,this.P=t):(this.j=this.P=t,this.N.H=this.j,this.j.V=this.N),this.P.H=this.N,this.N.V=this.P},N.prototype.popBack=function(){this.P&&(--this.t,this.j===this.P?(this.j=this.P=void 0,this.N.H=void 0):(this.P=this.P.V,this.P.H=this.N),this.N.V=this.P)},N.prototype.setElementByPos=function(t,i){for(var e=this.j;t--;)e=e.H;e.R=i},N.prototype.insert=function(t,i,e){if(!((e=void 0===e?1:e)<=0))if(0===t)for(;e--;)this.pushFront(i);else if(t===this.t)for(;e--;)this.pushBack(i);else{for(var r=this.j,n=1;n<t;++n)r=r.H;var s=r.H;for(this.t+=e;e--;)r.H=new B(i),r=(r.H.V=r).H;(r.H=s).V=r}},N.prototype.find=function(t){if(this.j)for(var i=this.j;i!==this.N;){if(i.R===t)return new E(i,this.N);i=i.H}return this.end()},N.prototype.reverse=function(){if(!(this.t<=1))for(var t=this.j,i=this.P,e=0;e<<1<this.t;){var r=t.R;t.R=i.R,i.R=r,t=t.H,i=i.V,e+=1}},N.prototype.unique=function(){if(!(this.t<=1))for(var t=this.j;t!==this.N;){for(var i=t;i.H&&i.R===i.H.R;)i=i.H,--this.t;t.H=i.H,t=(t.H.V=t).H}},N.prototype.sort=function(t){var i,e;this.t<=1||(i=[],this.forEach(function(t){return i.push(t)}),i.sort(t),e=this.j,i.forEach(function(t){e.R=t,e=e.H}))},N.prototype.pushFront=function(t){this.t+=1;t=new B(t);this.j?(t.H=this.j,this.j.V=t,this.j=t):(this.j=this.P=t,this.P.H=this.N,this.N.V=this.P),this.N.H=this.j,this.j.V=this.N},N.prototype.popFront=function(){this.j&&(--this.t,this.j===this.P?(this.j=this.P=void 0,this.N.V=this.P):(this.j=this.j.H,this.j.V=this.N),this.N.H=this.j)},N.prototype.merge=function(t){var e,r=this;this.j?(e=this.j,t.forEach(function(t){for(;e&&e!==r.N&&e.R<=t;)e=e.H;var i;e===r.N?(r.pushBack(t),e=r.P):e===r.j?(r.pushFront(t),e=r.j):(r.t+=1,(i=e.V).H=new B(t),((i.H.V=i).H.H=e).V=i.H)})):t.forEach(function(t){return r.pushBack(t)})},N.prototype[Symbol.iterator]=function(){return function(){var i;return a(this,function(t){switch(t.label){case 0:if(!this.j)return[2];i=this.j,t.label=1;case 1:return i===this.N?[3,3]:[4,i.R];case 2:return t.sent(),i=i.H,[3,1];case 3:return[2]}})}.bind(this)()};var st,K=N;function N(t){void 0===t&&(t=[]);var i=st.call(this)||this;return i.N=new B,i.j=void 0,i.P=void 0,t.forEach(function(t){return i.pushBack(t)}),i}m.prototype.pre=function(){var t=this;if(1===t.A&&t.F.F===t)t=t.J;else if(t.G)for(t=t.G;t.J;)t=t.J;else{for(var i=t.F;i.G===t;)i=(t=i).F;t=i}return t},m.prototype.next=function(){var t=this;if(t.J){for(t=t.J;t.G;)t=t.G;return t}for(var i=t.F;i.J===t;)i=(t=i).F;return t.J!==i?i:t},m.prototype.rotateLeft=function(){var t=this.F,i=this.J,e=i.G;return t.F===this?t.F=i:t.G===this?t.G=i:t.J=i,i.F=t,(i.G=this).F=i,(this.J=e)&&(e.F=this),i},m.prototype.rotateRight=function(){var t=this.F,i=this.G,e=i.J;return t.F===this?t.F=i:t.G===this?t.G=i:t.J=i,i.F=t,(i.J=this).F=i,(this.G=e)&&(e.F=this),i};var ot=m;function m(t,i){this.A=1,this.B=void 0,this.R=void 0,this.G=void 0,this.J=void 0,this.F=void 0,this.B=t,this.R=i}i(b,P=ot),b.prototype.rotateLeft=function(){var t=P.prototype.rotateLeft.call(this);return this.recount(),t.recount(),t},b.prototype.rotateRight=function(){var t=P.prototype.rotateRight.call(this);return this.recount(),t.recount(),t},b.prototype.recount=function(){this.K=1,this.G&&(this.K+=this.G.K),this.J&&(this.K+=this.J.K)};var P,ht=b;function b(){var t=null!==P&&P.apply(this,arguments)||this;return t.G=void 0,t.J=void 0,t.F=void 0,t.K=1,t}i(G,ut=r),G.prototype.et=function(t,i){for(var e;t;){var r=this.M(t.B,i);if(r<0)t=t.J;else{if(!(0<r))return t;t=(e=t).G}}return void 0===e?this.N:e},G.prototype.rt=function(t,i){for(var e;t;)t=this.M(t.B,i)<=0?t.J:(e=t).G;return void 0===e?this.N:e},G.prototype.nt=function(t,i){for(var e;t;){var r=this.M(t.B,i);if(r<0)t=(e=t).J;else{if(!(0<r))return t;t=t.G}}return void 0===e?this.N:e},G.prototype.st=function(t,i){for(var e;t;)t=this.M(t.B,i)<0?(e=t).J:t.G;return void 0===e?this.N:e},G.prototype.ht=function(t){for(;;){var i,e=t.F;if(e===this.N)return;if(1===t.A)return void(t.A=0);if(t===e.G)if(1===(i=e.J).A)i.A=0,e.A=1,e===this.U?this.U=e.rotateLeft():e.rotateLeft();else{if(i.J&&1===i.J.A)return i.A=e.A,e.A=0,i.J.A=0,void(e===this.U?this.U=e.rotateLeft():e.rotateLeft());i.G&&1===i.G.A?(i.A=1,i.G.A=0,i.rotateRight()):(i.A=1,t=e)}else if(1===(i=e.G).A)i.A=0,e.A=1,e===this.U?this.U=e.rotateRight():e.rotateRight();else{if(i.G&&1===i.G.A)return i.A=e.A,e.A=0,i.G.A=0,void(e===this.U?this.U=e.rotateRight():e.rotateRight());i.J&&1===i.J.A?(i.A=1,i.J.A=0,i.rotateLeft()):(i.A=1,t=e)}}},G.prototype.it=function(t){var i;if(1===this.t)return this.clear(),this.N;for(var e=t;e.G||e.J;){if(e.J)for(e=e.J;e.G;)e=e.G;else e=e.G;i=o([e.B,t.B],2),t.B=i[0],e.B=i[1],i=o([e.R,t.R],2),t.R=i[0],e.R=i[1],t=e}this.N.G===e?this.N.G=e.F:this.N.J===e&&(this.N.J=e.F),this.ht(e);var r=e.F;return e===r.G?r.G=void 0:r.J=void 0,--this.t,this.U.A=0,r},G.prototype.$=function(t){for(;;){var i=t.F;if(0===i.A)return;var e,r,n=i.F;if(i===n.G){if((e=n.J)&&1===e.A){if(e.A=i.A=0,n===this.U)return;n.A=1,t=n;continue}if(t===i.J)return t.A=0,t.G&&(t.G.F=i),t.J&&(t.J.F=n),i.J=t.G,n.G=t.J,t.G=i,(t.J=n)===this.U?(this.U=t,this.N.F=t):(r=n.F).G===n?r.G=t:r.J=t,t.F=n.F,i.F=t,n.F=t,n.A=1,{parentNode:i,grandParent:n,curNode:t};i.A=0,n===this.U?this.U=n.rotateRight():n.rotateRight()}else{if((e=n.G)&&1===e.A){if(e.A=i.A=0,n===this.U)return;n.A=1,t=n;continue}if(t===i.G)return t.A=0,t.G&&(t.G.F=n),t.J&&(t.J.F=i),n.J=t.G,i.G=t.J,t.G=n,t.J=i,n===this.U?(this.U=t,this.N.F=t):(r=n.F).G===n?r.G=t:r.J=t,t.F=n.F,i.F=t,n.F=t,n.A=1,{parentNode:i,grandParent:n,curNode:t};i.A=0,n===this.U?this.U=n.rotateLeft():n.rotateLeft()}return void(n.A=1)}},G.prototype.Z=function(t,i,e){if(void 0===this.U)this.t+=1,this.U=new this.X(t,i),this.U.A=0,this.U.F=this.N,this.N.F=this.U,this.N.G=this.U,this.N.J=this.U;else{var r,n=this.N.G,s=this.M(n.B,t);if(0!==s){if(0<s)n.G=new this.X(t,i),r=(n.G.F=n).G,this.N.G=r;else{var s=this.N.J,o=this.M(s.B,t);if(0===o)return void(s.R=i);if(o<0)s.J=new this.X(t,i),r=(s.J.F=s).J,this.N.J=r;else{if(void 0!==e){o=e.h;if(o!==this.N){s=this.M(o.B,t);if(0===s)return void(o.R=i);if(0<s){e=o.pre(),s=this.M(e.B,t);if(0===s)return void(e.R=i);s<0&&(r=new this.X(t,i),void 0===e.J?(e.J=r).F=e:(o.G=r).F=o)}}}if(void 0===r)for(r=this.U;;){var h=this.M(r.B,t);if(0<h){if(void 0===r.G){r.G=new this.X(t,i),r=(r.G.F=r).G;break}r=r.G}else{if(!(h<0))return void(r.R=i);if(void 0===r.J){r.J=new this.X(t,i),r=(r.J.F=r).J;break}r=r.J}}}}return this.t+=1,r}n.R=i}},G.prototype.clear=function(){this.t=0,this.U=void 0,this.N.F=void 0,this.N.G=this.N.J=void 0},G.prototype.updateKeyByIterator=function(t,i){t=t.h;if(t===this.N)throw new TypeError("Invalid iterator!");if(1!==this.t){if(t===this.N.G)return 0<this.M(t.next().B,i)&&(t.B=i,!0);if(t===this.N.J)return this.M(t.pre().B,i)<0&&(t.B=i,!0);var e=t.pre().B;if(0<=this.M(e,i))return!1;if(e=t.next().B,this.M(e,i)<=0)return!1}return t.B=i,!0},G.prototype.eraseElementByPos=function(i){var e=this,r=0;this.W(this.U,function(t){return i===r?(e.tt(t),!0):(r+=1,!1)})},G.prototype.ut=function(t,i){for(;t;){var e=this.M(t.B,i);if(e<0)t=t.J;else{if(!(0<e))return t;t=t.G}}return t},G.prototype.eraseElementByKey=function(t){!this.t||void 0!==(t=this.ut(this.U,t))&&this.tt(t)},G.prototype.eraseElementByIterator=function(t){var i=t.h;if(i===this.N)throw new RangeError("Invalid iterator");return void 0===i.J&&(t=t.next()),this.tt(i),t},G.prototype.getHeight=function(){var i;return this.t?(i=function(t){return t?Math.max(i(t.G),i(t.J))+1:0})(this.U):0};var ut,s=G;function G(t,i){void 0===t&&(t=function(t,i){return t<i?-1:i<t?1:0}),void 0===i&&(i=!1);var e=ut.call(this)||this;return e.U=void 0,e.W=function(t,i){return void 0!==t&&(!!e.W(t.G,i)||(!!i(t)||e.W(t.J,i)))},e.M=t,i?(e.X=ht,e.Y=function(t,i,e){t=this.Z(t,i,e);if(t){for(var r=t.F;r!==this.N;)r.K+=1,r=r.F;var i=this.$(t);i&&(e=i.parentNode,t=i.grandParent,i=i.curNode,e.recount(),t.recount(),i.recount())}},e.tt=function(t){for(var i=this.it(t);i!==this.N;)--i.K,i=i.F}):(e.X=ot,e.Y=function(t,i,e){t=this.Z(t,i,e);t&&this.$(t)},e.tt=e.it),e.N=new e.X,e}i(at,ft=S),Object.defineProperty(at.prototype,"index",{get:function(){var t=this.h,i=this.N.F;if(t===this.N)return i?i.K-1:0;var e=0;for(t.G&&(e+=t.G.K);t!==i;){var r=t.F;t===r.J&&(e+=1,r.G&&(e+=r.G.K)),t=r}return e},enumerable:!1,configurable:!0}),at.prototype.equals=function(t){return this.h===t.h};var ft,r=at;function at(t,i,e){e=ft.call(this,e)||this;return e.h=t,e.N=i,0===e.iteratorType?(e.pre=function(){if(this.h===this.N.G)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this},e.next=function(){if(this.h===this.N)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this}):(e.pre=function(){if(this.h===this.N.J)throw new RangeError("Tree iterator access denied!");return this.h=this.h.next(),this},e.next=function(){if(this.h===this.N)throw new RangeError("Tree iterator access denied!");return this.h=this.h.pre(),this}),e}i(R,ct=r),Object.defineProperty(R.prototype,"pointer",{get:function(){if(this.h===this.N)throw new RangeError("OrderedSet iterator access denied!");return this.h.B},enumerable:!1,configurable:!0}),R.prototype.copy=function(){return new R(this.h,this.N,this.iteratorType)};var ct,J=R;function R(){return null!==ct&&ct.apply(this,arguments)||this}i(F,pt=s),F.prototype.begin=function(){return new J(this.N.G||this.N,this.N)},F.prototype.end=function(){return new J(this.N,this.N)},F.prototype.rBegin=function(){return new J(this.N.J||this.N,this.N,1)},F.prototype.rEnd=function(){return new J(this.N,this.N,1)},F.prototype.front=function(){return this.N.G?this.N.G.B:void 0},F.prototype.back=function(){return this.N.J?this.N.J.B:void 0},F.prototype.forEach=function(t){var i,e,r=0;try{for(var n=c(this),s=n.next();!s.done;s=n.next())t(s.value,r++)}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}},F.prototype.getElementByPos=function(t){var i,e,r,n=0;try{for(var s=c(this),o=s.next();!o.done;o=s.next()){var h=o.value;if(n===t){r=h;break}n+=1}}catch(t){i={error:t}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(i)throw i.error}}return r},F.prototype.insert=function(t,i){this.Y(t,void 0,i)},F.prototype.find=function(t){t=this.ut(this.U,t);return void 0!==t?new J(t,this.N):this.end()},F.prototype.lowerBound=function(t){t=this.et(this.U,t);return new J(t,this.N)},F.prototype.upperBound=function(t){t=this.rt(this.U,t);return new J(t,this.N)},F.prototype.reverseLowerBound=function(t){t=this.nt(this.U,t);return new J(t,this.N)},F.prototype.reverseUpperBound=function(t){t=this.st(this.U,t);return new J(t,this.N)},F.prototype.union=function(t){var i=this;t.forEach(function(t){return i.insert(t)})},F.prototype[Symbol.iterator]=function(){return this.ft(this.U)};var pt,k=F;function F(t,i,e){void 0===t&&(t=[]);var r=pt.call(this,i,e)||this;return r.ft=function(i){return a(this,function(t){switch(t.label){case 0:return void 0===i?[2]:[5,c(this.ft(i.G))];case 1:return t.sent(),[4,i.B];case 2:return t.sent(),[5,c(this.ft(i.J))];case 3:return t.sent(),[2]}})},t.forEach(function(t){return r.insert(t)}),r}i(O,lt=r),Object.defineProperty(O.prototype,"pointer",{get:function(){var r=this;if(this.h===this.N)throw new RangeError("OrderedMap iterator access denied");return new Proxy([],{get:function(t,i){return"0"===i?r.h.B:"1"===i?r.h.R:void 0},set:function(t,i,e){if("1"!==i)throw new TypeError("props must be 1");return r.h.R=e,!0}})},enumerable:!1,configurable:!0}),O.prototype.copy=function(){return new O(this.h,this.N,this.iteratorType)};var lt,j=O;function O(){return null!==lt&&lt.apply(this,arguments)||this}i(A,yt=s),A.prototype.begin=function(){return new j(this.N.G||this.N,this.N)},A.prototype.end=function(){return new j(this.N,this.N)},A.prototype.rBegin=function(){return new j(this.N.J||this.N,this.N,1)},A.prototype.rEnd=function(){return new j(this.N,this.N,1)},A.prototype.front=function(){var t;if(this.t)return[(t=this.N.G).B,t.R]},A.prototype.back=function(){var t;if(this.t)return[(t=this.N.J).B,t.R]},A.prototype.forEach=function(t){var i,e,r=0;try{for(var n=c(this),s=n.next();!s.done;s=n.next())t(s.value,r++)}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}},A.prototype.lowerBound=function(t){t=this.et(this.U,t);return new j(t,this.N)},A.prototype.upperBound=function(t){t=this.rt(this.U,t);return new j(t,this.N)},A.prototype.reverseLowerBound=function(t){t=this.nt(this.U,t);return new j(t,this.N)},A.prototype.reverseUpperBound=function(t){t=this.st(this.U,t);return new j(t,this.N)},A.prototype.setElement=function(t,i,e){this.Y(t,i,e)},A.prototype.find=function(t){t=this.ut(this.U,t);return void 0!==t?new j(t,this.N):this.end()},A.prototype.getElementByKey=function(t){t=this.ut(this.U,t);return t?t.R:void 0},A.prototype.getElementByPos=function(t){var i,e,r,n=0;try{for(var s=c(this),o=s.next();!o.done;o=s.next()){var h=o.value;if(n===t){r=h;break}n+=1}}catch(t){i={error:t}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(i)throw i.error}}return r},A.prototype.union=function(t){var e=this;t.forEach(function(t){var t=o(t,2),i=t[0],t=t[1];return e.setElement(i,t)})},A.prototype[Symbol.iterator]=function(){return this.ft(this.U)};var yt,x=A;function A(t,i,e){void 0===t&&(t=[]);var r=yt.call(this,i,e)||this;return r.ft=function(i){return a(this,function(t){switch(t.label){case 0:return void 0===i?[2]:[5,c(this.ft(i.G))];case 1:return t.sent(),[4,[i.B,i.R]];case 2:return t.sent(),[5,c(this.ft(i.J))];case 3:return t.sent(),[2]}})},t.forEach(function(t){var t=o(t,2),i=t[0],t=t[1];return r.setElement(i,t)}),r}i(dt,vt=e),dt.prototype.clear=function(){this.t=0,this.O=this.ot,this.vt=[]};var vt,r=dt;function dt(t,i){void 0===t&&(t=16),void 0===i&&(i=function(t){for(var i="string"!=typeof t?JSON.stringify(t):t,e=0,r=i.length,n=0;n<r;n++){e=(e<<5)-e+i.charCodeAt(n);e|=0}return e>>>0});var e=vt.call(this)||this;if(t<16||0!=(t&t-1))throw new RangeError("InitBucketNum range error");return e.O=e.ot=t,e.ct=i,e}i(H,wt=r),H.prototype.I=function(){var s=this;if(!(1073741824<=this.O)){for(var o=[],h=this.O,u=(this.O<<=1,Object.keys(this.vt)),t=u.length,f=this,i=0;i<t;++i)!function(t){var i,e,t=parseInt(u[t]),r=f.vt[t],n=r.size();0===n||(1===n?(n=r.front(),o[f.ct(n)&f.O-1]=new d([n],!1)):(i=[],e=[],r.forEach(function(t){(0==(s.ct(t)&h)?i:e).push(t)}),r instanceof k?(o[t]=6<i.length?new k(i):new d(i,!1),o[t+h]=6<e.length?new k(e):new d(e,!1)):(o[t]=new d(i,!1),o[t+h]=new d(e,!1))))}(i);this.vt=o}},H.prototype.forEach=function(i){for(var t=Object.values(this.vt),e=t.length,r=0,n=0;n<e;++n)t[n].forEach(function(t){return i(t,r++)})},H.prototype.insert=function(t){var i=this.ct(t)&this.O-1,e=this.vt[i];if(e){var r=e.size();if(e instanceof d){if(!e.find(t).equals(e.end()))return;if(e.pushBack(t),8<=r+1){if(this.O<=64)return this.t+=1,void this.I();this.vt[i]=new k(e)}this.t+=1}else{e.insert(t);e=e.size();this.t+=e-r}}else this.vt[i]=new d([t],!1),this.t+=1;this.t>.75*this.O&&this.I()},H.prototype.eraseElementByKey=function(t){var i,e,r=this.ct(t)&this.O-1,n=this.vt[r];!n||0!==(i=n.size())&&(n instanceof d?(n.eraseElementByValue(t),e=n.size(),this.t+=e-i):(n.eraseElementByKey(t),e=n.size(),this.t+=e-i,e<=6&&(this.vt[r]=new d(n))))},H.prototype.find=function(t){var i=this.ct(t)&this.O-1,i=this.vt[i];return!!i&&!i.find(t).equals(i.end())},H.prototype[Symbol.iterator]=function(){return function(){var i,e,r,n,s,o,h,u,f;return a(this,function(t){switch(t.label){case 0:i=Object.values(this.vt),e=i.length,r=0,t.label=1;case 1:if(!(r<e))return[3,10];n=i[r],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,s=c(n),o=s.next(),t.label=3;case 3:return o.done?[3,6]:[4,o.value];case 4:t.sent(),t.label=5;case 5:return o=s.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{o&&!o.done&&(f=s.return)&&f.call(s)}finally{if(u)throw u.error}return[7];case 9:return++r,[3,1];case 10:return[2]}})}.bind(this)()};var wt,s=H;function H(t,i,e){void 0===t&&(t=[]);var r=wt.call(this,i,e)||this;return r.vt=[],t.forEach(function(t){return r.insert(t)}),r}i(U,Bt=r),U.prototype.I=function(){var s=this;if(!(1073741824<=this.O)){for(var o=[],h=this.O,u=(this.O<<=1,Object.keys(this.vt)),t=u.length,f=this,i=0;i<t;++i)!function(t){var i,e,t=parseInt(u[t]),r=f.vt[t],n=r.size();0===n||(1===n?(n=r.front(),o[f.ct(n[0])&f.O-1]=new d([n],!1)):(i=[],e=[],r.forEach(function(t){(0==(s.ct(t[0])&h)?i:e).push(t)}),r instanceof x?(o[t]=6<i.length?new x(i):new d(i,!1),o[t+h]=6<e.length?new x(e):new d(e,!1)):(o[t]=new d(i,!1),o[t+h]=new d(e,!1))))}(i);this.vt=o}},U.prototype.forEach=function(i){for(var t=Object.values(this.vt),e=t.length,r=0,n=0;n<e;++n)t[n].forEach(function(t){return i(t,r++)})},U.prototype.setElement=function(t,i){var e,r=this.ct(t)&this.O-1,n=this.vt[r];if(n){var s=n.size();if(n instanceof d){try{for(var o=c(n),h=o.next();!h.done;h=o.next()){var u=h.value;if(u[0]===t)return void(u[1]=i)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(f=o.return)&&f.call(o)}finally{if(e)throw e.error}}if(n.pushBack([t,i]),8<=s+1){if(this.O<=64)return this.t+=1,void this.I();this.vt[r]=new x(this.vt[r])}this.t+=1}else{n.setElement(t,i);var f=n.size();this.t+=f-s}}else this.t+=1,this.vt[r]=new d([[t,i]],!1);this.t>.75*this.O&&this.I()},U.prototype.getElementByKey=function(t){var i,e,r=this.ct(t)&this.O-1,r=this.vt[r];if(r){if(r instanceof x)return r.getElementByKey(t);try{for(var n=c(r),s=n.next();!s.done;s=n.next()){var o=s.value;if(o[0]===t)return o[1]}}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}}},U.prototype.eraseElementByKey=function(t){var i=this.ct(t)&this.O-1,e=this.vt[i];if(e)if(e instanceof d){var r=0;try{for(var n=c(e),s=n.next();!s.done;s=n.next()){if(s.value[0]===t)return e.eraseElementByPos(r),void--this.t;r+=1}}catch(t){h={error:t}}finally{try{s&&!s.done&&(o=n.return)&&o.call(n)}finally{if(h)throw h.error}}}else{var o=e.size(),h=(e.eraseElementByKey(t),e.size());this.t+=h-o,h<=6&&(this.vt[i]=new d(e))}},U.prototype.find=function(t){var i,e,r=this.ct(t)&this.O-1,r=this.vt[r];if(r){if(r instanceof x)return!r.find(t).equals(r.end());try{for(var n=c(r),s=n.next();!s.done;s=n.next())if(s.value[0]===t)return!0}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=n.return)&&e.call(n)}finally{if(i)throw i.error}}}return!1},U.prototype[Symbol.iterator]=function(){return function(){var i,e,r,n,s,o,h,u,f;return a(this,function(t){switch(t.label){case 0:i=Object.values(this.vt),e=i.length,r=0,t.label=1;case 1:if(!(r<e))return[3,10];n=i[r],t.label=2;case 2:t.trys.push([2,7,8,9]),u=void 0,s=c(n),o=s.next(),t.label=3;case 3:return o.done?[3,6]:[4,o.value];case 4:t.sent(),t.label=5;case 5:return o=s.next(),[3,3];case 6:return[3,9];case 7:return h=t.sent(),u={error:h},[3,9];case 8:try{o&&!o.done&&(f=s.return)&&f.call(s)}finally{if(u)throw u.error}return[7];case 9:return++r,[3,1];case 10:return[2]}})}.bind(this)()};var Bt,e=U;function U(t,i,e){void 0===t&&(t=[]);var r=Bt.call(this,i,e)||this;return r.vt=[],t.forEach(function(t){return r.setElement(t[0],t[1])}),r}t.Deque=Y,t.HashMap=e,t.HashSet=s,t.LinkList=K,t.OrderedMap=x,t.OrderedSet=k,t.PriorityQueue=tt,t.Queue=$,t.Stack=M,t.Vector=d,Object.defineProperty(t,"dt",{value:!0})});
//# sourceMappingURL=js-sdsl.min.js.map
{
"name": "js-sdsl",
"version": "4.1.5-beta.1",
"version": "4.1.5",
"description": "javascript standard data structure library which benchmark against C++ STL",

@@ -28,4 +28,6 @@ "main": "./dist/cjs/index.js",

"build:umd:min": "yarn build:umd && gulp umd:min",
"test": "yarn test:unit && yarn test:performance",
"test:unit": "jest --coverage",
"build:isolate": "gulp isolate",
"test": "yarn test:unit && yarn test:browser && yarn test:performance",
"test:unit": "nyc ts-mocha --paths 'test/**/*.test.ts' --timeout 10000",
"test:browser": "karma start",
"test:performance": "gulp performance && node dist/performance/performance/index.js",

@@ -43,5 +45,8 @@ "lint": "eslint --fix --color --cache --max-warnings=0 .",

"devDependencies": {
"@babel/eslint-parser": "^7.18.9",
"@babel/core": "^7.19.3",
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
"@rollup/plugin-babel": "^5.3.1",
"@types/babel__core": "^7.1.19",
"@types/chai": "^4.3.3",
"@types/delete-empty": "^3.0.2",
"@types/gulp": "^4.0.9",

@@ -55,4 +60,5 @@ "@types/gulp-babel": "^6.1.30",

"@types/gulp-uglify": "^3.0.7",
"@types/jest": "^28.1.6",
"@types/karma": "^6.3.3",
"@types/merge-stream": "^1.1.2",
"@types/mocha": "^9.1.1",
"@types/node": "^17.0.0",

@@ -65,7 +71,10 @@ "@typescript-eslint/eslint-plugin": "^5.33.1",

"caniuse-lite": "^1.0.30001380",
"chai": "^4.3.6",
"commitlint": "^17.0.3",
"compare-versions": "^5.0.1",
"conventional-changelog-conventionalcommits": "^5.0.0",
"coveralls": "^3.1.1",
"delete-empty": "^3.0.0",
"eslint": "^8.23.1",
"eslint-plugin-compat": "^4.0.2",
"get-npm-package-version": "^1.1.1",
"gh-pages": "^3.2.3",

@@ -84,8 +93,17 @@ "gulp": "^4.0.2",

"husky": "^8.0.1",
"jest": "^28.1.3",
"karma": "^6.4.1",
"karma-chrome-launcher": "^3.1.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-requirejs": "^1.1.0",
"karma-typescript": "^5.5.3",
"lint-staged": "^13.0.3",
"merge-stream": "^2.0.0",
"mocha": "^10.0.0",
"nyc": "^15.1.0",
"requirejs": "^2.3.6",
"rollup": "^2.79.1",
"rollup-plugin-typescript2": "^0.33.0",
"ts-jest": "^28.0.7",
"ts-macros": "^1.3.3",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1",

@@ -92,0 +110,0 @@ "ts-transform-paths": "^2.0.3",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc