Insane number of adds to setup env and packages
This commit is contained in:
120
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.d.ts
generated
vendored
Normal file
120
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
export declare const enum IteratorType {
|
||||
NORMAL = 0,
|
||||
REVERSE = 1
|
||||
}
|
||||
export declare abstract class ContainerIterator<T> {
|
||||
/**
|
||||
* @description Iterator's type.
|
||||
*/
|
||||
readonly iteratorType: IteratorType;
|
||||
protected constructor(iteratorType?: IteratorType);
|
||||
/**
|
||||
* @description Pointers to element.
|
||||
* @return The value of the pointer's element.
|
||||
*/
|
||||
abstract get pointer(): T;
|
||||
/**
|
||||
* @description Set pointer's value (some containers are unavailable).
|
||||
* @param newValue The new value you want to set.
|
||||
*/
|
||||
abstract set pointer(newValue: T);
|
||||
/**
|
||||
* @description Move `this` iterator to pre.
|
||||
*/
|
||||
abstract pre(): this;
|
||||
/**
|
||||
* @description Move `this` iterator to next.
|
||||
*/
|
||||
abstract next(): this;
|
||||
/**
|
||||
* @param obj The other iterator you want to compare.
|
||||
* @return Boolean about if this equals to obj.
|
||||
* @example container.find(1).equals(container.end());
|
||||
*/
|
||||
abstract equals(obj: ContainerIterator<T>): boolean;
|
||||
/**
|
||||
* @description Get a copy of itself.<br/>
|
||||
* We do not guarantee the safety of this function.<br/>
|
||||
* Please ensure that the iterator will not fail.
|
||||
* @return The copy of self.
|
||||
*/
|
||||
abstract copy(): ContainerIterator<T>;
|
||||
}
|
||||
export declare abstract class Base {
|
||||
/**
|
||||
* @return The size of the container.
|
||||
*/
|
||||
size(): number;
|
||||
/**
|
||||
* @return Boolean about if the container is empty.
|
||||
*/
|
||||
empty(): boolean;
|
||||
/**
|
||||
* @description Clear the container.
|
||||
*/
|
||||
abstract clear(): void;
|
||||
}
|
||||
export declare abstract class Container<T> extends Base {
|
||||
/**
|
||||
* @return Iterator pointing to the beginning element.
|
||||
*/
|
||||
abstract begin(): ContainerIterator<T>;
|
||||
/**
|
||||
* @return Iterator pointing to the super end like c++.
|
||||
*/
|
||||
abstract end(): ContainerIterator<T>;
|
||||
/**
|
||||
* @return Iterator pointing to the end element.
|
||||
*/
|
||||
abstract rBegin(): ContainerIterator<T>;
|
||||
/**
|
||||
* @return Iterator pointing to the super begin like c++.
|
||||
*/
|
||||
abstract rEnd(): ContainerIterator<T>;
|
||||
/**
|
||||
* @return The first element of the container.
|
||||
*/
|
||||
abstract front(): T | undefined;
|
||||
/**
|
||||
* @return The last element of the container.
|
||||
*/
|
||||
abstract back(): T | undefined;
|
||||
/**
|
||||
* @description Iterate over all elements in the container.
|
||||
* @param callback Callback function like Array.forEach.
|
||||
*/
|
||||
abstract forEach(callback: (element: T, index: number) => void): void;
|
||||
/**
|
||||
* @param element The element you want to find.
|
||||
* @return An iterator pointing to the element if found, or super end if not found.
|
||||
*/
|
||||
abstract find(element: T): ContainerIterator<T>;
|
||||
/**
|
||||
* @description Gets the value of the element at the specified position.
|
||||
*/
|
||||
abstract getElementByPos(pos: number): T;
|
||||
/**
|
||||
* @description Removes the element at the specified position.
|
||||
* @param pos The element's position you want to remove.
|
||||
*/
|
||||
abstract eraseElementByPos(pos: number): void;
|
||||
/**
|
||||
* @description Removes element by iterator and move `iter` to next.
|
||||
* @param iter The iterator you want to erase.
|
||||
* @example container.eraseElementByIterator(container.begin());
|
||||
*/
|
||||
abstract eraseElementByIterator(iter: ContainerIterator<T>): ContainerIterator<T>;
|
||||
/**
|
||||
* @description Using for `for...of` syntax like Array.
|
||||
*/
|
||||
abstract [Symbol.iterator](): Generator<T, void, undefined>;
|
||||
}
|
||||
export declare type initContainer<T> = ({
|
||||
size: number;
|
||||
} | {
|
||||
length: number;
|
||||
} | {
|
||||
size(): number;
|
||||
}) & {
|
||||
forEach(callback: (element: T) => void): void;
|
||||
};
|
||||
57
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.js
generated
vendored
Normal file
57
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(n, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(n, t) {
|
||||
n.__proto__ = t;
|
||||
} || function(n, t) {
|
||||
for (var r in t) if (Object.prototype.hasOwnProperty.call(t, r)) n[r] = t[r];
|
||||
};
|
||||
return extendStatics(n, t);
|
||||
};
|
||||
return function(n, t) {
|
||||
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
||||
extendStatics(n, t);
|
||||
function __() {
|
||||
this.constructor = n;
|
||||
}
|
||||
n.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var ContainerIterator = function() {
|
||||
function ContainerIterator(n) {
|
||||
if (n === void 0) {
|
||||
n = 0;
|
||||
}
|
||||
this.iteratorType = n;
|
||||
}
|
||||
return ContainerIterator;
|
||||
}();
|
||||
|
||||
export { ContainerIterator };
|
||||
|
||||
var Base = function() {
|
||||
function Base() {
|
||||
this.o = 0;
|
||||
}
|
||||
Base.prototype.size = function() {
|
||||
return this.o;
|
||||
};
|
||||
Base.prototype.empty = function() {
|
||||
return this.o === 0;
|
||||
};
|
||||
return Base;
|
||||
}();
|
||||
|
||||
export { Base };
|
||||
|
||||
var Container = function(n) {
|
||||
__extends(Container, n);
|
||||
function Container() {
|
||||
return n !== null && n.apply(this, arguments) || this;
|
||||
}
|
||||
return Container;
|
||||
}(Base);
|
||||
|
||||
export { Container };
|
||||
25
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.d.ts
generated
vendored
Normal file
25
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Base } from "../../ContainerBase";
|
||||
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;
|
||||
/**
|
||||
* @description Remove the elements of the specified value.
|
||||
* @param key The element you want to remove.
|
||||
*/
|
||||
abstract eraseElementByKey(key: K): void;
|
||||
/**
|
||||
* @param key The element you want to find.
|
||||
* @return Boolean about if the specified element in the hash set.
|
||||
*/
|
||||
abstract find(key: K): void;
|
||||
/**
|
||||
* @description Using for `for...of` syntax like Array.
|
||||
*/
|
||||
abstract [Symbol.iterator](): Generator<K | [K, unknown], void, undefined>;
|
||||
}
|
||||
export default HashContainer;
|
||||
62
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.js
generated
vendored
Normal file
62
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(n, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(n, t) {
|
||||
n.__proto__ = t;
|
||||
} || function(n, t) {
|
||||
for (var r in t) if (Object.prototype.hasOwnProperty.call(t, r)) n[r] = t[r];
|
||||
};
|
||||
return extendStatics(n, t);
|
||||
};
|
||||
return function(n, t) {
|
||||
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
||||
extendStatics(n, t);
|
||||
function __() {
|
||||
this.constructor = n;
|
||||
}
|
||||
n.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { Base } from "../../ContainerBase";
|
||||
|
||||
var HashContainer = function(n) {
|
||||
__extends(HashContainer, n);
|
||||
function HashContainer(t, r) {
|
||||
if (t === void 0) {
|
||||
t = 16;
|
||||
}
|
||||
if (r === void 0) {
|
||||
r = function(n) {
|
||||
var t;
|
||||
if (typeof n !== "string") {
|
||||
t = JSON.stringify(n);
|
||||
} else t = n;
|
||||
var r = 0;
|
||||
var i = t.length;
|
||||
for (var e = 0; e < i; e++) {
|
||||
var o = t.charCodeAt(e);
|
||||
r = (r << 5) - r + o;
|
||||
r |= 0;
|
||||
}
|
||||
return r >>> 0;
|
||||
};
|
||||
}
|
||||
var i = n.call(this) || this;
|
||||
if (t < 16 || (t & t - 1) !== 0) {
|
||||
throw new RangeError("InitBucketNum range error");
|
||||
}
|
||||
i.l = i.nn = t;
|
||||
i.p = r;
|
||||
return i;
|
||||
}
|
||||
HashContainer.prototype.clear = function() {
|
||||
this.o = 0;
|
||||
this.l = this.nn;
|
||||
this.h = [];
|
||||
};
|
||||
return HashContainer;
|
||||
}(Base);
|
||||
|
||||
export default HashContainer;
|
||||
22
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.d.ts
generated
vendored
Normal file
22
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { initContainer } from "../ContainerBase";
|
||||
import HashContainer from './Base';
|
||||
declare class HashMap<K, V> extends HashContainer<K> {
|
||||
constructor(container?: initContainer<[K, V]>, initBucketNum?: number, hashFunc?: (x: K) => number);
|
||||
forEach(callback: (element: [K, V], index: number) => void): void;
|
||||
/**
|
||||
* @description Insert a new key-value pair to hash map or set value by key.
|
||||
* @param key The key you want to insert.
|
||||
* @param value The value you want to insert.
|
||||
* @example HashMap.setElement(1, 2); // insert a key-value pair [1, 2]
|
||||
*/
|
||||
setElement(key: K, value: V): void;
|
||||
/**
|
||||
* @description Get the value of the element which has the specified key.
|
||||
* @param key The key you want to get.
|
||||
*/
|
||||
getElementByKey(key: K): V | undefined;
|
||||
eraseElementByKey(key: K): void;
|
||||
find(key: K): boolean;
|
||||
[Symbol.iterator](): Generator<[K, V], void, unknown>;
|
||||
}
|
||||
export default HashMap;
|
||||
410
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.js
generated
vendored
Normal file
410
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.js
generated
vendored
Normal file
@@ -0,0 +1,410 @@
|
||||
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, f;
|
||||
return f = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (f[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), f;
|
||||
function verb(r) {
|
||||
return function(e) {
|
||||
return step([ r, e ]);
|
||||
};
|
||||
}
|
||||
function step(f) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (t) try {
|
||||
if (n = 1, i && (a = f[0] & 2 ? i["return"] : f[0] ? i["throw"] || ((a = i["return"]) && a.call(i),
|
||||
0) : i.next) && !(a = a.call(i, f[1])).done) return a;
|
||||
if (i = 0, a) f = [ f[0] & 2, a.value ];
|
||||
switch (f[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
a = f;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
t.label++;
|
||||
return {
|
||||
value: f[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
t.label++;
|
||||
i = f[1];
|
||||
f = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
f = t.ops.pop();
|
||||
t.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(a = t.trys, a = a.length > 0 && a[a.length - 1]) && (f[0] === 6 || f[0] === 2)) {
|
||||
t = 0;
|
||||
continue;
|
||||
}
|
||||
if (f[0] === 3 && (!a || f[1] > a[0] && f[1] < a[3])) {
|
||||
t.label = f[1];
|
||||
break;
|
||||
}
|
||||
if (f[0] === 6 && t.label < a[1]) {
|
||||
t.label = a[1];
|
||||
a = f;
|
||||
break;
|
||||
}
|
||||
if (a && t.label < a[2]) {
|
||||
t.label = a[2];
|
||||
t.ops.push(f);
|
||||
break;
|
||||
}
|
||||
if (a[2]) t.ops.pop();
|
||||
t.trys.pop();
|
||||
continue;
|
||||
}
|
||||
f = e.call(r, t);
|
||||
} catch (r) {
|
||||
f = [ 6, r ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = a = 0;
|
||||
}
|
||||
if (f[0] & 5) throw f[1];
|
||||
return {
|
||||
value: f[0] ? f[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
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 HashContainer from "./Base";
|
||||
|
||||
import Vector from "../SequentialContainer/Vector";
|
||||
|
||||
import OrderedMap from "../TreeContainer/OrderedMap";
|
||||
|
||||
var HashMap = function(r) {
|
||||
__extends(HashMap, r);
|
||||
function HashMap(e, t, n) {
|
||||
if (e === void 0) {
|
||||
e = [];
|
||||
}
|
||||
var i = r.call(this, t, n) || this;
|
||||
i.h = [];
|
||||
e.forEach((function(r) {
|
||||
return i.setElement(r[0], r[1]);
|
||||
}));
|
||||
return i;
|
||||
}
|
||||
HashMap.prototype.v = function() {
|
||||
var r = this;
|
||||
if (this.l >= 1073741824) return;
|
||||
var e = [];
|
||||
var t = this.l;
|
||||
this.l <<= 1;
|
||||
var n = Object.keys(this.h);
|
||||
var i = n.length;
|
||||
var _loop_1 = function(i) {
|
||||
var f = parseInt(n[i]);
|
||||
var s = a.h[f];
|
||||
var o = s.size();
|
||||
if (o === 0) return "continue";
|
||||
if (o === 1) {
|
||||
var u = s.front();
|
||||
e[a.p(u[0]) & a.l - 1] = new Vector([ u ], false);
|
||||
return "continue";
|
||||
}
|
||||
var c = [];
|
||||
var h = [];
|
||||
s.forEach((function(e) {
|
||||
var n = r.p(e[0]);
|
||||
if ((n & t) === 0) {
|
||||
c.push(e);
|
||||
} else h.push(e);
|
||||
}));
|
||||
if (s instanceof OrderedMap) {
|
||||
if (c.length > 6) {
|
||||
e[f] = new OrderedMap(c);
|
||||
} else {
|
||||
e[f] = new Vector(c, false);
|
||||
}
|
||||
if (h.length > 6) {
|
||||
e[f + t] = new OrderedMap(h);
|
||||
} else {
|
||||
e[f + t] = new Vector(h, false);
|
||||
}
|
||||
} else {
|
||||
e[f] = new Vector(c, false);
|
||||
e[f + t] = new Vector(h, false);
|
||||
}
|
||||
};
|
||||
var a = this;
|
||||
for (var f = 0; f < i; ++f) {
|
||||
_loop_1(f);
|
||||
}
|
||||
this.h = e;
|
||||
};
|
||||
HashMap.prototype.forEach = function(r) {
|
||||
var e = Object.values(this.h);
|
||||
var t = e.length;
|
||||
var n = 0;
|
||||
for (var i = 0; i < t; ++i) {
|
||||
e[i].forEach((function(e) {
|
||||
return r(e, n++);
|
||||
}));
|
||||
}
|
||||
};
|
||||
HashMap.prototype.setElement = function(r, e) {
|
||||
var t, n;
|
||||
var i = this.p(r) & this.l - 1;
|
||||
var a = this.h[i];
|
||||
if (!a) {
|
||||
this.o += 1;
|
||||
this.h[i] = new Vector([ [ r, e ] ], false);
|
||||
} else {
|
||||
var f = a.size();
|
||||
if (a instanceof Vector) {
|
||||
try {
|
||||
for (var s = __values(a), o = s.next(); !o.done; o = s.next()) {
|
||||
var u = o.value;
|
||||
if (u[0] === r) {
|
||||
u[1] = e;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (r) {
|
||||
t = {
|
||||
error: r
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (o && !o.done && (n = s.return)) n.call(s);
|
||||
} finally {
|
||||
if (t) throw t.error;
|
||||
}
|
||||
}
|
||||
a.pushBack([ r, e ]);
|
||||
if (f + 1 >= 8) {
|
||||
if (this.l <= 64) {
|
||||
this.o += 1;
|
||||
this.v();
|
||||
return;
|
||||
}
|
||||
this.h[i] = new OrderedMap(this.h[i]);
|
||||
}
|
||||
this.o += 1;
|
||||
} else {
|
||||
a.setElement(r, e);
|
||||
var c = a.size();
|
||||
this.o += c - f;
|
||||
}
|
||||
}
|
||||
if (this.o > this.l * .75) {
|
||||
this.v();
|
||||
}
|
||||
};
|
||||
HashMap.prototype.getElementByKey = function(r) {
|
||||
var e, t;
|
||||
var n = this.p(r) & this.l - 1;
|
||||
var i = this.h[n];
|
||||
if (!i) return undefined;
|
||||
if (i instanceof OrderedMap) {
|
||||
return i.getElementByKey(r);
|
||||
} else {
|
||||
try {
|
||||
for (var a = __values(i), f = a.next(); !f.done; f = a.next()) {
|
||||
var s = f.value;
|
||||
if (s[0] === r) return s[1];
|
||||
}
|
||||
} catch (r) {
|
||||
e = {
|
||||
error: r
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (f && !f.done && (t = a.return)) t.call(a);
|
||||
} finally {
|
||||
if (e) throw e.error;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
HashMap.prototype.eraseElementByKey = function(r) {
|
||||
var e, t;
|
||||
var n = this.p(r) & this.l - 1;
|
||||
var i = this.h[n];
|
||||
if (!i) return;
|
||||
if (i instanceof Vector) {
|
||||
var a = 0;
|
||||
try {
|
||||
for (var f = __values(i), s = f.next(); !s.done; s = f.next()) {
|
||||
var o = s.value;
|
||||
if (o[0] === r) {
|
||||
i.eraseElementByPos(a);
|
||||
this.o -= 1;
|
||||
return;
|
||||
}
|
||||
a += 1;
|
||||
}
|
||||
} catch (r) {
|
||||
e = {
|
||||
error: r
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (s && !s.done && (t = f.return)) t.call(f);
|
||||
} finally {
|
||||
if (e) throw e.error;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var u = i.size();
|
||||
i.eraseElementByKey(r);
|
||||
var c = i.size();
|
||||
this.o += c - u;
|
||||
if (c <= 6) {
|
||||
this.h[n] = new Vector(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
HashMap.prototype.find = function(r) {
|
||||
var e, t;
|
||||
var n = this.p(r) & this.l - 1;
|
||||
var i = this.h[n];
|
||||
if (!i) return false;
|
||||
if (i instanceof OrderedMap) {
|
||||
return !i.find(r).equals(i.end());
|
||||
}
|
||||
try {
|
||||
for (var a = __values(i), f = a.next(); !f.done; f = a.next()) {
|
||||
var s = f.value;
|
||||
if (s[0] === r) return true;
|
||||
}
|
||||
} catch (r) {
|
||||
e = {
|
||||
error: r
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (f && !f.done && (t = a.return)) t.call(a);
|
||||
} finally {
|
||||
if (e) throw e.error;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
HashMap.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var r, e, t, n, i, a, f, s;
|
||||
var o, u;
|
||||
return __generator(this, (function(c) {
|
||||
switch (c.label) {
|
||||
case 0:
|
||||
r = Object.values(this.h);
|
||||
e = r.length;
|
||||
t = 0;
|
||||
c.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(t < e)) return [ 3, 10 ];
|
||||
n = r[t];
|
||||
c.label = 2;
|
||||
|
||||
case 2:
|
||||
c.trys.push([ 2, 7, 8, 9 ]);
|
||||
i = (o = void 0, __values(n)), a = i.next();
|
||||
c.label = 3;
|
||||
|
||||
case 3:
|
||||
if (!!a.done) return [ 3, 6 ];
|
||||
f = a.value;
|
||||
return [ 4, f ];
|
||||
|
||||
case 4:
|
||||
c.sent();
|
||||
c.label = 5;
|
||||
|
||||
case 5:
|
||||
a = i.next();
|
||||
return [ 3, 3 ];
|
||||
|
||||
case 6:
|
||||
return [ 3, 9 ];
|
||||
|
||||
case 7:
|
||||
s = c.sent();
|
||||
o = {
|
||||
error: s
|
||||
};
|
||||
return [ 3, 9 ];
|
||||
|
||||
case 8:
|
||||
try {
|
||||
if (a && !a.done && (u = i.return)) u.call(i);
|
||||
} finally {
|
||||
if (o) throw o.error;
|
||||
}
|
||||
return [ 7 ];
|
||||
|
||||
case 9:
|
||||
++t;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 10:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return HashMap;
|
||||
}(HashContainer);
|
||||
|
||||
export default HashMap;
|
||||
15
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.d.ts
generated
vendored
Normal file
15
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import HashContainer from './Base';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
declare class HashSet<K> extends HashContainer<K> {
|
||||
constructor(container?: initContainer<K>, initBucketNum?: number, _hashFunc?: (x: K) => number);
|
||||
forEach(callback: (element: K, index: number) => void): void;
|
||||
/**
|
||||
* @description Insert element to hash set.
|
||||
* @param element The element you want to insert.
|
||||
*/
|
||||
insert(element: K): void;
|
||||
eraseElementByKey(key: K): void;
|
||||
find(element: K): boolean;
|
||||
[Symbol.iterator](): Generator<K, void, unknown>;
|
||||
}
|
||||
export default HashSet;
|
||||
325
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.js
generated
vendored
Normal file
325
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.js
generated
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(e, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(e, t) {
|
||||
e.__proto__ = t;
|
||||
} || function(e, t) {
|
||||
for (var r in t) if (Object.prototype.hasOwnProperty.call(t, r)) e[r] = t[r];
|
||||
};
|
||||
return extendStatics(e, t);
|
||||
};
|
||||
return function(e, t) {
|
||||
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
||||
extendStatics(e, t);
|
||||
function __() {
|
||||
this.constructor = e;
|
||||
}
|
||||
e.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(e, t) {
|
||||
var r = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (a[0] & 1) throw a[1];
|
||||
return a[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, n, i, a, s;
|
||||
return s = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (s[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), s;
|
||||
function verb(e) {
|
||||
return function(t) {
|
||||
return step([ e, t ]);
|
||||
};
|
||||
}
|
||||
function step(s) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (r) try {
|
||||
if (n = 1, i && (a = s[0] & 2 ? i["return"] : s[0] ? i["throw"] || ((a = i["return"]) && a.call(i),
|
||||
0) : i.next) && !(a = a.call(i, s[1])).done) return a;
|
||||
if (i = 0, a) s = [ s[0] & 2, a.value ];
|
||||
switch (s[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
a = s;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
r.label++;
|
||||
return {
|
||||
value: s[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
r.label++;
|
||||
i = s[1];
|
||||
s = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
s = r.ops.pop();
|
||||
r.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(a = r.trys, a = a.length > 0 && a[a.length - 1]) && (s[0] === 6 || s[0] === 2)) {
|
||||
r = 0;
|
||||
continue;
|
||||
}
|
||||
if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
|
||||
r.label = s[1];
|
||||
break;
|
||||
}
|
||||
if (s[0] === 6 && r.label < a[1]) {
|
||||
r.label = a[1];
|
||||
a = s;
|
||||
break;
|
||||
}
|
||||
if (a && r.label < a[2]) {
|
||||
r.label = a[2];
|
||||
r.ops.push(s);
|
||||
break;
|
||||
}
|
||||
if (a[2]) r.ops.pop();
|
||||
r.trys.pop();
|
||||
continue;
|
||||
}
|
||||
s = t.call(e, r);
|
||||
} catch (e) {
|
||||
s = [ 6, e ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = a = 0;
|
||||
}
|
||||
if (s[0] & 5) throw s[1];
|
||||
return {
|
||||
value: s[0] ? s[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __values = this && this.u || function(e) {
|
||||
var t = typeof Symbol === "function" && Symbol.iterator, r = t && e[t], n = 0;
|
||||
if (r) return r.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(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
|
||||
import HashContainer from "./Base";
|
||||
|
||||
import Vector from "../SequentialContainer/Vector";
|
||||
|
||||
import OrderedSet from "../TreeContainer/OrderedSet";
|
||||
|
||||
var HashSet = function(e) {
|
||||
__extends(HashSet, e);
|
||||
function HashSet(t, r, n) {
|
||||
if (t === void 0) {
|
||||
t = [];
|
||||
}
|
||||
var i = e.call(this, r, n) || this;
|
||||
i.h = [];
|
||||
t.forEach((function(e) {
|
||||
return i.insert(e);
|
||||
}));
|
||||
return i;
|
||||
}
|
||||
HashSet.prototype.v = function() {
|
||||
var e = this;
|
||||
if (this.l >= 1073741824) return;
|
||||
var t = [];
|
||||
var r = this.l;
|
||||
this.l <<= 1;
|
||||
var n = Object.keys(this.h);
|
||||
var i = n.length;
|
||||
var _loop_1 = function(i) {
|
||||
var s = parseInt(n[i]);
|
||||
var o = a.h[s];
|
||||
var f = o.size();
|
||||
if (f === 0) return "continue";
|
||||
if (f === 1) {
|
||||
var u = o.front();
|
||||
t[a.p(u) & a.l - 1] = new Vector([ u ], false);
|
||||
return "continue";
|
||||
}
|
||||
var c = [];
|
||||
var h = [];
|
||||
o.forEach((function(t) {
|
||||
var n = e.p(t);
|
||||
if ((n & r) === 0) {
|
||||
c.push(t);
|
||||
} else h.push(t);
|
||||
}));
|
||||
if (o instanceof OrderedSet) {
|
||||
if (c.length > 6) {
|
||||
t[s] = new OrderedSet(c);
|
||||
} else {
|
||||
t[s] = new Vector(c, false);
|
||||
}
|
||||
if (h.length > 6) {
|
||||
t[s + r] = new OrderedSet(h);
|
||||
} else {
|
||||
t[s + r] = new Vector(h, false);
|
||||
}
|
||||
} else {
|
||||
t[s] = new Vector(c, false);
|
||||
t[s + r] = new Vector(h, false);
|
||||
}
|
||||
};
|
||||
var a = this;
|
||||
for (var s = 0; s < i; ++s) {
|
||||
_loop_1(s);
|
||||
}
|
||||
this.h = t;
|
||||
};
|
||||
HashSet.prototype.forEach = function(e) {
|
||||
var t = Object.values(this.h);
|
||||
var r = t.length;
|
||||
var n = 0;
|
||||
for (var i = 0; i < r; ++i) {
|
||||
t[i].forEach((function(t) {
|
||||
return e(t, n++);
|
||||
}));
|
||||
}
|
||||
};
|
||||
HashSet.prototype.insert = function(e) {
|
||||
var t = this.p(e) & this.l - 1;
|
||||
var r = this.h[t];
|
||||
if (!r) {
|
||||
this.h[t] = new Vector([ e ], false);
|
||||
this.o += 1;
|
||||
} else {
|
||||
var n = r.size();
|
||||
if (r instanceof Vector) {
|
||||
if (!r.find(e).equals(r.end())) return;
|
||||
r.pushBack(e);
|
||||
if (n + 1 >= 8) {
|
||||
if (this.l <= 64) {
|
||||
this.o += 1;
|
||||
this.v();
|
||||
return;
|
||||
}
|
||||
this.h[t] = new OrderedSet(r);
|
||||
}
|
||||
this.o += 1;
|
||||
} else {
|
||||
r.insert(e);
|
||||
var i = r.size();
|
||||
this.o += i - n;
|
||||
}
|
||||
}
|
||||
if (this.o > this.l * .75) {
|
||||
this.v();
|
||||
}
|
||||
};
|
||||
HashSet.prototype.eraseElementByKey = function(e) {
|
||||
var t = this.p(e) & this.l - 1;
|
||||
var r = this.h[t];
|
||||
if (!r) return;
|
||||
var n = r.size();
|
||||
if (n === 0) return;
|
||||
if (r instanceof Vector) {
|
||||
r.eraseElementByValue(e);
|
||||
var i = r.size();
|
||||
this.o += i - n;
|
||||
} else {
|
||||
r.eraseElementByKey(e);
|
||||
var i = r.size();
|
||||
this.o += i - n;
|
||||
if (i <= 6) {
|
||||
this.h[t] = new Vector(r);
|
||||
}
|
||||
}
|
||||
};
|
||||
HashSet.prototype.find = function(e) {
|
||||
var t = this.p(e) & this.l - 1;
|
||||
var r = this.h[t];
|
||||
if (!r) return false;
|
||||
return !r.find(e).equals(r.end());
|
||||
};
|
||||
HashSet.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var e, t, r, n, i, a, s, o;
|
||||
var f, u;
|
||||
return __generator(this, (function(c) {
|
||||
switch (c.label) {
|
||||
case 0:
|
||||
e = Object.values(this.h);
|
||||
t = e.length;
|
||||
r = 0;
|
||||
c.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(r < t)) return [ 3, 10 ];
|
||||
n = e[r];
|
||||
c.label = 2;
|
||||
|
||||
case 2:
|
||||
c.trys.push([ 2, 7, 8, 9 ]);
|
||||
i = (f = void 0, __values(n)), a = i.next();
|
||||
c.label = 3;
|
||||
|
||||
case 3:
|
||||
if (!!a.done) return [ 3, 6 ];
|
||||
s = a.value;
|
||||
return [ 4, s ];
|
||||
|
||||
case 4:
|
||||
c.sent();
|
||||
c.label = 5;
|
||||
|
||||
case 5:
|
||||
a = i.next();
|
||||
return [ 3, 3 ];
|
||||
|
||||
case 6:
|
||||
return [ 3, 9 ];
|
||||
|
||||
case 7:
|
||||
o = c.sent();
|
||||
f = {
|
||||
error: o
|
||||
};
|
||||
return [ 3, 9 ];
|
||||
|
||||
case 8:
|
||||
try {
|
||||
if (a && !a.done && (u = i.return)) u.call(i);
|
||||
} finally {
|
||||
if (f) throw f.error;
|
||||
}
|
||||
return [ 7 ];
|
||||
|
||||
case 9:
|
||||
++r;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 10:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return HashSet;
|
||||
}(HashContainer);
|
||||
|
||||
export default HashSet;
|
||||
48
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.d.ts
generated
vendored
Normal file
48
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Base, initContainer } from "../ContainerBase";
|
||||
declare class PriorityQueue<T> extends Base {
|
||||
/**
|
||||
* @description PriorityQueue's constructor.
|
||||
* @param container Initialize container, must have a forEach 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);
|
||||
clear(): void;
|
||||
/**
|
||||
* @description Push element into a container in order.
|
||||
* @param item The element you want to push.
|
||||
*/
|
||||
push(item: T): void;
|
||||
/**
|
||||
* @description Removes the top element.
|
||||
*/
|
||||
pop(): void;
|
||||
/**
|
||||
* @description Accesses 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;
|
||||
167
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.js
generated
vendored
Normal file
167
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.js
generated
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(i, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} 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(i, t);
|
||||
};
|
||||
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 = i;
|
||||
}
|
||||
i.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
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 ((t === void 0 || t-- > 0) && !(n = e.next()).done) u.push(n.value);
|
||||
} catch (i) {
|
||||
s = {
|
||||
error: i
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (n && !n.done && (r = e["return"])) r.call(e);
|
||||
} finally {
|
||||
if (s) throw s.error;
|
||||
}
|
||||
}
|
||||
return u;
|
||||
};
|
||||
|
||||
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 i.concat(u || Array.prototype.slice.call(t));
|
||||
};
|
||||
|
||||
import { Base } from "../ContainerBase";
|
||||
|
||||
var PriorityQueue = function(i) {
|
||||
__extends(PriorityQueue, i);
|
||||
function PriorityQueue(t, r, e) {
|
||||
if (t === void 0) {
|
||||
t = [];
|
||||
}
|
||||
if (r === void 0) {
|
||||
r = function(i, t) {
|
||||
if (i > t) return -1;
|
||||
if (i < t) return 1;
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
if (e === void 0) {
|
||||
e = true;
|
||||
}
|
||||
var n = i.call(this) || this;
|
||||
n.A = r;
|
||||
if (Array.isArray(t)) {
|
||||
n.m = e ? __spreadArray([], __read(t), false) : t;
|
||||
} else {
|
||||
n.m = [];
|
||||
t.forEach((function(i) {
|
||||
return n.m.push(i);
|
||||
}));
|
||||
}
|
||||
n.o = n.m.length;
|
||||
var u = n.o >> 1;
|
||||
for (var s = n.o - 1 >> 1; s >= 0; --s) {
|
||||
n.j(s, u);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
PriorityQueue.prototype.B = function(i) {
|
||||
var t = this.m[i];
|
||||
while (i > 0) {
|
||||
var r = i - 1 >> 1;
|
||||
var e = this.m[r];
|
||||
if (this.A(e, t) <= 0) break;
|
||||
this.m[i] = e;
|
||||
i = r;
|
||||
}
|
||||
this.m[i] = t;
|
||||
};
|
||||
PriorityQueue.prototype.j = function(i, t) {
|
||||
var r = this.m[i];
|
||||
while (i < t) {
|
||||
var e = i << 1 | 1;
|
||||
var n = e + 1;
|
||||
var u = this.m[e];
|
||||
if (n < this.o && this.A(u, this.m[n]) > 0) {
|
||||
e = n;
|
||||
u = this.m[n];
|
||||
}
|
||||
if (this.A(u, r) >= 0) break;
|
||||
this.m[i] = u;
|
||||
i = e;
|
||||
}
|
||||
this.m[i] = r;
|
||||
};
|
||||
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;
|
||||
}(Base);
|
||||
|
||||
export default PriorityQueue;
|
||||
18
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.d.ts
generated
vendored
Normal file
18
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Base, initContainer } from "../ContainerBase";
|
||||
declare class Queue<T> extends Base {
|
||||
constructor(container?: initContainer<T>);
|
||||
clear(): void;
|
||||
/**
|
||||
* @description Inserts element to queue's end.
|
||||
*/
|
||||
push(element: T): void;
|
||||
/**
|
||||
* @description Removes the first element.
|
||||
*/
|
||||
pop(): void;
|
||||
/**
|
||||
* @description Access the first element.
|
||||
*/
|
||||
front(): T | undefined;
|
||||
}
|
||||
export default Queue;
|
||||
55
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.js
generated
vendored
Normal file
55
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(e, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(e, t) {
|
||||
e.__proto__ = t;
|
||||
} || function(e, t) {
|
||||
for (var n in t) if (Object.prototype.hasOwnProperty.call(t, n)) e[n] = t[n];
|
||||
};
|
||||
return extendStatics(e, t);
|
||||
};
|
||||
return function(e, t) {
|
||||
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
||||
extendStatics(e, t);
|
||||
function __() {
|
||||
this.constructor = e;
|
||||
}
|
||||
e.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
import Deque from "../SequentialContainer/Deque";
|
||||
|
||||
import { Base } from "../ContainerBase";
|
||||
|
||||
var Queue = function(e) {
|
||||
__extends(Queue, e);
|
||||
function Queue(t) {
|
||||
if (t === void 0) {
|
||||
t = [];
|
||||
}
|
||||
var n = e.call(this) || this;
|
||||
n.q = new Deque(t);
|
||||
n.o = n.q.size();
|
||||
return n;
|
||||
}
|
||||
Queue.prototype.clear = function() {
|
||||
this.q.clear();
|
||||
this.o = 0;
|
||||
};
|
||||
Queue.prototype.push = function(e) {
|
||||
this.q.pushBack(e);
|
||||
this.o += 1;
|
||||
};
|
||||
Queue.prototype.pop = function() {
|
||||
this.q.popFront();
|
||||
if (this.o) this.o -= 1;
|
||||
};
|
||||
Queue.prototype.front = function() {
|
||||
return this.q.front();
|
||||
};
|
||||
return Queue;
|
||||
}(Base);
|
||||
|
||||
export default Queue;
|
||||
18
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.d.ts
generated
vendored
Normal file
18
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Base, initContainer } from "../ContainerBase";
|
||||
declare class Stack<T> extends Base {
|
||||
constructor(container?: initContainer<T>);
|
||||
clear(): void;
|
||||
/**
|
||||
* @description Insert element to stack's end.
|
||||
*/
|
||||
push(element: T): void;
|
||||
/**
|
||||
* @description Removes the end element.
|
||||
*/
|
||||
pop(): void;
|
||||
/**
|
||||
* @description Accesses the end element.
|
||||
*/
|
||||
top(): T | undefined;
|
||||
}
|
||||
export default Stack;
|
||||
55
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js
generated
vendored
Normal file
55
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(t, n) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(t, n) {
|
||||
t.__proto__ = n;
|
||||
} || function(t, n) {
|
||||
for (var i in n) if (Object.prototype.hasOwnProperty.call(n, i)) t[i] = n[i];
|
||||
};
|
||||
return extendStatics(t, n);
|
||||
};
|
||||
return function(t, n) {
|
||||
if (typeof n !== "function" && n !== null) throw new TypeError("Class extends value " + String(n) + " is not a constructor or null");
|
||||
extendStatics(t, n);
|
||||
function __() {
|
||||
this.constructor = t;
|
||||
}
|
||||
t.prototype = n === null ? Object.create(n) : (__.prototype = n.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { Base } from "../ContainerBase";
|
||||
|
||||
var Stack = function(t) {
|
||||
__extends(Stack, t);
|
||||
function Stack(n) {
|
||||
if (n === void 0) {
|
||||
n = [];
|
||||
}
|
||||
var i = t.call(this) || this;
|
||||
i.S = [];
|
||||
n.forEach((function(t) {
|
||||
return i.push(t);
|
||||
}));
|
||||
return i;
|
||||
}
|
||||
Stack.prototype.clear = function() {
|
||||
this.o = 0;
|
||||
this.S.length = 0;
|
||||
};
|
||||
Stack.prototype.push = function(t) {
|
||||
this.S.push(t);
|
||||
this.o += 1;
|
||||
};
|
||||
Stack.prototype.pop = function() {
|
||||
this.S.pop();
|
||||
if (this.o > 0) this.o -= 1;
|
||||
};
|
||||
Stack.prototype.top = function() {
|
||||
return this.S[this.o - 1];
|
||||
};
|
||||
return Stack;
|
||||
}(Base);
|
||||
|
||||
export default Stack;
|
||||
8
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.d.ts
generated
vendored
Normal file
8
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
export declare abstract class RandomIterator<T> extends ContainerIterator<T> {
|
||||
pre: () => this;
|
||||
next: () => this;
|
||||
get pointer(): T;
|
||||
set pointer(newValue: T);
|
||||
equals(obj: RandomIterator<T>): boolean;
|
||||
}
|
||||
87
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js
generated
vendored
Normal file
87
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
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 n in r) if (Object.prototype.hasOwnProperty.call(r, n)) t[n] = r[n];
|
||||
};
|
||||
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 RandomIterator = function(t) {
|
||||
__extends(RandomIterator, t);
|
||||
function RandomIterator(r, n, e, i, o) {
|
||||
var a = t.call(this, o) || this;
|
||||
a.D = r;
|
||||
a.I = n;
|
||||
a.g = e;
|
||||
a.R = i;
|
||||
if (a.iteratorType === 0) {
|
||||
a.pre = function() {
|
||||
if (this.D === 0) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.D -= 1;
|
||||
return this;
|
||||
};
|
||||
a.next = function() {
|
||||
if (this.D === this.I()) {
|
||||
throw new RangeError("Random Iterator access denied!");
|
||||
}
|
||||
this.D += 1;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
a.pre = function() {
|
||||
if (this.D === this.I() - 1) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.D += 1;
|
||||
return this;
|
||||
};
|
||||
a.next = function() {
|
||||
if (this.D === -1) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.D -= 1;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return a;
|
||||
}
|
||||
Object.defineProperty(RandomIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.D < 0 || this.D > this.I() - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
return this.g(this.D);
|
||||
},
|
||||
set: function(t) {
|
||||
if (this.D < 0 || this.D > this.I() - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.R(this.D, t);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
RandomIterator.prototype.equals = function(t) {
|
||||
return this.D === t.D;
|
||||
};
|
||||
return RandomIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
export { RandomIterator };
|
||||
44
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.d.ts
generated
vendored
Normal file
44
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Container } from "../../ContainerBase";
|
||||
declare abstract class SequentialContainer<T> extends Container<T> {
|
||||
/**
|
||||
* @description Push the element to the back.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
abstract pushBack(element: T): void;
|
||||
/**
|
||||
* @description Removes the last element.
|
||||
*/
|
||||
abstract popBack(): void;
|
||||
/**
|
||||
* @description Sets element by position.
|
||||
* @param pos The position you want to change.
|
||||
* @param element The element's value you want to update.
|
||||
*/
|
||||
abstract setElementByPos(pos: number, element: T): void;
|
||||
/**
|
||||
* @description Removes the elements of the specified value.
|
||||
* @param value The value you want to remove.
|
||||
*/
|
||||
abstract eraseElementByValue(value: T): void;
|
||||
/**
|
||||
* @description Insert several elements after the specified position.
|
||||
* @param pos The position you want to insert.
|
||||
* @param element The element you want to insert.
|
||||
* @param num The number of elements you want to insert (default 1).
|
||||
*/
|
||||
abstract insert(pos: number, element: T, num?: number): void;
|
||||
/**
|
||||
* @description Reverses the container.
|
||||
*/
|
||||
abstract reverse(): void;
|
||||
/**
|
||||
* @description Removes the duplication of elements in the container.
|
||||
*/
|
||||
abstract unique(): void;
|
||||
/**
|
||||
* @description Sort the container.
|
||||
* @param cmp Comparison function.
|
||||
*/
|
||||
abstract sort(cmp?: (x: T, y: T) => number): void;
|
||||
}
|
||||
export default SequentialContainer;
|
||||
32
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js
generated
vendored
Normal file
32
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(n, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(n, t) {
|
||||
n.__proto__ = t;
|
||||
} || function(n, t) {
|
||||
for (var e in t) if (Object.prototype.hasOwnProperty.call(t, e)) n[e] = t[e];
|
||||
};
|
||||
return extendStatics(n, t);
|
||||
};
|
||||
return function(n, t) {
|
||||
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
||||
extendStatics(n, t);
|
||||
function __() {
|
||||
this.constructor = n;
|
||||
}
|
||||
n.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { Container } from "../../ContainerBase";
|
||||
|
||||
var SequentialContainer = function(n) {
|
||||
__extends(SequentialContainer, n);
|
||||
function SequentialContainer() {
|
||||
return n !== null && n.apply(this, arguments) || this;
|
||||
}
|
||||
return SequentialContainer;
|
||||
}(Container);
|
||||
|
||||
export default SequentialContainer;
|
||||
50
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.d.ts
generated
vendored
Normal file
50
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.d.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
export declare class DequeIterator<T> extends RandomIterator<T> {
|
||||
copy(): DequeIterator<T>;
|
||||
}
|
||||
declare class Deque<T> extends SequentialContainer<T> {
|
||||
constructor(container?: initContainer<T>, _bucketSize?: number);
|
||||
clear(): void;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
begin(): DequeIterator<T>;
|
||||
end(): DequeIterator<T>;
|
||||
rBegin(): DequeIterator<T>;
|
||||
rEnd(): DequeIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
/**
|
||||
* @description Push the element to the front.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
pushFront(element: T): void;
|
||||
/**
|
||||
* @description Remove the _first element.
|
||||
*/
|
||||
popFront(): void;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
/**
|
||||
* @description Remove all elements after the specified position (excluding the specified position).
|
||||
* @param pos The previous position of the _first removed element.
|
||||
* @example deque.cut(1); // Then deque's size will be 2. deque -> [0, 1]
|
||||
*/
|
||||
cut(pos: number): void;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(value: T): void;
|
||||
eraseElementByIterator(iter: DequeIterator<T>): DequeIterator<T>;
|
||||
find(element: T): DequeIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
/**
|
||||
* @description Remove as much useless space as possible.
|
||||
*/
|
||||
shrinkToFit(): void;
|
||||
[Symbol.iterator](): Generator<T, void, unknown>;
|
||||
}
|
||||
export default Deque;
|
||||
493
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js
generated
vendored
Normal file
493
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js
generated
vendored
Normal file
@@ -0,0 +1,493 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(t, i) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(t, i) {
|
||||
t.__proto__ = i;
|
||||
} || function(t, i) {
|
||||
for (var e in i) if (Object.prototype.hasOwnProperty.call(i, e)) t[e] = i[e];
|
||||
};
|
||||
return extendStatics(t, i);
|
||||
};
|
||||
return function(t, i) {
|
||||
if (typeof i !== "function" && i !== null) throw new TypeError("Class extends value " + String(i) + " is not a constructor or null");
|
||||
extendStatics(t, i);
|
||||
function __() {
|
||||
this.constructor = t;
|
||||
}
|
||||
t.prototype = i === null ? Object.create(i) : (__.prototype = i.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(t, i) {
|
||||
var e = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (h[0] & 1) throw h[1];
|
||||
return h[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, r, s, h, n;
|
||||
return n = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (n[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), n;
|
||||
function verb(t) {
|
||||
return function(i) {
|
||||
return step([ t, i ]);
|
||||
};
|
||||
}
|
||||
function step(n) {
|
||||
if (r) throw new TypeError("Generator is already executing.");
|
||||
while (e) try {
|
||||
if (r = 1, s && (h = n[0] & 2 ? s["return"] : n[0] ? s["throw"] || ((h = s["return"]) && h.call(s),
|
||||
0) : s.next) && !(h = h.call(s, n[1])).done) return h;
|
||||
if (s = 0, h) n = [ n[0] & 2, h.value ];
|
||||
switch (n[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
h = n;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
e.label++;
|
||||
return {
|
||||
value: n[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
e.label++;
|
||||
s = n[1];
|
||||
n = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
n = e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(h = e.trys, h = h.length > 0 && h[h.length - 1]) && (n[0] === 6 || n[0] === 2)) {
|
||||
e = 0;
|
||||
continue;
|
||||
}
|
||||
if (n[0] === 3 && (!h || n[1] > h[0] && n[1] < h[3])) {
|
||||
e.label = n[1];
|
||||
break;
|
||||
}
|
||||
if (n[0] === 6 && e.label < h[1]) {
|
||||
e.label = h[1];
|
||||
h = n;
|
||||
break;
|
||||
}
|
||||
if (h && e.label < h[2]) {
|
||||
e.label = h[2];
|
||||
e.ops.push(n);
|
||||
break;
|
||||
}
|
||||
if (h[2]) e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
}
|
||||
n = i.call(t, e);
|
||||
} catch (t) {
|
||||
n = [ 6, t ];
|
||||
s = 0;
|
||||
} finally {
|
||||
r = h = 0;
|
||||
}
|
||||
if (n[0] & 5) throw n[1];
|
||||
return {
|
||||
value: n[0] ? n[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __read = this && this._ || function(t, i) {
|
||||
var e = typeof Symbol === "function" && t[Symbol.iterator];
|
||||
if (!e) return t;
|
||||
var r = e.call(t), s, h = [], n;
|
||||
try {
|
||||
while ((i === void 0 || i-- > 0) && !(s = r.next()).done) h.push(s.value);
|
||||
} catch (t) {
|
||||
n = {
|
||||
error: t
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (s && !s.done && (e = r["return"])) e.call(r);
|
||||
} finally {
|
||||
if (n) throw n.error;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
};
|
||||
|
||||
var __spreadArray = this && this.P || function(t, i, e) {
|
||||
if (e || arguments.length === 2) for (var r = 0, s = i.length, h; r < s; r++) {
|
||||
if (h || !(r in i)) {
|
||||
if (!h) h = Array.prototype.slice.call(i, 0, r);
|
||||
h[r] = i[r];
|
||||
}
|
||||
}
|
||||
return t.concat(h || Array.prototype.slice.call(i));
|
||||
};
|
||||
|
||||
import SequentialContainer from "./Base";
|
||||
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
|
||||
var DequeIterator = function(t) {
|
||||
__extends(DequeIterator, t);
|
||||
function DequeIterator() {
|
||||
return t !== null && t.apply(this, arguments) || this;
|
||||
}
|
||||
DequeIterator.prototype.copy = function() {
|
||||
return new DequeIterator(this.D, this.I, this.g, this.R, this.iteratorType);
|
||||
};
|
||||
return DequeIterator;
|
||||
}(RandomIterator);
|
||||
|
||||
export { DequeIterator };
|
||||
|
||||
var Deque = function(t) {
|
||||
__extends(Deque, t);
|
||||
function Deque(i, e) {
|
||||
if (i === void 0) {
|
||||
i = [];
|
||||
}
|
||||
if (e === void 0) {
|
||||
e = 1 << 12;
|
||||
}
|
||||
var r = t.call(this) || this;
|
||||
r.M = 0;
|
||||
r.k = 0;
|
||||
r.C = 0;
|
||||
r.O = 0;
|
||||
r.l = 0;
|
||||
r.N = [];
|
||||
var s;
|
||||
if ("size" in i) {
|
||||
if (typeof i.size === "number") {
|
||||
s = i.size;
|
||||
} else {
|
||||
s = i.size();
|
||||
}
|
||||
} else if ("length" in i) {
|
||||
s = i.length;
|
||||
} else {
|
||||
throw new RangeError("Can't get container's size!");
|
||||
}
|
||||
r.T = e;
|
||||
r.l = Math.max(Math.ceil(s / r.T), 1);
|
||||
for (var h = 0; h < r.l; ++h) {
|
||||
r.N.push(new Array(r.T));
|
||||
}
|
||||
var n = Math.ceil(s / r.T);
|
||||
r.M = r.C = (r.l >> 1) - (n >> 1);
|
||||
r.k = r.O = r.T - s % r.T >> 1;
|
||||
i.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);
|
||||
return r;
|
||||
}
|
||||
Deque.prototype.v = function() {
|
||||
var t = [];
|
||||
var i = Math.max(this.l >> 1, 1);
|
||||
for (var e = 0; e < i; ++e) {
|
||||
t[e] = new Array(this.T);
|
||||
}
|
||||
for (var e = this.M; e < this.l; ++e) {
|
||||
t[t.length] = this.N[e];
|
||||
}
|
||||
for (var e = 0; e < this.C; ++e) {
|
||||
t[t.length] = this.N[e];
|
||||
}
|
||||
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.T);
|
||||
}
|
||||
this.N = t;
|
||||
this.l = t.length;
|
||||
};
|
||||
Deque.prototype.G = function(t) {
|
||||
var i = this.k + t + 1;
|
||||
var e = i % this.T;
|
||||
var r = e - 1;
|
||||
var s = this.M + (i - e) / this.T;
|
||||
if (e === 0) s -= 1;
|
||||
s %= this.l;
|
||||
if (r < 0) r += this.T;
|
||||
return {
|
||||
curNodeBucketIndex: s,
|
||||
curNodePointerIndex: r
|
||||
};
|
||||
};
|
||||
Deque.prototype.clear = function() {
|
||||
this.N = [ [] ];
|
||||
this.l = 1;
|
||||
this.M = this.C = this.o = 0;
|
||||
this.k = this.O = this.T >> 1;
|
||||
};
|
||||
Deque.prototype.front = function() {
|
||||
return this.N[this.M][this.k];
|
||||
};
|
||||
Deque.prototype.back = function() {
|
||||
return this.N[this.C][this.O];
|
||||
};
|
||||
Deque.prototype.begin = function() {
|
||||
return new DequeIterator(0, this.size, this.getElementByPos, this.setElementByPos);
|
||||
};
|
||||
Deque.prototype.end = function() {
|
||||
return new DequeIterator(this.o, this.size, this.getElementByPos, this.setElementByPos);
|
||||
};
|
||||
Deque.prototype.rBegin = function() {
|
||||
return new DequeIterator(this.o - 1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
};
|
||||
Deque.prototype.rEnd = function() {
|
||||
return new DequeIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
};
|
||||
Deque.prototype.pushBack = function(t) {
|
||||
if (this.o) {
|
||||
if (this.O < this.T - 1) {
|
||||
this.O += 1;
|
||||
} else if (this.C < this.l - 1) {
|
||||
this.C += 1;
|
||||
this.O = 0;
|
||||
} else {
|
||||
this.C = 0;
|
||||
this.O = 0;
|
||||
}
|
||||
if (this.C === this.M && this.O === this.k) this.v();
|
||||
}
|
||||
this.o += 1;
|
||||
this.N[this.C][this.O] = t;
|
||||
};
|
||||
Deque.prototype.popBack = function() {
|
||||
if (!this.o) return;
|
||||
this.N[this.C][this.O] = undefined;
|
||||
if (this.o !== 1) {
|
||||
if (this.O > 0) {
|
||||
this.O -= 1;
|
||||
} else if (this.C > 0) {
|
||||
this.C -= 1;
|
||||
this.O = this.T - 1;
|
||||
} else {
|
||||
this.C = this.l - 1;
|
||||
this.O = this.T - 1;
|
||||
}
|
||||
}
|
||||
this.o -= 1;
|
||||
};
|
||||
Deque.prototype.pushFront = function(t) {
|
||||
if (this.o) {
|
||||
if (this.k > 0) {
|
||||
this.k -= 1;
|
||||
} else if (this.M > 0) {
|
||||
this.M -= 1;
|
||||
this.k = this.T - 1;
|
||||
} else {
|
||||
this.M = this.l - 1;
|
||||
this.k = this.T - 1;
|
||||
}
|
||||
if (this.M === this.C && this.k === this.O) this.v();
|
||||
}
|
||||
this.o += 1;
|
||||
this.N[this.M][this.k] = t;
|
||||
};
|
||||
Deque.prototype.popFront = function() {
|
||||
if (!this.o) return;
|
||||
this.N[this.M][this.k] = undefined;
|
||||
if (this.o !== 1) {
|
||||
if (this.k < this.T - 1) {
|
||||
this.k += 1;
|
||||
} else if (this.M < this.l - 1) {
|
||||
this.M += 1;
|
||||
this.k = 0;
|
||||
} else {
|
||||
this.M = 0;
|
||||
this.k = 0;
|
||||
}
|
||||
}
|
||||
this.o -= 1;
|
||||
};
|
||||
Deque.prototype.forEach = function(t) {
|
||||
for (var i = 0; i < this.o; ++i) {
|
||||
t(this.getElementByPos(i), i);
|
||||
}
|
||||
};
|
||||
Deque.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var i = this.G(t), e = i.curNodeBucketIndex, r = i.curNodePointerIndex;
|
||||
return this.N[e][r];
|
||||
};
|
||||
Deque.prototype.setElementByPos = function(t, i) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var e = this.G(t), r = e.curNodeBucketIndex, s = e.curNodePointerIndex;
|
||||
this.N[r][s] = i;
|
||||
};
|
||||
Deque.prototype.insert = function(t, i, e) {
|
||||
if (e === void 0) {
|
||||
e = 1;
|
||||
}
|
||||
if (t < 0 || t > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) {
|
||||
while (e--) this.pushFront(i);
|
||||
} else if (t === this.o) {
|
||||
while (e--) this.pushBack(i);
|
||||
} else {
|
||||
var r = [];
|
||||
for (var s = t; s < this.o; ++s) {
|
||||
r.push(this.getElementByPos(s));
|
||||
}
|
||||
this.cut(t - 1);
|
||||
for (var s = 0; s < e; ++s) this.pushBack(i);
|
||||
for (var s = 0; s < r.length; ++s) this.pushBack(r[s]);
|
||||
}
|
||||
};
|
||||
Deque.prototype.cut = function(t) {
|
||||
if (t < 0) {
|
||||
this.clear();
|
||||
return;
|
||||
}
|
||||
var i = this.G(t), e = i.curNodeBucketIndex, r = i.curNodePointerIndex;
|
||||
this.C = e;
|
||||
this.O = r;
|
||||
this.o = t + 1;
|
||||
};
|
||||
Deque.prototype.eraseElementByPos = function(t) {
|
||||
var i = this;
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) this.popFront(); else if (t === this.o - 1) this.popBack(); else {
|
||||
var e = [];
|
||||
for (var r = t + 1; r < this.o; ++r) {
|
||||
e.push(this.getElementByPos(r));
|
||||
}
|
||||
this.cut(t);
|
||||
this.popBack();
|
||||
e.forEach((function(t) {
|
||||
return i.pushBack(t);
|
||||
}));
|
||||
}
|
||||
};
|
||||
Deque.prototype.eraseElementByValue = function(t) {
|
||||
if (!this.o) return;
|
||||
var i = [];
|
||||
for (var e = 0; e < this.o; ++e) {
|
||||
var r = this.getElementByPos(e);
|
||||
if (r !== t) i.push(r);
|
||||
}
|
||||
var s = i.length;
|
||||
for (var e = 0; e < s; ++e) this.setElementByPos(e, i[e]);
|
||||
this.cut(s - 1);
|
||||
};
|
||||
Deque.prototype.eraseElementByIterator = function(t) {
|
||||
var i = t.D;
|
||||
this.eraseElementByPos(i);
|
||||
t = t.next();
|
||||
return t;
|
||||
};
|
||||
Deque.prototype.find = function(t) {
|
||||
for (var i = 0; i < this.o; ++i) {
|
||||
if (this.getElementByPos(i) === t) {
|
||||
return new DequeIterator(i, this.size, this.getElementByPos, this.setElementByPos);
|
||||
}
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
Deque.prototype.reverse = function() {
|
||||
var t = 0;
|
||||
var i = this.o - 1;
|
||||
while (t < i) {
|
||||
var e = this.getElementByPos(t);
|
||||
this.setElementByPos(t, this.getElementByPos(i));
|
||||
this.setElementByPos(i, e);
|
||||
t += 1;
|
||||
i -= 1;
|
||||
}
|
||||
};
|
||||
Deque.prototype.unique = function() {
|
||||
if (this.o <= 1) return;
|
||||
var t = 1;
|
||||
var i = this.getElementByPos(0);
|
||||
for (var e = 1; e < this.o; ++e) {
|
||||
var r = this.getElementByPos(e);
|
||||
if (r !== i) {
|
||||
i = r;
|
||||
this.setElementByPos(t++, r);
|
||||
}
|
||||
}
|
||||
while (this.o > t) this.popBack();
|
||||
};
|
||||
Deque.prototype.sort = function(t) {
|
||||
var i = [];
|
||||
for (var e = 0; e < this.o; ++e) {
|
||||
i.push(this.getElementByPos(e));
|
||||
}
|
||||
i.sort(t);
|
||||
for (var e = 0; e < this.o; ++e) this.setElementByPos(e, i[e]);
|
||||
};
|
||||
Deque.prototype.shrinkToFit = function() {
|
||||
if (!this.o) return;
|
||||
var t = [];
|
||||
this.forEach((function(i) {
|
||||
return t.push(i);
|
||||
}));
|
||||
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.N.push(new Array(this.T));
|
||||
}
|
||||
for (var i = 0; i < t.length; ++i) this.pushBack(t[i]);
|
||||
};
|
||||
Deque.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var t;
|
||||
return __generator(this, (function(i) {
|
||||
switch (i.label) {
|
||||
case 0:
|
||||
t = 0;
|
||||
i.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(t < this.o)) return [ 3, 4 ];
|
||||
return [ 4, this.getElementByPos(t) ];
|
||||
|
||||
case 2:
|
||||
i.sent();
|
||||
i.label = 3;
|
||||
|
||||
case 3:
|
||||
++t;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 4:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return Deque;
|
||||
}(SequentialContainer);
|
||||
|
||||
export default Deque;
|
||||
49
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.d.ts
generated
vendored
Normal file
49
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.d.ts
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { ContainerIterator, initContainer } from "../ContainerBase";
|
||||
export declare class LinkListIterator<T> extends ContainerIterator<T> {
|
||||
pre: () => this;
|
||||
next: () => this;
|
||||
get pointer(): T;
|
||||
set pointer(newValue: T);
|
||||
equals(obj: LinkListIterator<T>): boolean;
|
||||
copy(): LinkListIterator<T>;
|
||||
}
|
||||
declare class LinkList<T> extends SequentialContainer<T> {
|
||||
constructor(container?: initContainer<T>);
|
||||
clear(): void;
|
||||
begin(): LinkListIterator<T>;
|
||||
end(): LinkListIterator<T>;
|
||||
rBegin(): LinkListIterator<T>;
|
||||
rEnd(): LinkListIterator<T>;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(_value: T): void;
|
||||
eraseElementByIterator(iter: LinkListIterator<T>): LinkListIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
find(element: T): LinkListIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
/**
|
||||
* @description Push an element to the front.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
pushFront(element: T): void;
|
||||
/**
|
||||
* @description Removes the first element.
|
||||
*/
|
||||
popFront(): void;
|
||||
/**
|
||||
* @description Merges two sorted lists.
|
||||
* @param list The other list you want to merge (must be sorted).
|
||||
*/
|
||||
merge(list: LinkList<T>): void;
|
||||
[Symbol.iterator](): Generator<T, void, unknown>;
|
||||
}
|
||||
export default LinkList;
|
||||
500
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js
generated
vendored
Normal file
500
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js
generated
vendored
Normal file
@@ -0,0 +1,500 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(i, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(i, t) {
|
||||
i.__proto__ = t;
|
||||
} || function(i, t) {
|
||||
for (var n in t) if (Object.prototype.hasOwnProperty.call(t, n)) i[n] = t[n];
|
||||
};
|
||||
return extendStatics(i, t);
|
||||
};
|
||||
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 = i;
|
||||
}
|
||||
i.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(i, t) {
|
||||
var n = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (s[0] & 1) throw s[1];
|
||||
return s[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, r, e, s, h;
|
||||
return h = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (h[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), h;
|
||||
function verb(i) {
|
||||
return function(t) {
|
||||
return step([ i, t ]);
|
||||
};
|
||||
}
|
||||
function step(h) {
|
||||
if (r) throw new TypeError("Generator is already executing.");
|
||||
while (n) try {
|
||||
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]) {
|
||||
case 0:
|
||||
case 1:
|
||||
s = h;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
n.label++;
|
||||
return {
|
||||
value: h[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
n.label++;
|
||||
e = h[1];
|
||||
h = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
h = n.ops.pop();
|
||||
n.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(s = n.trys, s = s.length > 0 && s[s.length - 1]) && (h[0] === 6 || h[0] === 2)) {
|
||||
n = 0;
|
||||
continue;
|
||||
}
|
||||
if (h[0] === 3 && (!s || h[1] > s[0] && h[1] < s[3])) {
|
||||
n.label = h[1];
|
||||
break;
|
||||
}
|
||||
if (h[0] === 6 && n.label < s[1]) {
|
||||
n.label = s[1];
|
||||
s = h;
|
||||
break;
|
||||
}
|
||||
if (s && n.label < s[2]) {
|
||||
n.label = s[2];
|
||||
n.ops.push(h);
|
||||
break;
|
||||
}
|
||||
if (s[2]) n.ops.pop();
|
||||
n.trys.pop();
|
||||
continue;
|
||||
}
|
||||
h = t.call(i, n);
|
||||
} catch (i) {
|
||||
h = [ 6, i ];
|
||||
e = 0;
|
||||
} finally {
|
||||
r = s = 0;
|
||||
}
|
||||
if (h[0] & 5) throw h[1];
|
||||
return {
|
||||
value: h[0] ? h[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
import SequentialContainer from "./Base";
|
||||
|
||||
import { ContainerIterator } from "../ContainerBase";
|
||||
|
||||
var LinkNode = function() {
|
||||
function LinkNode(i) {
|
||||
this.L = undefined;
|
||||
this.F = undefined;
|
||||
this.H = undefined;
|
||||
this.L = i;
|
||||
}
|
||||
return LinkNode;
|
||||
}();
|
||||
|
||||
export { LinkNode };
|
||||
|
||||
var LinkListIterator = function(i) {
|
||||
__extends(LinkListIterator, i);
|
||||
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.F;
|
||||
return this;
|
||||
};
|
||||
e.next = function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D = this.D.H;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
e.pre = function() {
|
||||
if (this.D.H === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D = this.D.H;
|
||||
return this;
|
||||
};
|
||||
e.next = function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D = this.D.F;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return e;
|
||||
}
|
||||
Object.defineProperty(LinkListIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
return this.D.L;
|
||||
},
|
||||
set: function(i) {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D.L = i;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
LinkListIterator.prototype.equals = function(i) {
|
||||
return this.D === i.D;
|
||||
};
|
||||
LinkListIterator.prototype.copy = function() {
|
||||
return new LinkListIterator(this.D, this.J, this.iteratorType);
|
||||
};
|
||||
return LinkListIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
export { LinkListIterator };
|
||||
|
||||
var LinkList = function(i) {
|
||||
__extends(LinkList, i);
|
||||
function LinkList(t) {
|
||||
if (t === void 0) {
|
||||
t = [];
|
||||
}
|
||||
var n = i.call(this) || this;
|
||||
n.J = new LinkNode;
|
||||
n.K = undefined;
|
||||
n.U = undefined;
|
||||
t.forEach((function(i) {
|
||||
return n.pushBack(i);
|
||||
}));
|
||||
return n;
|
||||
}
|
||||
LinkList.prototype.clear = function() {
|
||||
this.o = 0;
|
||||
this.K = this.U = undefined;
|
||||
this.J.F = this.J.H = undefined;
|
||||
};
|
||||
LinkList.prototype.begin = function() {
|
||||
return new LinkListIterator(this.K || this.J, this.J);
|
||||
};
|
||||
LinkList.prototype.end = function() {
|
||||
return new LinkListIterator(this.J, this.J);
|
||||
};
|
||||
LinkList.prototype.rBegin = function() {
|
||||
return new LinkListIterator(this.U || this.J, this.J, 1);
|
||||
};
|
||||
LinkList.prototype.rEnd = function() {
|
||||
return new LinkListIterator(this.J, this.J, 1);
|
||||
};
|
||||
LinkList.prototype.front = function() {
|
||||
return this.K ? this.K.L : undefined;
|
||||
};
|
||||
LinkList.prototype.back = function() {
|
||||
return this.U ? this.U.L : undefined;
|
||||
};
|
||||
LinkList.prototype.forEach = function(i) {
|
||||
if (!this.o) return;
|
||||
var t = this.K;
|
||||
var n = 0;
|
||||
while (t !== this.J) {
|
||||
i(t.L, n++);
|
||||
t = t.H;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.getElementByPos = function(i) {
|
||||
if (i < 0 || i > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var t = this.K;
|
||||
while (i--) {
|
||||
t = t.H;
|
||||
}
|
||||
return t.L;
|
||||
};
|
||||
LinkList.prototype.eraseElementByPos = function(i) {
|
||||
if (i < 0 || i > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (i === 0) this.popFront(); else if (i === this.o - 1) this.popBack(); else {
|
||||
var t = this.K;
|
||||
while (i--) {
|
||||
t = t.H;
|
||||
}
|
||||
t = t;
|
||||
var n = t.F;
|
||||
var r = t.H;
|
||||
r.F = n;
|
||||
n.H = r;
|
||||
this.o -= 1;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.eraseElementByValue = function(i) {
|
||||
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.H;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.eraseElementByIterator = function(i) {
|
||||
var t = i.D;
|
||||
if (t === this.J) {
|
||||
throw new RangeError("Invalid iterator");
|
||||
}
|
||||
i = i.next();
|
||||
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;
|
||||
}
|
||||
return i;
|
||||
};
|
||||
LinkList.prototype.pushBack = function(i) {
|
||||
this.o += 1;
|
||||
var t = new LinkNode(i);
|
||||
if (!this.U) {
|
||||
this.K = this.U = t;
|
||||
this.J.H = this.K;
|
||||
this.K.F = this.J;
|
||||
} else {
|
||||
this.U.H = t;
|
||||
t.F = this.U;
|
||||
this.U = t;
|
||||
}
|
||||
this.U.H = this.J;
|
||||
this.J.F = this.U;
|
||||
};
|
||||
LinkList.prototype.popBack = function() {
|
||||
if (!this.U) return;
|
||||
this.o -= 1;
|
||||
if (this.K === this.U) {
|
||||
this.K = this.U = undefined;
|
||||
this.J.H = undefined;
|
||||
} else {
|
||||
this.U = this.U.F;
|
||||
this.U.H = this.J;
|
||||
}
|
||||
this.J.F = this.U;
|
||||
};
|
||||
LinkList.prototype.setElementByPos = function(i, t) {
|
||||
if (i < 0 || i > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var n = this.K;
|
||||
while (i--) {
|
||||
n = n.H;
|
||||
}
|
||||
n.L = t;
|
||||
};
|
||||
LinkList.prototype.insert = function(i, t, n) {
|
||||
if (n === void 0) {
|
||||
n = 1;
|
||||
}
|
||||
if (i < 0 || i > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (n <= 0) return;
|
||||
if (i === 0) {
|
||||
while (n--) this.pushFront(t);
|
||||
} else if (i === this.o) {
|
||||
while (n--) this.pushBack(t);
|
||||
} else {
|
||||
var r = this.K;
|
||||
for (var e = 1; e < i; ++e) {
|
||||
r = r.H;
|
||||
}
|
||||
var s = r.H;
|
||||
this.o += n;
|
||||
while (n--) {
|
||||
r.H = new LinkNode(t);
|
||||
r.H.F = r;
|
||||
r = r.H;
|
||||
}
|
||||
r.H = s;
|
||||
s.F = r;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.find = function(i) {
|
||||
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.H;
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
LinkList.prototype.reverse = function() {
|
||||
if (this.o <= 1) return;
|
||||
var i = this.K;
|
||||
var t = this.U;
|
||||
var n = 0;
|
||||
while (n << 1 < this.o) {
|
||||
var r = i.L;
|
||||
i.L = t.L;
|
||||
t.L = r;
|
||||
i = i.H;
|
||||
t = t.F;
|
||||
n += 1;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.unique = function() {
|
||||
if (this.o <= 1) return;
|
||||
var i = this.K;
|
||||
while (i !== this.J) {
|
||||
var t = i;
|
||||
while (t.H && t.L === t.H.L) {
|
||||
t = t.H;
|
||||
this.o -= 1;
|
||||
}
|
||||
i.H = t.H;
|
||||
i.H.F = i;
|
||||
i = i.H;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.sort = function(i) {
|
||||
if (this.o <= 1) return;
|
||||
var t = [];
|
||||
this.forEach((function(i) {
|
||||
return t.push(i);
|
||||
}));
|
||||
t.sort(i);
|
||||
var n = this.K;
|
||||
t.forEach((function(i) {
|
||||
n.L = i;
|
||||
n = n.H;
|
||||
}));
|
||||
};
|
||||
LinkList.prototype.pushFront = function(i) {
|
||||
this.o += 1;
|
||||
var t = new LinkNode(i);
|
||||
if (!this.K) {
|
||||
this.K = this.U = t;
|
||||
this.U.H = this.J;
|
||||
this.J.F = this.U;
|
||||
} else {
|
||||
t.H = this.K;
|
||||
this.K.F = t;
|
||||
this.K = t;
|
||||
}
|
||||
this.J.H = this.K;
|
||||
this.K.F = this.J;
|
||||
};
|
||||
LinkList.prototype.popFront = function() {
|
||||
if (!this.K) return;
|
||||
this.o -= 1;
|
||||
if (this.K === this.U) {
|
||||
this.K = this.U = undefined;
|
||||
this.J.F = this.U;
|
||||
} else {
|
||||
this.K = this.K.H;
|
||||
this.K.F = this.J;
|
||||
}
|
||||
this.J.H = this.K;
|
||||
};
|
||||
LinkList.prototype.merge = function(i) {
|
||||
var t = this;
|
||||
if (!this.K) {
|
||||
i.forEach((function(i) {
|
||||
return t.pushBack(i);
|
||||
}));
|
||||
return;
|
||||
}
|
||||
var n = this.K;
|
||||
i.forEach((function(i) {
|
||||
while (n && n !== t.J && n.L <= i) {
|
||||
n = n.H;
|
||||
}
|
||||
if (n === t.J) {
|
||||
t.pushBack(i);
|
||||
n = t.U;
|
||||
} else if (n === t.K) {
|
||||
t.pushFront(i);
|
||||
n = t.K;
|
||||
} else {
|
||||
t.o += 1;
|
||||
var r = n.F;
|
||||
r.H = new LinkNode(i);
|
||||
r.H.F = r;
|
||||
r.H.H = n;
|
||||
n.F = r.H;
|
||||
}
|
||||
}));
|
||||
};
|
||||
LinkList.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var i;
|
||||
return __generator(this, (function(t) {
|
||||
switch (t.label) {
|
||||
case 0:
|
||||
if (!this.K) return [ 2 ];
|
||||
i = this.K;
|
||||
t.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(i !== this.J)) return [ 3, 3 ];
|
||||
return [ 4, i.L ];
|
||||
|
||||
case 2:
|
||||
t.sent();
|
||||
i = i.H;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 3:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return LinkList;
|
||||
}(SequentialContainer);
|
||||
|
||||
export default LinkList;
|
||||
37
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.d.ts
generated
vendored
Normal file
37
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
export declare class VectorIterator<T> extends RandomIterator<T> {
|
||||
copy(): VectorIterator<T>;
|
||||
}
|
||||
declare class Vector<T> extends SequentialContainer<T> {
|
||||
/**
|
||||
* @description Vector's constructor.
|
||||
* @param container Initialize container, must have a forEach 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>, copy?: boolean);
|
||||
clear(): void;
|
||||
begin(): VectorIterator<T>;
|
||||
end(): VectorIterator<T>;
|
||||
rBegin(): VectorIterator<T>;
|
||||
rEnd(): VectorIterator<T>;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(value: T): void;
|
||||
eraseElementByIterator(iter: VectorIterator<T>): VectorIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
find(element: T): VectorIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
[Symbol.iterator](): Generator<T, any, undefined>;
|
||||
}
|
||||
export default Vector;
|
||||
318
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js
generated
vendored
Normal file
318
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js
generated
vendored
Normal file
@@ -0,0 +1,318 @@
|
||||
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 __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(t, r) {
|
||||
var e = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (o[0] & 1) throw o[1];
|
||||
return o[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, n, i, o, s;
|
||||
return s = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (s[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), s;
|
||||
function verb(t) {
|
||||
return function(r) {
|
||||
return step([ t, r ]);
|
||||
};
|
||||
}
|
||||
function step(s) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (e) try {
|
||||
if (n = 1, i && (o = s[0] & 2 ? i["return"] : s[0] ? i["throw"] || ((o = i["return"]) && o.call(i),
|
||||
0) : i.next) && !(o = o.call(i, s[1])).done) return o;
|
||||
if (i = 0, o) s = [ s[0] & 2, o.value ];
|
||||
switch (s[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
o = s;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
e.label++;
|
||||
return {
|
||||
value: s[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
e.label++;
|
||||
i = s[1];
|
||||
s = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
s = e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(o = e.trys, o = o.length > 0 && o[o.length - 1]) && (s[0] === 6 || s[0] === 2)) {
|
||||
e = 0;
|
||||
continue;
|
||||
}
|
||||
if (s[0] === 3 && (!o || s[1] > o[0] && s[1] < o[3])) {
|
||||
e.label = s[1];
|
||||
break;
|
||||
}
|
||||
if (s[0] === 6 && e.label < o[1]) {
|
||||
e.label = o[1];
|
||||
o = s;
|
||||
break;
|
||||
}
|
||||
if (o && e.label < o[2]) {
|
||||
e.label = o[2];
|
||||
e.ops.push(s);
|
||||
break;
|
||||
}
|
||||
if (o[2]) e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
}
|
||||
s = r.call(t, e);
|
||||
} catch (t) {
|
||||
s = [ 6, t ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = o = 0;
|
||||
}
|
||||
if (s[0] & 5) throw s[1];
|
||||
return {
|
||||
value: s[0] ? s[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __read = this && this._ || function(t, r) {
|
||||
var e = typeof Symbol === "function" && t[Symbol.iterator];
|
||||
if (!e) return t;
|
||||
var n = e.call(t), i, o = [], s;
|
||||
try {
|
||||
while ((r === void 0 || r-- > 0) && !(i = n.next()).done) o.push(i.value);
|
||||
} catch (t) {
|
||||
s = {
|
||||
error: t
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (i && !i.done && (e = n["return"])) e.call(n);
|
||||
} finally {
|
||||
if (s) throw s.error;
|
||||
}
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
var __spreadArray = this && this.P || function(t, r, e) {
|
||||
if (e || arguments.length === 2) for (var n = 0, i = r.length, o; n < i; n++) {
|
||||
if (o || !(n in r)) {
|
||||
if (!o) o = Array.prototype.slice.call(r, 0, n);
|
||||
o[n] = r[n];
|
||||
}
|
||||
}
|
||||
return t.concat(o || Array.prototype.slice.call(r));
|
||||
};
|
||||
|
||||
var __values = this && this.u || function(t) {
|
||||
var r = typeof Symbol === "function" && Symbol.iterator, e = r && t[r], n = 0;
|
||||
if (e) return e.call(t);
|
||||
if (t && typeof t.length === "number") return {
|
||||
next: function() {
|
||||
if (t && n >= t.length) t = void 0;
|
||||
return {
|
||||
value: t && t[n++],
|
||||
done: !t
|
||||
};
|
||||
}
|
||||
};
|
||||
throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
|
||||
import SequentialContainer from "./Base";
|
||||
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
|
||||
var VectorIterator = function(t) {
|
||||
__extends(VectorIterator, t);
|
||||
function VectorIterator() {
|
||||
return t !== null && t.apply(this, arguments) || this;
|
||||
}
|
||||
VectorIterator.prototype.copy = function() {
|
||||
return new VectorIterator(this.D, this.I, this.g, this.R, this.iteratorType);
|
||||
};
|
||||
return VectorIterator;
|
||||
}(RandomIterator);
|
||||
|
||||
export { VectorIterator };
|
||||
|
||||
var Vector = function(t) {
|
||||
__extends(Vector, t);
|
||||
function Vector(r, e) {
|
||||
if (r === void 0) {
|
||||
r = [];
|
||||
}
|
||||
if (e === void 0) {
|
||||
e = true;
|
||||
}
|
||||
var n = t.call(this) || this;
|
||||
if (Array.isArray(r)) {
|
||||
n.V = e ? __spreadArray([], __read(r), false) : r;
|
||||
n.o = r.length;
|
||||
} else {
|
||||
n.V = [];
|
||||
r.forEach((function(t) {
|
||||
return n.pushBack(t);
|
||||
}));
|
||||
}
|
||||
n.size = n.size.bind(n);
|
||||
n.getElementByPos = n.getElementByPos.bind(n);
|
||||
n.setElementByPos = n.setElementByPos.bind(n);
|
||||
return n;
|
||||
}
|
||||
Vector.prototype.clear = function() {
|
||||
this.o = 0;
|
||||
this.V.length = 0;
|
||||
};
|
||||
Vector.prototype.begin = function() {
|
||||
return new VectorIterator(0, this.size, this.getElementByPos, this.setElementByPos);
|
||||
};
|
||||
Vector.prototype.end = function() {
|
||||
return new VectorIterator(this.o, this.size, this.getElementByPos, this.setElementByPos);
|
||||
};
|
||||
Vector.prototype.rBegin = function() {
|
||||
return new VectorIterator(this.o - 1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
};
|
||||
Vector.prototype.rEnd = function() {
|
||||
return new VectorIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
};
|
||||
Vector.prototype.front = function() {
|
||||
return this.V[0];
|
||||
};
|
||||
Vector.prototype.back = function() {
|
||||
return this.V[this.o - 1];
|
||||
};
|
||||
Vector.prototype.forEach = function(t) {
|
||||
for (var r = 0; r < this.o; ++r) {
|
||||
t(this.V[r], r);
|
||||
}
|
||||
};
|
||||
Vector.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
return this.V[t];
|
||||
};
|
||||
Vector.prototype.eraseElementByPos = function(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.V.splice(t, 1);
|
||||
this.o -= 1;
|
||||
};
|
||||
Vector.prototype.eraseElementByValue = function(t) {
|
||||
var r = 0;
|
||||
for (var e = 0; e < this.o; ++e) {
|
||||
if (this.V[e] !== t) {
|
||||
this.V[r++] = this.V[e];
|
||||
}
|
||||
}
|
||||
this.o = this.V.length = r;
|
||||
};
|
||||
Vector.prototype.eraseElementByIterator = function(t) {
|
||||
var r = t.D;
|
||||
t = t.next();
|
||||
this.eraseElementByPos(r);
|
||||
return t;
|
||||
};
|
||||
Vector.prototype.pushBack = function(t) {
|
||||
this.V.push(t);
|
||||
this.o += 1;
|
||||
};
|
||||
Vector.prototype.popBack = function() {
|
||||
if (!this.o) return;
|
||||
this.V.pop();
|
||||
this.o -= 1;
|
||||
};
|
||||
Vector.prototype.setElementByPos = function(t, r) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.V[t] = r;
|
||||
};
|
||||
Vector.prototype.insert = function(t, r, e) {
|
||||
var n;
|
||||
if (e === void 0) {
|
||||
e = 1;
|
||||
}
|
||||
if (t < 0 || t > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
(n = this.V).splice.apply(n, __spreadArray([ t, 0 ], __read(new Array(e).fill(r)), false));
|
||||
this.o += e;
|
||||
};
|
||||
Vector.prototype.find = function(t) {
|
||||
for (var r = 0; r < this.o; ++r) {
|
||||
if (this.V[r] === t) {
|
||||
return new VectorIterator(r, this.size, this.getElementByPos, this.getElementByPos);
|
||||
}
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
Vector.prototype.reverse = function() {
|
||||
this.V.reverse();
|
||||
};
|
||||
Vector.prototype.unique = function() {
|
||||
var t = 1;
|
||||
for (var r = 1; r < this.o; ++r) {
|
||||
if (this.V[r] !== this.V[r - 1]) {
|
||||
this.V[t++] = this.V[r];
|
||||
}
|
||||
}
|
||||
this.o = this.V.length = t;
|
||||
};
|
||||
Vector.prototype.sort = function(t) {
|
||||
this.V.sort(t);
|
||||
};
|
||||
Vector.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
return __generator(this, (function(t) {
|
||||
switch (t.label) {
|
||||
case 0:
|
||||
return [ 5, __values(this.V) ];
|
||||
|
||||
case 1:
|
||||
return [ 2, t.sent() ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return Vector;
|
||||
}(SequentialContainer);
|
||||
|
||||
export default Vector;
|
||||
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;
|
||||
19
node_modules/js-sdsl/dist/esm/index.d.ts
generated
vendored
Normal file
19
node_modules/js-sdsl/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export { default as Stack } from "./container/OtherContainer/Stack";
|
||||
export { default as Queue } from "./container/OtherContainer/Queue";
|
||||
export { default as PriorityQueue } from "./container/OtherContainer/PriorityQueue";
|
||||
export { default as Vector } from "./container/SequentialContainer/Vector";
|
||||
export { default as LinkList } from "./container/SequentialContainer/LinkList";
|
||||
export { default as Deque } from "./container/SequentialContainer/Deque";
|
||||
export { default as OrderedSet } from "./container/TreeContainer/OrderedSet";
|
||||
export { default as OrderedMap } from "./container/TreeContainer/OrderedMap";
|
||||
export { default as HashSet } from "./container/HashContainer/HashSet";
|
||||
export { default as HashMap } from "./container/HashContainer/HashMap";
|
||||
export type { VectorIterator } from "./container/SequentialContainer/Vector";
|
||||
export type { LinkListIterator } from "./container/SequentialContainer/LinkList";
|
||||
export type { DequeIterator } from "./container/SequentialContainer/Deque";
|
||||
export type { OrderedSetIterator } from "./container/TreeContainer/OrderedSet";
|
||||
export type { OrderedMapIterator } from "./container/TreeContainer/OrderedMap";
|
||||
export type { IteratorType, Container, ContainerIterator } from "./container/ContainerBase";
|
||||
export type { default as SequentialContainer } from "./container/SequentialContainer/Base";
|
||||
export type { default as TreeContainer } from "./container/TreeContainer/Base";
|
||||
export type { default as HashContainer } from "./container/HashContainer/Base";
|
||||
19
node_modules/js-sdsl/dist/esm/index.js
generated
vendored
Normal file
19
node_modules/js-sdsl/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export { default as Stack } from "./container/OtherContainer/Stack";
|
||||
|
||||
export { default as Queue } from "./container/OtherContainer/Queue";
|
||||
|
||||
export { default as PriorityQueue } from "./container/OtherContainer/PriorityQueue";
|
||||
|
||||
export { default as Vector } from "./container/SequentialContainer/Vector";
|
||||
|
||||
export { default as LinkList } from "./container/SequentialContainer/LinkList";
|
||||
|
||||
export { default as Deque } from "./container/SequentialContainer/Deque";
|
||||
|
||||
export { default as OrderedSet } from "./container/TreeContainer/OrderedSet";
|
||||
|
||||
export { default as OrderedMap } from "./container/TreeContainer/OrderedMap";
|
||||
|
||||
export { default as HashSet } from "./container/HashContainer/HashSet";
|
||||
|
||||
export { default as HashMap } from "./container/HashContainer/HashMap";
|
||||
Reference in New Issue
Block a user