Insane number of adds to setup env and packages
This commit is contained in:
15
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.d.ts
generated
vendored
Normal file
15
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
declare abstract class TreeIterator<K, V> extends ContainerIterator<K | [K, V]> {
|
||||
pre: () => this;
|
||||
next: () => this;
|
||||
/**
|
||||
* @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;
|
||||
equals(obj: TreeIterator<K, V>): boolean;
|
||||
}
|
||||
export default TreeIterator;
|
||||
98
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.js
generated
vendored
Normal file
98
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(t, r) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(t, r) {
|
||||
t.__proto__ = r;
|
||||
} || function(t, r) {
|
||||
for (var e in r) if (Object.prototype.hasOwnProperty.call(r, e)) t[e] = r[e];
|
||||
};
|
||||
return extendStatics(t, r);
|
||||
};
|
||||
return function(t, r) {
|
||||
if (typeof r !== "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
||||
extendStatics(t, r);
|
||||
function __() {
|
||||
this.constructor = t;
|
||||
}
|
||||
t.prototype = r === null ? Object.create(r) : (__.prototype = r.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
|
||||
var TreeIterator = function(t) {
|
||||
__extends(TreeIterator, t);
|
||||
function TreeIterator(r, e, n) {
|
||||
var i = t.call(this, n) || this;
|
||||
i.D = r;
|
||||
i.J = e;
|
||||
if (i.iteratorType === 0) {
|
||||
i.pre = function() {
|
||||
if (this.D === this.J.Y) {
|
||||
throw new RangeError("Tree iterator access denied!");
|
||||
}
|
||||
this.D = this.D.pre();
|
||||
return this;
|
||||
};
|
||||
i.next = function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("Tree iterator access denied!");
|
||||
}
|
||||
this.D = this.D.next();
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
i.pre = function() {
|
||||
if (this.D === this.J.Z) {
|
||||
throw new RangeError("Tree iterator access denied!");
|
||||
}
|
||||
this.D = this.D.next();
|
||||
return this;
|
||||
};
|
||||
i.next = function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("Tree iterator access denied!");
|
||||
}
|
||||
this.D = this.D.pre();
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return i;
|
||||
}
|
||||
Object.defineProperty(TreeIterator.prototype, "index", {
|
||||
get: function() {
|
||||
var t = this.D;
|
||||
var r = this.J.tt;
|
||||
if (t === this.J) {
|
||||
if (r) {
|
||||
return r.rt - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
var e = 0;
|
||||
if (t.Y) {
|
||||
e += t.Y.rt;
|
||||
}
|
||||
while (t !== r) {
|
||||
var n = t.tt;
|
||||
if (t === n.Z) {
|
||||
e += 1;
|
||||
if (n.Y) {
|
||||
e += n.Y.rt;
|
||||
}
|
||||
}
|
||||
t = n;
|
||||
}
|
||||
return e;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
TreeIterator.prototype.equals = function(t) {
|
||||
return this.D === t.D;
|
||||
};
|
||||
return TreeIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
export default TreeIterator;
|
||||
36
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.d.ts
generated
vendored
Normal file
36
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
export declare class TreeNode<K, V> {
|
||||
constructor(_key?: K, _value?: V);
|
||||
/**
|
||||
* @description Get the pre node.
|
||||
* @return TreeNode about the pre node.
|
||||
*/
|
||||
pre(): TreeNode<K, V>;
|
||||
/**
|
||||
* @description Get the next node.
|
||||
* @return TreeNode about the next node.
|
||||
*/
|
||||
next(): TreeNode<K, V>;
|
||||
/**
|
||||
* @description Rotate _left.
|
||||
* @return TreeNode about moved to original position after rotation.
|
||||
*/
|
||||
rotateLeft(): TreeNode<K, V>;
|
||||
/**
|
||||
* @description Rotate _right.
|
||||
* @return TreeNode about moved to original position after rotation.
|
||||
*/
|
||||
rotateRight(): TreeNode<K, V>;
|
||||
}
|
||||
export declare class TreeNodeEnableIndex<K, V> extends TreeNode<K, V> {
|
||||
/**
|
||||
* @description Rotate _left and do recount.
|
||||
* @return TreeNode about moved to original position after rotation.
|
||||
*/
|
||||
rotateLeft(): TreeNodeEnableIndex<K, V>;
|
||||
/**
|
||||
* @description Rotate _right and do recount.
|
||||
* @return TreeNode about moved to original position after rotation.
|
||||
*/
|
||||
rotateRight(): TreeNode<K, V>;
|
||||
recount(): void;
|
||||
}
|
||||
130
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js
generated
vendored
Normal file
130
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(e, n) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(e, n) {
|
||||
e.__proto__ = n;
|
||||
} || function(e, n) {
|
||||
for (var i in n) if (Object.prototype.hasOwnProperty.call(n, i)) e[i] = n[i];
|
||||
};
|
||||
return extendStatics(e, n);
|
||||
};
|
||||
return function(e, n) {
|
||||
if (typeof n !== "function" && n !== null) throw new TypeError("Class extends value " + String(n) + " is not a constructor or null");
|
||||
extendStatics(e, n);
|
||||
function __() {
|
||||
this.constructor = e;
|
||||
}
|
||||
e.prototype = n === null ? Object.create(n) : (__.prototype = n.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var TreeNode = function() {
|
||||
function TreeNode(e, 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.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.tt;
|
||||
while (n.Y === e) {
|
||||
e = n;
|
||||
n = e.tt;
|
||||
}
|
||||
e = n;
|
||||
}
|
||||
return e;
|
||||
};
|
||||
TreeNode.prototype.next = function() {
|
||||
var e = this;
|
||||
if (e.Z) {
|
||||
e = e.Z;
|
||||
while (e.Y) {
|
||||
e = e.Y;
|
||||
}
|
||||
return e;
|
||||
} else {
|
||||
var n = e.tt;
|
||||
while (n.Z === e) {
|
||||
e = n;
|
||||
n = e.tt;
|
||||
}
|
||||
if (e.Z !== n) {
|
||||
return n;
|
||||
} else return e;
|
||||
}
|
||||
};
|
||||
TreeNode.prototype.rotateLeft = function() {
|
||||
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.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;
|
||||
};
|
||||
return TreeNode;
|
||||
}();
|
||||
|
||||
export { TreeNode };
|
||||
|
||||
var TreeNodeEnableIndex = function(e) {
|
||||
__extends(TreeNodeEnableIndex, e);
|
||||
function TreeNodeEnableIndex() {
|
||||
var n = e !== null && e.apply(this, arguments) || this;
|
||||
n.Y = undefined;
|
||||
n.Z = undefined;
|
||||
n.tt = undefined;
|
||||
n.rt = 1;
|
||||
return n;
|
||||
}
|
||||
TreeNodeEnableIndex.prototype.rotateLeft = function() {
|
||||
var n = e.prototype.rotateLeft.call(this);
|
||||
this.recount();
|
||||
n.recount();
|
||||
return n;
|
||||
};
|
||||
TreeNodeEnableIndex.prototype.rotateRight = function() {
|
||||
var n = e.prototype.rotateRight.call(this);
|
||||
this.recount();
|
||||
n.recount();
|
||||
return n;
|
||||
};
|
||||
TreeNodeEnableIndex.prototype.recount = function() {
|
||||
this.rt = 1;
|
||||
if (this.Y) this.rt += this.Y.rt;
|
||||
if (this.Z) this.rt += this.Z.rt;
|
||||
};
|
||||
return TreeNodeEnableIndex;
|
||||
}(TreeNode);
|
||||
|
||||
export { TreeNodeEnableIndex };
|
||||
55
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.d.ts
generated
vendored
Normal file
55
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import type TreeIterator from './TreeIterator';
|
||||
import { Container } from "../../ContainerBase";
|
||||
declare abstract class TreeContainer<K, V> extends Container<K | [K, V]> {
|
||||
/**
|
||||
* @param cmp The compare function.
|
||||
* @param enableIndex Whether to enable iterator indexing function.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
abstract lowerBound(_key: K): TreeIterator<K, V>;
|
||||
/**
|
||||
* @param _key The given _key you want to compare.
|
||||
* @return An iterator to the first element greater than the given _key.
|
||||
*/
|
||||
abstract upperBound(_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.
|
||||
*/
|
||||
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.
|
||||
* @param other The other tree container you want to merge.
|
||||
*/
|
||||
abstract union(other: TreeContainer<K, V>): void;
|
||||
clear(): void;
|
||||
/**
|
||||
* @description Update node's _key by iterator.
|
||||
* @param iter The iterator you want to change.
|
||||
* @param _key The _key you want to update.
|
||||
* @return Boolean about if the modification is successful.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
eraseElementByKey(_key: K): void;
|
||||
eraseElementByIterator(iter: TreeIterator<K, V>): TreeIterator<K, V>;
|
||||
/**
|
||||
* @description Get the height of the tree.
|
||||
* @return Number about the height of the RB-tree.
|
||||
*/
|
||||
getHeight(): number;
|
||||
}
|
||||
export default TreeContainer;
|
||||
525
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.js
generated
vendored
Normal file
525
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.js
generated
vendored
Normal file
@@ -0,0 +1,525 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(e, i) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(e, i) {
|
||||
e.__proto__ = i;
|
||||
} || function(e, i) {
|
||||
for (var r in i) if (Object.prototype.hasOwnProperty.call(i, r)) e[r] = i[r];
|
||||
};
|
||||
return extendStatics(e, i);
|
||||
};
|
||||
return function(e, i) {
|
||||
if (typeof i !== "function" && i !== null) throw new TypeError("Class extends value " + String(i) + " is not a constructor or null");
|
||||
extendStatics(e, i);
|
||||
function __() {
|
||||
this.constructor = e;
|
||||
}
|
||||
e.prototype = i === null ? Object.create(i) : (__.prototype = i.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __read = this && this._ || function(e, i) {
|
||||
var r = typeof Symbol === "function" && e[Symbol.iterator];
|
||||
if (!r) return e;
|
||||
var t = r.call(e), n, s = [], f;
|
||||
try {
|
||||
while ((i === void 0 || i-- > 0) && !(n = t.next()).done) s.push(n.value);
|
||||
} catch (e) {
|
||||
f = {
|
||||
error: e
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (n && !n.done && (r = t["return"])) r.call(t);
|
||||
} finally {
|
||||
if (f) throw f.error;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
import { Container } from "../../ContainerBase";
|
||||
|
||||
import { TreeNode, TreeNodeEnableIndex } from "./TreeNode";
|
||||
|
||||
var TreeContainer = function(e) {
|
||||
__extends(TreeContainer, e);
|
||||
function TreeContainer(i, r) {
|
||||
if (i === void 0) {
|
||||
i = function(e, i) {
|
||||
if (e < i) return -1;
|
||||
if (e > i) return 1;
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
if (r === void 0) {
|
||||
r = false;
|
||||
}
|
||||
var t = e.call(this) || this;
|
||||
t.rr = undefined;
|
||||
t.ie = function(e, i) {
|
||||
if (e === undefined) return false;
|
||||
var r = t.ie(e.Y, i);
|
||||
if (r) return true;
|
||||
if (i(e)) return true;
|
||||
return t.ie(e.Z, i);
|
||||
};
|
||||
t.A = i;
|
||||
if (r) {
|
||||
t.re = TreeNodeEnableIndex;
|
||||
t.ir = function(e, i, r) {
|
||||
var t = this.te(e, i, r);
|
||||
if (t) {
|
||||
var n = t.tt;
|
||||
while (n !== this.J) {
|
||||
n.rt += 1;
|
||||
n = n.tt;
|
||||
}
|
||||
var s = this.ne(t);
|
||||
if (s) {
|
||||
var f = s, h = f.parentNode, u = f.grandParent, a = f.curNode;
|
||||
h.recount();
|
||||
u.recount();
|
||||
a.recount();
|
||||
}
|
||||
}
|
||||
};
|
||||
t.se = function(e) {
|
||||
var i = this.fe(e);
|
||||
while (i !== this.J) {
|
||||
i.rt -= 1;
|
||||
i = i.tt;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
t.re = TreeNode;
|
||||
t.ir = function(e, i, r) {
|
||||
var t = this.te(e, i, r);
|
||||
if (t) this.ne(t);
|
||||
};
|
||||
t.se = t.fe;
|
||||
}
|
||||
t.J = new t.re;
|
||||
return t;
|
||||
}
|
||||
TreeContainer.prototype.$ = function(e, i) {
|
||||
var r;
|
||||
while (e) {
|
||||
var t = this.A(e.W, i);
|
||||
if (t < 0) {
|
||||
e = e.Z;
|
||||
} else if (t > 0) {
|
||||
r = e;
|
||||
e = e.Y;
|
||||
} else return e;
|
||||
}
|
||||
return r === undefined ? this.J : r;
|
||||
};
|
||||
TreeContainer.prototype.er = function(e, i) {
|
||||
var r;
|
||||
while (e) {
|
||||
var t = this.A(e.W, i);
|
||||
if (t <= 0) {
|
||||
e = e.Z;
|
||||
} else {
|
||||
r = e;
|
||||
e = e.Y;
|
||||
}
|
||||
}
|
||||
return r === undefined ? this.J : r;
|
||||
};
|
||||
TreeContainer.prototype.tr = function(e, i) {
|
||||
var r;
|
||||
while (e) {
|
||||
var t = this.A(e.W, i);
|
||||
if (t < 0) {
|
||||
r = e;
|
||||
e = e.Z;
|
||||
} else if (t > 0) {
|
||||
e = e.Y;
|
||||
} else return e;
|
||||
}
|
||||
return r === undefined ? this.J : r;
|
||||
};
|
||||
TreeContainer.prototype.nr = function(e, i) {
|
||||
var r;
|
||||
while (e) {
|
||||
var t = this.A(e.W, i);
|
||||
if (t < 0) {
|
||||
r = e;
|
||||
e = e.Z;
|
||||
} else {
|
||||
e = e.Y;
|
||||
}
|
||||
}
|
||||
return r === undefined ? this.J : r;
|
||||
};
|
||||
TreeContainer.prototype.he = function(e) {
|
||||
while (true) {
|
||||
var i = e.tt;
|
||||
if (i === this.J) return;
|
||||
if (e.ee === 1) {
|
||||
e.ee = 0;
|
||||
return;
|
||||
}
|
||||
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.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.Y && r.Y.ee === 1) {
|
||||
r.ee = 1;
|
||||
r.Y.ee = 0;
|
||||
r.rotateRight();
|
||||
} else {
|
||||
r.ee = 1;
|
||||
e = i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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.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.Z && r.Z.ee === 1) {
|
||||
r.ee = 1;
|
||||
r.Z.ee = 0;
|
||||
r.rotateLeft();
|
||||
} else {
|
||||
r.ee = 1;
|
||||
e = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
TreeContainer.prototype.fe = function(e) {
|
||||
var i, r;
|
||||
if (this.o === 1) {
|
||||
this.clear();
|
||||
return this.J;
|
||||
}
|
||||
var t = e;
|
||||
while (t.Y || t.Z) {
|
||||
if (t.Z) {
|
||||
t = t.Z;
|
||||
while (t.Y) t = t.Y;
|
||||
} else {
|
||||
t = t.Y;
|
||||
}
|
||||
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.J.Y === t) {
|
||||
this.J.Y = t.tt;
|
||||
} else if (this.J.Z === t) {
|
||||
this.J.Z = t.tt;
|
||||
}
|
||||
this.he(t);
|
||||
var n = t.tt;
|
||||
if (t === n.Y) {
|
||||
n.Y = undefined;
|
||||
} else n.Z = undefined;
|
||||
this.o -= 1;
|
||||
this.rr.ee = 0;
|
||||
return n;
|
||||
};
|
||||
TreeContainer.prototype.ne = function(e) {
|
||||
while (true) {
|
||||
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.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.tt;
|
||||
if (n.Y === r) {
|
||||
n.Y = e;
|
||||
} else n.Z = e;
|
||||
}
|
||||
e.tt = r.tt;
|
||||
i.tt = e;
|
||||
r.tt = e;
|
||||
r.ee = 1;
|
||||
return {
|
||||
parentNode: i,
|
||||
grandParent: r,
|
||||
curNode: e
|
||||
};
|
||||
} else {
|
||||
i.ee = 0;
|
||||
if (r === this.rr) {
|
||||
this.rr = r.rotateRight();
|
||||
} else r.rotateRight();
|
||||
r.ee = 1;
|
||||
}
|
||||
} else {
|
||||
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.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.tt;
|
||||
if (n.Y === r) {
|
||||
n.Y = e;
|
||||
} else n.Z = e;
|
||||
}
|
||||
e.tt = r.tt;
|
||||
i.tt = e;
|
||||
r.tt = e;
|
||||
r.ee = 1;
|
||||
return {
|
||||
parentNode: i,
|
||||
grandParent: r,
|
||||
curNode: e
|
||||
};
|
||||
} else {
|
||||
i.ee = 0;
|
||||
if (r === this.rr) {
|
||||
this.rr = r.rotateLeft();
|
||||
} else r.rotateLeft();
|
||||
r.ee = 1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
TreeContainer.prototype.te = function(e, i, r) {
|
||||
if (this.rr === undefined) {
|
||||
this.o += 1;
|
||||
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.J.Y;
|
||||
var s = this.A(n.W, e);
|
||||
if (s === 0) {
|
||||
n.L = i;
|
||||
return;
|
||||
} else if (s > 0) {
|
||||
n.Y = new this.re(e, i);
|
||||
n.Y.tt = n;
|
||||
t = n.Y;
|
||||
this.J.Y = t;
|
||||
} else {
|
||||
var f = this.J.Z;
|
||||
var h = this.A(f.W, e);
|
||||
if (h === 0) {
|
||||
f.L = i;
|
||||
return;
|
||||
} else if (h < 0) {
|
||||
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.J) {
|
||||
var a = this.A(u.W, e);
|
||||
if (a === 0) {
|
||||
u.L = i;
|
||||
return;
|
||||
} else if (a > 0) {
|
||||
var o = u.pre();
|
||||
var l = this.A(o.W, e);
|
||||
if (l === 0) {
|
||||
o.L = i;
|
||||
return;
|
||||
} else if (l < 0) {
|
||||
t = new this.re(e, i);
|
||||
if (o.Z === undefined) {
|
||||
o.Z = t;
|
||||
t.tt = o;
|
||||
} else {
|
||||
u.Y = t;
|
||||
t.tt = u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t === undefined) {
|
||||
t = this.rr;
|
||||
while (true) {
|
||||
var d = this.A(t.W, e);
|
||||
if (d > 0) {
|
||||
if (t.Y === undefined) {
|
||||
t.Y = new this.re(e, i);
|
||||
t.Y.tt = t;
|
||||
t = t.Y;
|
||||
break;
|
||||
}
|
||||
t = t.Y;
|
||||
} else if (d < 0) {
|
||||
if (t.Z === undefined) {
|
||||
t.Z = new this.re(e, i);
|
||||
t.Z.tt = t;
|
||||
t = t.Z;
|
||||
break;
|
||||
}
|
||||
t = t.Z;
|
||||
} else {
|
||||
t.L = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.o += 1;
|
||||
return t;
|
||||
};
|
||||
TreeContainer.prototype.clear = function() {
|
||||
this.o = 0;
|
||||
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.J) {
|
||||
throw new TypeError("Invalid iterator!");
|
||||
}
|
||||
if (this.o === 1) {
|
||||
r.W = i;
|
||||
return true;
|
||||
}
|
||||
if (r === this.J.Y) {
|
||||
if (this.A(r.next().W, i) > 0) {
|
||||
r.W = i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (r === this.J.Z) {
|
||||
if (this.A(r.pre().W, i) < 0) {
|
||||
r.W = i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var t = r.pre().W;
|
||||
if (this.A(t, i) >= 0) return false;
|
||||
var n = r.next().W;
|
||||
if (this.A(n, i) <= 0) return false;
|
||||
r.W = i;
|
||||
return true;
|
||||
};
|
||||
TreeContainer.prototype.eraseElementByPos = function(e) {
|
||||
var i = this;
|
||||
if (e < 0 || e > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var r = 0;
|
||||
this.ie(this.rr, (function(t) {
|
||||
if (e === r) {
|
||||
i.se(t);
|
||||
return true;
|
||||
}
|
||||
r += 1;
|
||||
return false;
|
||||
}));
|
||||
};
|
||||
TreeContainer.prototype.ar = function(e, i) {
|
||||
while (e) {
|
||||
var r = this.A(e.W, i);
|
||||
if (r < 0) {
|
||||
e = e.Z;
|
||||
} else if (r > 0) {
|
||||
e = e.Y;
|
||||
} else return e;
|
||||
}
|
||||
return e;
|
||||
};
|
||||
TreeContainer.prototype.eraseElementByKey = function(e) {
|
||||
if (!this.o) return;
|
||||
var i = this.ar(this.rr, e);
|
||||
if (i === undefined) return;
|
||||
this.se(i);
|
||||
};
|
||||
TreeContainer.prototype.eraseElementByIterator = function(e) {
|
||||
var i = e.D;
|
||||
if (i === this.J) {
|
||||
throw new RangeError("Invalid iterator");
|
||||
}
|
||||
if (i.Z === undefined) {
|
||||
e = e.next();
|
||||
}
|
||||
this.se(i);
|
||||
return e;
|
||||
};
|
||||
TreeContainer.prototype.getHeight = function() {
|
||||
if (!this.o) return 0;
|
||||
var traversal = function(e) {
|
||||
if (!e) return 0;
|
||||
return Math.max(traversal(e.Y), traversal(e.Z)) + 1;
|
||||
};
|
||||
return traversal(this.rr);
|
||||
};
|
||||
return TreeContainer;
|
||||
}(Container);
|
||||
|
||||
export default TreeContainer;
|
||||
42
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.d.ts
generated
vendored
Normal file
42
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import TreeContainer from './Base';
|
||||
import TreeIterator from './Base/TreeIterator';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
export declare class OrderedMapIterator<K, V> extends TreeIterator<K, V> {
|
||||
get pointer(): [K, V];
|
||||
copy(): OrderedMapIterator<K, V>;
|
||||
}
|
||||
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);
|
||||
begin(): OrderedMapIterator<K, V>;
|
||||
end(): OrderedMapIterator<K, V>;
|
||||
rBegin(): OrderedMapIterator<K, V>;
|
||||
rEnd(): OrderedMapIterator<K, V>;
|
||||
front(): [K, V] | undefined;
|
||||
back(): [K, V] | undefined;
|
||||
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>;
|
||||
/**
|
||||
* @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>;
|
||||
/**
|
||||
* @description Get the _value of the element of the specified _key.
|
||||
*/
|
||||
getElementByKey(_key: K): V | undefined;
|
||||
getElementByPos(pos: number): [K, V];
|
||||
union(other: OrderedMap<K, V>): void;
|
||||
[Symbol.iterator](): Generator<[K, V], void, undefined>;
|
||||
}
|
||||
export default OrderedMap;
|
||||
334
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.js
generated
vendored
Normal file
334
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.js
generated
vendored
Normal file
@@ -0,0 +1,334 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(r, e) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(r, e) {
|
||||
r.__proto__ = e;
|
||||
} || function(r, e) {
|
||||
for (var t in e) if (Object.prototype.hasOwnProperty.call(e, t)) r[t] = e[t];
|
||||
};
|
||||
return extendStatics(r, e);
|
||||
};
|
||||
return function(r, e) {
|
||||
if (typeof e !== "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
|
||||
extendStatics(r, e);
|
||||
function __() {
|
||||
this.constructor = r;
|
||||
}
|
||||
r.prototype = e === null ? Object.create(e) : (__.prototype = e.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(r, e) {
|
||||
var t = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (a[0] & 1) throw a[1];
|
||||
return a[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, n, i, a, o;
|
||||
return o = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (o[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), o;
|
||||
function verb(r) {
|
||||
return function(e) {
|
||||
return step([ r, e ]);
|
||||
};
|
||||
}
|
||||
function step(o) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (t) try {
|
||||
if (n = 1, i && (a = o[0] & 2 ? i["return"] : o[0] ? i["throw"] || ((a = i["return"]) && a.call(i),
|
||||
0) : i.next) && !(a = a.call(i, o[1])).done) return a;
|
||||
if (i = 0, a) o = [ o[0] & 2, a.value ];
|
||||
switch (o[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
a = o;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
t.label++;
|
||||
return {
|
||||
value: o[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
t.label++;
|
||||
i = o[1];
|
||||
o = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
o = t.ops.pop();
|
||||
t.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(a = t.trys, a = a.length > 0 && a[a.length - 1]) && (o[0] === 6 || o[0] === 2)) {
|
||||
t = 0;
|
||||
continue;
|
||||
}
|
||||
if (o[0] === 3 && (!a || o[1] > a[0] && o[1] < a[3])) {
|
||||
t.label = o[1];
|
||||
break;
|
||||
}
|
||||
if (o[0] === 6 && t.label < a[1]) {
|
||||
t.label = a[1];
|
||||
a = o;
|
||||
break;
|
||||
}
|
||||
if (a && t.label < a[2]) {
|
||||
t.label = a[2];
|
||||
t.ops.push(o);
|
||||
break;
|
||||
}
|
||||
if (a[2]) t.ops.pop();
|
||||
t.trys.pop();
|
||||
continue;
|
||||
}
|
||||
o = e.call(r, t);
|
||||
} catch (r) {
|
||||
o = [ 6, r ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = a = 0;
|
||||
}
|
||||
if (o[0] & 5) throw o[1];
|
||||
return {
|
||||
value: o[0] ? o[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __read = this && this._ || function(r, e) {
|
||||
var t = typeof Symbol === "function" && r[Symbol.iterator];
|
||||
if (!t) return r;
|
||||
var n = t.call(r), i, a = [], o;
|
||||
try {
|
||||
while ((e === void 0 || e-- > 0) && !(i = n.next()).done) a.push(i.value);
|
||||
} catch (r) {
|
||||
o = {
|
||||
error: r
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (i && !i.done && (t = n["return"])) t.call(n);
|
||||
} finally {
|
||||
if (o) throw o.error;
|
||||
}
|
||||
}
|
||||
return a;
|
||||
};
|
||||
|
||||
var __values = this && this.u || function(r) {
|
||||
var e = typeof Symbol === "function" && Symbol.iterator, t = e && r[e], n = 0;
|
||||
if (t) return t.call(r);
|
||||
if (r && typeof r.length === "number") return {
|
||||
next: function() {
|
||||
if (r && n >= r.length) r = void 0;
|
||||
return {
|
||||
value: r && r[n++],
|
||||
done: !r
|
||||
};
|
||||
}
|
||||
};
|
||||
throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
|
||||
import TreeContainer from "./Base";
|
||||
|
||||
import TreeIterator from "./Base/TreeIterator";
|
||||
|
||||
var OrderedMapIterator = function(r) {
|
||||
__extends(OrderedMapIterator, r);
|
||||
function OrderedMapIterator() {
|
||||
return r !== null && r.apply(this, arguments) || this;
|
||||
}
|
||||
Object.defineProperty(OrderedMapIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
var r = this;
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("OrderedMap iterator access denied");
|
||||
}
|
||||
return new Proxy([], {
|
||||
get: function(e, t) {
|
||||
if (t === "0") return r.D.W; else if (t === "1") return r.D.L;
|
||||
},
|
||||
set: function(e, t, n) {
|
||||
if (t !== "1") {
|
||||
throw new TypeError("props must be 1");
|
||||
}
|
||||
r.D.L = n;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
OrderedMapIterator.prototype.copy = function() {
|
||||
return new OrderedMapIterator(this.D, this.J, this.iteratorType);
|
||||
};
|
||||
return OrderedMapIterator;
|
||||
}(TreeIterator);
|
||||
|
||||
export { OrderedMapIterator };
|
||||
|
||||
var OrderedMap = function(r) {
|
||||
__extends(OrderedMap, r);
|
||||
function OrderedMap(e, t, n) {
|
||||
if (e === void 0) {
|
||||
e = [];
|
||||
}
|
||||
var i = r.call(this, t, n) || this;
|
||||
i.X = function(r) {
|
||||
return __generator(this, (function(e) {
|
||||
switch (e.label) {
|
||||
case 0:
|
||||
if (r === undefined) return [ 2 ];
|
||||
return [ 5, __values(this.X(r.Y)) ];
|
||||
|
||||
case 1:
|
||||
e.sent();
|
||||
return [ 4, [ r.W, r.L ] ];
|
||||
|
||||
case 2:
|
||||
e.sent();
|
||||
return [ 5, __values(this.X(r.Z)) ];
|
||||
|
||||
case 3:
|
||||
e.sent();
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
};
|
||||
e.forEach((function(r) {
|
||||
var e = __read(r, 2), t = e[0], n = e[1];
|
||||
return i.setElement(t, n);
|
||||
}));
|
||||
return i;
|
||||
}
|
||||
OrderedMap.prototype.begin = function() {
|
||||
return new OrderedMapIterator(this.J.Y || this.J, this.J);
|
||||
};
|
||||
OrderedMap.prototype.end = function() {
|
||||
return new OrderedMapIterator(this.J, this.J);
|
||||
};
|
||||
OrderedMap.prototype.rBegin = function() {
|
||||
return new OrderedMapIterator(this.J.Z || this.J, this.J, 1);
|
||||
};
|
||||
OrderedMap.prototype.rEnd = function() {
|
||||
return new OrderedMapIterator(this.J, this.J, 1);
|
||||
};
|
||||
OrderedMap.prototype.front = function() {
|
||||
if (!this.o) return undefined;
|
||||
var r = this.J.Y;
|
||||
return [ r.W, r.L ];
|
||||
};
|
||||
OrderedMap.prototype.back = function() {
|
||||
if (!this.o) return undefined;
|
||||
var r = this.J.Z;
|
||||
return [ r.W, r.L ];
|
||||
};
|
||||
OrderedMap.prototype.forEach = function(r) {
|
||||
var e, t;
|
||||
var n = 0;
|
||||
try {
|
||||
for (var i = __values(this), a = i.next(); !a.done; a = i.next()) {
|
||||
var o = a.value;
|
||||
r(o, n++);
|
||||
}
|
||||
} catch (r) {
|
||||
e = {
|
||||
error: r
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (a && !a.done && (t = i.return)) t.call(i);
|
||||
} finally {
|
||||
if (e) throw e.error;
|
||||
}
|
||||
}
|
||||
};
|
||||
OrderedMap.prototype.lowerBound = function(r) {
|
||||
var e = this.$(this.rr, r);
|
||||
return new OrderedMapIterator(e, this.J);
|
||||
};
|
||||
OrderedMap.prototype.upperBound = function(r) {
|
||||
var e = this.er(this.rr, r);
|
||||
return new OrderedMapIterator(e, this.J);
|
||||
};
|
||||
OrderedMap.prototype.reverseLowerBound = function(r) {
|
||||
var e = this.tr(this.rr, r);
|
||||
return new OrderedMapIterator(e, this.J);
|
||||
};
|
||||
OrderedMap.prototype.reverseUpperBound = function(r) {
|
||||
var e = this.nr(this.rr, r);
|
||||
return new OrderedMapIterator(e, this.J);
|
||||
};
|
||||
OrderedMap.prototype.setElement = function(r, e, t) {
|
||||
this.ir(r, e, t);
|
||||
};
|
||||
OrderedMap.prototype.find = function(r) {
|
||||
var e = this.ar(this.rr, r);
|
||||
if (e !== undefined) {
|
||||
return new OrderedMapIterator(e, this.J);
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
OrderedMap.prototype.getElementByKey = function(r) {
|
||||
var e = this.ar(this.rr, r);
|
||||
return e ? e.L : undefined;
|
||||
};
|
||||
OrderedMap.prototype.getElementByPos = function(r) {
|
||||
var e, t;
|
||||
if (r < 0 || r > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var n;
|
||||
var i = 0;
|
||||
try {
|
||||
for (var a = __values(this), o = a.next(); !o.done; o = a.next()) {
|
||||
var u = o.value;
|
||||
if (i === r) {
|
||||
n = u;
|
||||
break;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
} catch (r) {
|
||||
e = {
|
||||
error: r
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (o && !o.done && (t = a.return)) t.call(a);
|
||||
} finally {
|
||||
if (e) throw e.error;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
};
|
||||
OrderedMap.prototype.union = function(r) {
|
||||
var e = this;
|
||||
r.forEach((function(r) {
|
||||
var t = __read(r, 2), n = t[0], i = t[1];
|
||||
return e.setElement(n, i);
|
||||
}));
|
||||
};
|
||||
OrderedMap.prototype[Symbol.iterator] = function() {
|
||||
return this.X(this.rr);
|
||||
};
|
||||
return OrderedMap;
|
||||
}(TreeContainer);
|
||||
|
||||
export default OrderedMap;
|
||||
37
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.d.ts
generated
vendored
Normal file
37
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import TreeContainer from './Base';
|
||||
import TreeIterator from './Base/TreeIterator';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
export declare class OrderedSetIterator<K> extends TreeIterator<K, undefined> {
|
||||
get pointer(): K;
|
||||
copy(): OrderedSetIterator<K>;
|
||||
}
|
||||
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);
|
||||
begin(): OrderedSetIterator<K>;
|
||||
end(): OrderedSetIterator<K>;
|
||||
rBegin(): OrderedSetIterator<K>;
|
||||
rEnd(): OrderedSetIterator<K>;
|
||||
front(): K | undefined;
|
||||
back(): K | undefined;
|
||||
forEach(callback: (element: K, index: number) => void): void;
|
||||
getElementByPos(pos: number): K;
|
||||
/**
|
||||
* @description Insert element to set.
|
||||
* @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;
|
||||
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>;
|
||||
union(other: OrderedSet<K>): void;
|
||||
[Symbol.iterator](): Generator<K, void, undefined>;
|
||||
}
|
||||
export default OrderedSet;
|
||||
292
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.js
generated
vendored
Normal file
292
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.js
generated
vendored
Normal file
@@ -0,0 +1,292 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(e, r) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(e, r) {
|
||||
e.__proto__ = r;
|
||||
} || function(e, r) {
|
||||
for (var t in r) if (Object.prototype.hasOwnProperty.call(r, t)) e[t] = r[t];
|
||||
};
|
||||
return extendStatics(e, r);
|
||||
};
|
||||
return function(e, r) {
|
||||
if (typeof r !== "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
||||
extendStatics(e, r);
|
||||
function __() {
|
||||
this.constructor = e;
|
||||
}
|
||||
e.prototype = r === null ? Object.create(r) : (__.prototype = r.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(e, r) {
|
||||
var t = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (o[0] & 1) throw o[1];
|
||||
return o[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, n, i, o, u;
|
||||
return u = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (u[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), u;
|
||||
function verb(e) {
|
||||
return function(r) {
|
||||
return step([ e, r ]);
|
||||
};
|
||||
}
|
||||
function step(u) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (t) try {
|
||||
if (n = 1, i && (o = u[0] & 2 ? i["return"] : u[0] ? i["throw"] || ((o = i["return"]) && o.call(i),
|
||||
0) : i.next) && !(o = o.call(i, u[1])).done) return o;
|
||||
if (i = 0, o) u = [ u[0] & 2, o.value ];
|
||||
switch (u[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
o = u;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
t.label++;
|
||||
return {
|
||||
value: u[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
t.label++;
|
||||
i = u[1];
|
||||
u = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
u = t.ops.pop();
|
||||
t.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(o = t.trys, o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
|
||||
t = 0;
|
||||
continue;
|
||||
}
|
||||
if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
|
||||
t.label = u[1];
|
||||
break;
|
||||
}
|
||||
if (u[0] === 6 && t.label < o[1]) {
|
||||
t.label = o[1];
|
||||
o = u;
|
||||
break;
|
||||
}
|
||||
if (o && t.label < o[2]) {
|
||||
t.label = o[2];
|
||||
t.ops.push(u);
|
||||
break;
|
||||
}
|
||||
if (o[2]) t.ops.pop();
|
||||
t.trys.pop();
|
||||
continue;
|
||||
}
|
||||
u = r.call(e, t);
|
||||
} catch (e) {
|
||||
u = [ 6, e ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = o = 0;
|
||||
}
|
||||
if (u[0] & 5) throw u[1];
|
||||
return {
|
||||
value: u[0] ? u[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __values = this && this.u || function(e) {
|
||||
var r = typeof Symbol === "function" && Symbol.iterator, t = r && e[r], n = 0;
|
||||
if (t) return t.call(e);
|
||||
if (e && typeof e.length === "number") return {
|
||||
next: function() {
|
||||
if (e && n >= e.length) e = void 0;
|
||||
return {
|
||||
value: e && e[n++],
|
||||
done: !e
|
||||
};
|
||||
}
|
||||
};
|
||||
throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
|
||||
import TreeContainer from "./Base";
|
||||
|
||||
import TreeIterator from "./Base/TreeIterator";
|
||||
|
||||
var OrderedSetIterator = function(e) {
|
||||
__extends(OrderedSetIterator, e);
|
||||
function OrderedSetIterator() {
|
||||
return e !== null && e.apply(this, arguments) || this;
|
||||
}
|
||||
Object.defineProperty(OrderedSetIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("OrderedSet iterator access denied!");
|
||||
}
|
||||
return this.D.W;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
OrderedSetIterator.prototype.copy = function() {
|
||||
return new OrderedSetIterator(this.D, this.J, this.iteratorType);
|
||||
};
|
||||
return OrderedSetIterator;
|
||||
}(TreeIterator);
|
||||
|
||||
export { OrderedSetIterator };
|
||||
|
||||
var OrderedSet = function(e) {
|
||||
__extends(OrderedSet, e);
|
||||
function OrderedSet(r, t, n) {
|
||||
if (r === void 0) {
|
||||
r = [];
|
||||
}
|
||||
var i = e.call(this, t, n) || this;
|
||||
i.X = function(e) {
|
||||
return __generator(this, (function(r) {
|
||||
switch (r.label) {
|
||||
case 0:
|
||||
if (e === undefined) return [ 2 ];
|
||||
return [ 5, __values(this.X(e.Y)) ];
|
||||
|
||||
case 1:
|
||||
r.sent();
|
||||
return [ 4, e.W ];
|
||||
|
||||
case 2:
|
||||
r.sent();
|
||||
return [ 5, __values(this.X(e.Z)) ];
|
||||
|
||||
case 3:
|
||||
r.sent();
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
};
|
||||
r.forEach((function(e) {
|
||||
return i.insert(e);
|
||||
}));
|
||||
return i;
|
||||
}
|
||||
OrderedSet.prototype.begin = function() {
|
||||
return new OrderedSetIterator(this.J.Y || this.J, this.J);
|
||||
};
|
||||
OrderedSet.prototype.end = function() {
|
||||
return new OrderedSetIterator(this.J, this.J);
|
||||
};
|
||||
OrderedSet.prototype.rBegin = function() {
|
||||
return new OrderedSetIterator(this.J.Z || this.J, this.J, 1);
|
||||
};
|
||||
OrderedSet.prototype.rEnd = function() {
|
||||
return new OrderedSetIterator(this.J, this.J, 1);
|
||||
};
|
||||
OrderedSet.prototype.front = function() {
|
||||
return this.J.Y ? this.J.Y.W : undefined;
|
||||
};
|
||||
OrderedSet.prototype.back = function() {
|
||||
return this.J.Z ? this.J.Z.W : undefined;
|
||||
};
|
||||
OrderedSet.prototype.forEach = function(e) {
|
||||
var r, t;
|
||||
var n = 0;
|
||||
try {
|
||||
for (var i = __values(this), o = i.next(); !o.done; o = i.next()) {
|
||||
var u = o.value;
|
||||
e(u, n++);
|
||||
}
|
||||
} catch (e) {
|
||||
r = {
|
||||
error: e
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (o && !o.done && (t = i.return)) t.call(i);
|
||||
} finally {
|
||||
if (r) throw r.error;
|
||||
}
|
||||
}
|
||||
};
|
||||
OrderedSet.prototype.getElementByPos = function(e) {
|
||||
var r, t;
|
||||
if (e < 0 || e > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var n;
|
||||
var i = 0;
|
||||
try {
|
||||
for (var o = __values(this), u = o.next(); !u.done; u = o.next()) {
|
||||
var d = u.value;
|
||||
if (i === e) {
|
||||
n = d;
|
||||
break;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
} catch (e) {
|
||||
r = {
|
||||
error: e
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (u && !u.done && (t = o.return)) t.call(o);
|
||||
} finally {
|
||||
if (r) throw r.error;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
};
|
||||
OrderedSet.prototype.insert = function(e, r) {
|
||||
this.ir(e, undefined, r);
|
||||
};
|
||||
OrderedSet.prototype.find = function(e) {
|
||||
var r = this.ar(this.rr, e);
|
||||
if (r !== undefined) {
|
||||
return new OrderedSetIterator(r, this.J);
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
OrderedSet.prototype.lowerBound = function(e) {
|
||||
var r = this.$(this.rr, e);
|
||||
return new OrderedSetIterator(r, this.J);
|
||||
};
|
||||
OrderedSet.prototype.upperBound = function(e) {
|
||||
var r = this.er(this.rr, e);
|
||||
return new OrderedSetIterator(r, this.J);
|
||||
};
|
||||
OrderedSet.prototype.reverseLowerBound = function(e) {
|
||||
var r = this.tr(this.rr, e);
|
||||
return new OrderedSetIterator(r, this.J);
|
||||
};
|
||||
OrderedSet.prototype.reverseUpperBound = function(e) {
|
||||
var r = this.nr(this.rr, e);
|
||||
return new OrderedSetIterator(r, this.J);
|
||||
};
|
||||
OrderedSet.prototype.union = function(e) {
|
||||
var r = this;
|
||||
e.forEach((function(e) {
|
||||
return r.insert(e);
|
||||
}));
|
||||
};
|
||||
OrderedSet.prototype[Symbol.iterator] = function() {
|
||||
return this.X(this.rr);
|
||||
};
|
||||
return OrderedSet;
|
||||
}(TreeContainer);
|
||||
|
||||
export default OrderedSet;
|
||||
Reference in New Issue
Block a user