first commit
This commit is contained in:
206
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.d.ts
generated
vendored
Normal file
206
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* @description The iterator type including `NORMAL` and `REVERSE`.
|
||||
*/
|
||||
export declare const enum IteratorType {
|
||||
NORMAL = 0,
|
||||
REVERSE = 1
|
||||
}
|
||||
export declare abstract class ContainerIterator<T> {
|
||||
/**
|
||||
* @description The container pointed to by the iterator.
|
||||
*/
|
||||
abstract readonly container: Container<T>;
|
||||
/**
|
||||
* @description Iterator's type.
|
||||
* @example
|
||||
* console.log(container.end().iteratorType === IteratorType.NORMAL); // true
|
||||
*/
|
||||
readonly iteratorType: IteratorType;
|
||||
/**
|
||||
* @param iter - The other iterator you want to compare.
|
||||
* @returns Whether this equals to obj.
|
||||
* @example
|
||||
* container.find(1).equals(container.end());
|
||||
*/
|
||||
equals(iter: ContainerIterator<T>): boolean;
|
||||
/**
|
||||
* @description Pointers to element.
|
||||
* @returns The value of the pointer's element.
|
||||
* @example
|
||||
* const val = container.begin().pointer;
|
||||
*/
|
||||
abstract get pointer(): T;
|
||||
/**
|
||||
* @description Set pointer's value (some containers are unavailable).
|
||||
* @param newValue - The new value you want to set.
|
||||
* @example
|
||||
* (<LinkList<number>>container).begin().pointer = 1;
|
||||
*/
|
||||
abstract set pointer(newValue: T);
|
||||
/**
|
||||
* @description Move `this` iterator to pre.
|
||||
* @returns The iterator's self.
|
||||
* @example
|
||||
* const iter = container.find(1); // container = [0, 1]
|
||||
* const pre = iter.pre();
|
||||
* console.log(pre === iter); // true
|
||||
* console.log(pre.equals(iter)); // true
|
||||
* console.log(pre.pointer, iter.pointer); // 0, 0
|
||||
*/
|
||||
abstract pre(): this;
|
||||
/**
|
||||
* @description Move `this` iterator to next.
|
||||
* @returns The iterator's self.
|
||||
* @example
|
||||
* const iter = container.find(1); // container = [1, 2]
|
||||
* const next = iter.next();
|
||||
* console.log(next === iter); // true
|
||||
* console.log(next.equals(iter)); // true
|
||||
* console.log(next.pointer, iter.pointer); // 2, 2
|
||||
*/
|
||||
abstract next(): this;
|
||||
/**
|
||||
* @description Get a copy of itself.
|
||||
* @returns The copy of self.
|
||||
* @example
|
||||
* const iter = container.find(1); // container = [1, 2]
|
||||
* const next = iter.copy().next();
|
||||
* console.log(next === iter); // false
|
||||
* console.log(next.equals(iter)); // false
|
||||
* console.log(next.pointer, iter.pointer); // 2, 1
|
||||
*/
|
||||
abstract copy(): ContainerIterator<T>;
|
||||
}
|
||||
export declare abstract class Base {
|
||||
/**
|
||||
* @returns The size of the container.
|
||||
* @example
|
||||
* const container = new Vector([1, 2]);
|
||||
* console.log(container.length); // 2
|
||||
*/
|
||||
get length(): number;
|
||||
/**
|
||||
* @returns The size of the container.
|
||||
* @example
|
||||
* const container = new Vector([1, 2]);
|
||||
* console.log(container.size()); // 2
|
||||
*/
|
||||
size(): number;
|
||||
/**
|
||||
* @returns Whether the container is empty.
|
||||
* @example
|
||||
* container.clear();
|
||||
* console.log(container.empty()); // true
|
||||
*/
|
||||
empty(): boolean;
|
||||
/**
|
||||
* @description Clear the container.
|
||||
* @example
|
||||
* container.clear();
|
||||
* console.log(container.empty()); // true
|
||||
*/
|
||||
abstract clear(): void;
|
||||
}
|
||||
export declare abstract class Container<T> extends Base {
|
||||
/**
|
||||
* @returns Iterator pointing to the beginning element.
|
||||
* @example
|
||||
* const begin = container.begin();
|
||||
* const end = container.end();
|
||||
* for (const it = begin; !it.equals(end); it.next()) {
|
||||
* doSomething(it.pointer);
|
||||
* }
|
||||
*/
|
||||
abstract begin(): ContainerIterator<T>;
|
||||
/**
|
||||
* @returns Iterator pointing to the super end like c++.
|
||||
* @example
|
||||
* const begin = container.begin();
|
||||
* const end = container.end();
|
||||
* for (const it = begin; !it.equals(end); it.next()) {
|
||||
* doSomething(it.pointer);
|
||||
* }
|
||||
*/
|
||||
abstract end(): ContainerIterator<T>;
|
||||
/**
|
||||
* @returns Iterator pointing to the end element.
|
||||
* @example
|
||||
* const rBegin = container.rBegin();
|
||||
* const rEnd = container.rEnd();
|
||||
* for (const it = rBegin; !it.equals(rEnd); it.next()) {
|
||||
* doSomething(it.pointer);
|
||||
* }
|
||||
*/
|
||||
abstract rBegin(): ContainerIterator<T>;
|
||||
/**
|
||||
* @returns Iterator pointing to the super begin like c++.
|
||||
* @example
|
||||
* const rBegin = container.rBegin();
|
||||
* const rEnd = container.rEnd();
|
||||
* for (const it = rBegin; !it.equals(rEnd); it.next()) {
|
||||
* doSomething(it.pointer);
|
||||
* }
|
||||
*/
|
||||
abstract rEnd(): ContainerIterator<T>;
|
||||
/**
|
||||
* @returns The first element of the container.
|
||||
*/
|
||||
abstract front(): T | undefined;
|
||||
/**
|
||||
* @returns The last element of the container.
|
||||
*/
|
||||
abstract back(): T | undefined;
|
||||
/**
|
||||
* @param element - The element you want to find.
|
||||
* @returns An iterator pointing to the element if found, or super end if not found.
|
||||
* @example
|
||||
* container.find(1).equals(container.end());
|
||||
*/
|
||||
abstract find(element: T): ContainerIterator<T>;
|
||||
/**
|
||||
* @description Iterate over all elements in the container.
|
||||
* @param callback - Callback function like Array.forEach.
|
||||
* @example
|
||||
* container.forEach((element, index) => console.log(element, index));
|
||||
*/
|
||||
abstract forEach(callback: (element: T, index: number, container: Container<T>) => void): void;
|
||||
/**
|
||||
* @description Gets the value of the element at the specified position.
|
||||
* @example
|
||||
* const val = container.getElementByPos(-1); // throw a RangeError
|
||||
*/
|
||||
abstract getElementByPos(pos: number): T;
|
||||
/**
|
||||
* @description Removes the element at the specified position.
|
||||
* @param pos - The element's position you want to remove.
|
||||
* @returns The container length after erasing.
|
||||
* @example
|
||||
* container.eraseElementByPos(-1); // throw a RangeError
|
||||
*/
|
||||
abstract eraseElementByPos(pos: number): number;
|
||||
/**
|
||||
* @description Removes element by iterator and move `iter` to next.
|
||||
* @param iter - The iterator you want to erase.
|
||||
* @returns The next iterator.
|
||||
* @example
|
||||
* container.eraseElementByIterator(container.begin());
|
||||
* container.eraseElementByIterator(container.end()); // throw a RangeError
|
||||
*/
|
||||
abstract eraseElementByIterator(iter: ContainerIterator<T>): ContainerIterator<T>;
|
||||
/**
|
||||
* @description Using for `for...of` syntax like Array.
|
||||
* @example
|
||||
* for (const element of container) {
|
||||
* console.log(element);
|
||||
* }
|
||||
*/
|
||||
abstract [Symbol.iterator](): Generator<T, void>;
|
||||
}
|
||||
/**
|
||||
* @description The initial data type passed in when initializing the container.
|
||||
*/
|
||||
export declare type initContainer<T> = {
|
||||
size?: number | (() => number);
|
||||
length?: number;
|
||||
forEach: (callback: (el: T) => void) => void;
|
||||
};
|
68
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.js
generated
vendored
Normal file
68
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
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;
|
||||
}
|
||||
ContainerIterator.prototype.equals = function(n) {
|
||||
return this.o === n.o;
|
||||
};
|
||||
return ContainerIterator;
|
||||
}();
|
||||
|
||||
export { ContainerIterator };
|
||||
|
||||
var Base = function() {
|
||||
function Base() {
|
||||
this.M = 0;
|
||||
}
|
||||
Object.defineProperty(Base.prototype, "length", {
|
||||
get: function() {
|
||||
return this.M;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Base.prototype.size = function() {
|
||||
return this.M;
|
||||
};
|
||||
Base.prototype.empty = function() {
|
||||
return this.M === 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 };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/ContainerBase/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.d.ts
generated
vendored
Normal file
29
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Container, ContainerIterator } from "../../ContainerBase";
|
||||
export declare type HashLinkNode<K, V> = {
|
||||
_key: K;
|
||||
_value: V;
|
||||
_pre: HashLinkNode<K, V>;
|
||||
_next: HashLinkNode<K, V>;
|
||||
};
|
||||
export declare abstract class HashContainerIterator<K, V> extends ContainerIterator<K | [K, V]> {
|
||||
abstract readonly container: HashContainer<K, V>;
|
||||
pre(): this;
|
||||
next(): this;
|
||||
}
|
||||
export declare abstract class HashContainer<K, V> extends Container<K | [K, V]> {
|
||||
/**
|
||||
* @description Unique symbol used to tag object.
|
||||
*/
|
||||
readonly HASH_TAG: symbol;
|
||||
clear(): void;
|
||||
/**
|
||||
* @description Remove the element of the specified key.
|
||||
* @param key - The key you want to remove.
|
||||
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
|
||||
* If a `undefined` value is passed in, the type will be automatically judged.
|
||||
* @returns Whether erase successfully.
|
||||
*/
|
||||
eraseElementByKey(key: K, isObject?: boolean): boolean;
|
||||
eraseElementByIterator(iter: HashContainerIterator<K, V>): HashContainerIterator<K, V>;
|
||||
eraseElementByPos(pos: number): number;
|
||||
}
|
201
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.js
generated
vendored
Normal file
201
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
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 r in i) if (Object.prototype.hasOwnProperty.call(i, r)) t[r] = i[r];
|
||||
};
|
||||
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 __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { Container, ContainerIterator } from "../../ContainerBase";
|
||||
|
||||
import checkObject from "../../../utils/checkObject";
|
||||
|
||||
import { throwIteratorAccessError } from "../../../utils/throwError";
|
||||
|
||||
var HashContainerIterator = function(t) {
|
||||
__extends(HashContainerIterator, t);
|
||||
function HashContainerIterator(i, r, e) {
|
||||
var n = t.call(this, e) || this;
|
||||
n.o = i;
|
||||
n.h = r;
|
||||
if (n.iteratorType === 0) {
|
||||
n.pre = function() {
|
||||
if (this.o.L === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.L;
|
||||
return this;
|
||||
};
|
||||
n.next = function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.m;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
n.pre = function() {
|
||||
if (this.o.m === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.m;
|
||||
return this;
|
||||
};
|
||||
n.next = function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.L;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return n;
|
||||
}
|
||||
return HashContainerIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
export { HashContainerIterator };
|
||||
|
||||
var HashContainer = function(t) {
|
||||
__extends(HashContainer, t);
|
||||
function HashContainer() {
|
||||
var i = t.call(this) || this;
|
||||
i._ = [];
|
||||
i.I = {};
|
||||
i.HASH_TAG = Symbol("@@HASH_TAG");
|
||||
Object.setPrototypeOf(i.I, null);
|
||||
i.h = {};
|
||||
i.h.L = i.h.m = i.H = i.l = i.h;
|
||||
return i;
|
||||
}
|
||||
HashContainer.prototype.G = function(t) {
|
||||
var i = t.L, r = t.m;
|
||||
i.m = r;
|
||||
r.L = i;
|
||||
if (t === this.H) {
|
||||
this.H = r;
|
||||
}
|
||||
if (t === this.l) {
|
||||
this.l = i;
|
||||
}
|
||||
this.M -= 1;
|
||||
};
|
||||
HashContainer.prototype.v = function(t, i, r) {
|
||||
if (r === undefined) r = checkObject(t);
|
||||
var e;
|
||||
if (r) {
|
||||
var n = t[this.HASH_TAG];
|
||||
if (n !== undefined) {
|
||||
this._[n].p = i;
|
||||
return this.M;
|
||||
}
|
||||
Object.defineProperty(t, this.HASH_TAG, {
|
||||
value: this._.length,
|
||||
configurable: true
|
||||
});
|
||||
e = {
|
||||
u: t,
|
||||
p: i,
|
||||
L: this.l,
|
||||
m: this.h
|
||||
};
|
||||
this._.push(e);
|
||||
} else {
|
||||
var s = this.I[t];
|
||||
if (s) {
|
||||
s.p = i;
|
||||
return this.M;
|
||||
}
|
||||
e = {
|
||||
u: t,
|
||||
p: i,
|
||||
L: this.l,
|
||||
m: this.h
|
||||
};
|
||||
this.I[t] = e;
|
||||
}
|
||||
if (this.M === 0) {
|
||||
this.H = e;
|
||||
this.h.m = e;
|
||||
} else {
|
||||
this.l.m = e;
|
||||
}
|
||||
this.l = e;
|
||||
this.h.L = e;
|
||||
return ++this.M;
|
||||
};
|
||||
HashContainer.prototype.g = function(t, i) {
|
||||
if (i === undefined) i = checkObject(t);
|
||||
if (i) {
|
||||
var r = t[this.HASH_TAG];
|
||||
if (r === undefined) return this.h;
|
||||
return this._[r];
|
||||
} else {
|
||||
return this.I[t] || this.h;
|
||||
}
|
||||
};
|
||||
HashContainer.prototype.clear = function() {
|
||||
var t = this.HASH_TAG;
|
||||
this._.forEach((function(i) {
|
||||
delete i.u[t];
|
||||
}));
|
||||
this._ = [];
|
||||
this.I = {};
|
||||
Object.setPrototypeOf(this.I, null);
|
||||
this.M = 0;
|
||||
this.H = this.l = this.h.L = this.h.m = this.h;
|
||||
};
|
||||
HashContainer.prototype.eraseElementByKey = function(t, i) {
|
||||
var r;
|
||||
if (i === undefined) i = checkObject(t);
|
||||
if (i) {
|
||||
var e = t[this.HASH_TAG];
|
||||
if (e === undefined) return false;
|
||||
delete t[this.HASH_TAG];
|
||||
r = this._[e];
|
||||
delete this._[e];
|
||||
} else {
|
||||
r = this.I[t];
|
||||
if (r === undefined) return false;
|
||||
delete this.I[t];
|
||||
}
|
||||
this.G(r);
|
||||
return true;
|
||||
};
|
||||
HashContainer.prototype.eraseElementByIterator = function(t) {
|
||||
var i = t.o;
|
||||
if (i === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.G(i);
|
||||
return t.next();
|
||||
};
|
||||
HashContainer.prototype.eraseElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var i = this.H;
|
||||
while (t--) {
|
||||
i = i.m;
|
||||
}
|
||||
this.G(i);
|
||||
return this.M;
|
||||
};
|
||||
return HashContainer;
|
||||
}(Container);
|
||||
|
||||
export { HashContainer };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
49
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.d.ts
generated
vendored
Normal file
49
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { initContainer, IteratorType } from "../ContainerBase";
|
||||
import { HashContainer, HashContainerIterator, HashLinkNode } from "./Base";
|
||||
declare class HashMapIterator<K, V> extends HashContainerIterator<K, V> {
|
||||
readonly container: HashMap<K, V>;
|
||||
constructor(node: HashLinkNode<K, V>, header: HashLinkNode<K, V>, container: HashMap<K, V>, iteratorType?: IteratorType);
|
||||
get pointer(): [K, V];
|
||||
copy(): HashMapIterator<K, V>;
|
||||
equals(iter: HashMapIterator<K, V>): boolean;
|
||||
}
|
||||
export type { HashMapIterator };
|
||||
declare class HashMap<K, V> extends HashContainer<K, V> {
|
||||
constructor(container?: initContainer<[K, V]>);
|
||||
begin(): HashMapIterator<K, V>;
|
||||
end(): HashMapIterator<K, V>;
|
||||
rBegin(): HashMapIterator<K, V>;
|
||||
rEnd(): HashMapIterator<K, V>;
|
||||
front(): [K, V] | undefined;
|
||||
back(): [K, V] | undefined;
|
||||
/**
|
||||
* @description Insert a key-value pair or set value by the given key.
|
||||
* @param key - The key want to insert.
|
||||
* @param value - The value want to set.
|
||||
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
|
||||
* If a `undefined` value is passed in, the type will be automatically judged.
|
||||
* @returns The size of container after setting.
|
||||
*/
|
||||
setElement(key: K, value: V, isObject?: boolean): number;
|
||||
/**
|
||||
* @description Get the value of the element of the specified key.
|
||||
* @param key - The key want to search.
|
||||
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
|
||||
* If a `undefined` value is passed in, the type will be automatically judged.
|
||||
* @example
|
||||
* const val = container.getElementByKey(1);
|
||||
*/
|
||||
getElementByKey(key: K, isObject?: boolean): V | undefined;
|
||||
getElementByPos(pos: number): [K, V];
|
||||
/**
|
||||
* @description Check key if exist in container.
|
||||
* @param key - The element you want to search.
|
||||
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
|
||||
* If a `undefined` value is passed in, the type will be automatically judged.
|
||||
* @returns An iterator pointing to the element if found, or super end if not found.
|
||||
*/
|
||||
find(key: K, isObject?: boolean): HashMapIterator<K, V>;
|
||||
forEach(callback: (element: [K, V], index: number, hashMap: HashMap<K, V>) => void): void;
|
||||
[Symbol.iterator](): Generator<[K, V], void, unknown>;
|
||||
}
|
||||
export default HashMap;
|
248
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.js
generated
vendored
Normal file
248
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.js
generated
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
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 __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(t, r) {
|
||||
var n = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (a[0] & 1) throw a[1];
|
||||
return a[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, e, 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(t) {
|
||||
return function(r) {
|
||||
return step([ t, r ]);
|
||||
};
|
||||
}
|
||||
function step(s) {
|
||||
if (e) throw new TypeError("Generator is already executing.");
|
||||
while (n) try {
|
||||
if (e = 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:
|
||||
n.label++;
|
||||
return {
|
||||
value: s[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
n.label++;
|
||||
i = s[1];
|
||||
s = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
s = n.ops.pop();
|
||||
n.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(a = n.trys, a = a.length > 0 && a[a.length - 1]) && (s[0] === 6 || s[0] === 2)) {
|
||||
n = 0;
|
||||
continue;
|
||||
}
|
||||
if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
|
||||
n.label = s[1];
|
||||
break;
|
||||
}
|
||||
if (s[0] === 6 && n.label < a[1]) {
|
||||
n.label = a[1];
|
||||
a = s;
|
||||
break;
|
||||
}
|
||||
if (a && n.label < a[2]) {
|
||||
n.label = a[2];
|
||||
n.ops.push(s);
|
||||
break;
|
||||
}
|
||||
if (a[2]) n.ops.pop();
|
||||
n.trys.pop();
|
||||
continue;
|
||||
}
|
||||
s = r.call(t, n);
|
||||
} catch (t) {
|
||||
s = [ 6, t ];
|
||||
i = 0;
|
||||
} finally {
|
||||
e = a = 0;
|
||||
}
|
||||
if (s[0] & 5) throw s[1];
|
||||
return {
|
||||
value: s[0] ? s[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
import { HashContainer, HashContainerIterator } from "./Base";
|
||||
|
||||
import checkObject from "../../utils/checkObject";
|
||||
|
||||
import { throwIteratorAccessError } from "../../utils/throwError";
|
||||
|
||||
var HashMapIterator = function(t) {
|
||||
__extends(HashMapIterator, t);
|
||||
function HashMapIterator(r, n, e, i) {
|
||||
var a = t.call(this, r, n, i) || this;
|
||||
a.container = e;
|
||||
return a;
|
||||
}
|
||||
Object.defineProperty(HashMapIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
var t = this;
|
||||
return new Proxy([], {
|
||||
get: function(r, n) {
|
||||
if (n === "0") return t.o.u; else if (n === "1") return t.o.p;
|
||||
},
|
||||
set: function(r, n, e) {
|
||||
if (n !== "1") {
|
||||
throw new TypeError("props must be 1");
|
||||
}
|
||||
t.o.p = e;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
HashMapIterator.prototype.copy = function() {
|
||||
return new HashMapIterator(this.o, this.h, this.container, this.iteratorType);
|
||||
};
|
||||
return HashMapIterator;
|
||||
}(HashContainerIterator);
|
||||
|
||||
var HashMap = function(t) {
|
||||
__extends(HashMap, t);
|
||||
function HashMap(r) {
|
||||
if (r === void 0) {
|
||||
r = [];
|
||||
}
|
||||
var n = t.call(this) || this;
|
||||
var e = n;
|
||||
r.forEach((function(t) {
|
||||
e.setElement(t[0], t[1]);
|
||||
}));
|
||||
return n;
|
||||
}
|
||||
HashMap.prototype.begin = function() {
|
||||
return new HashMapIterator(this.H, this.h, this);
|
||||
};
|
||||
HashMap.prototype.end = function() {
|
||||
return new HashMapIterator(this.h, this.h, this);
|
||||
};
|
||||
HashMap.prototype.rBegin = function() {
|
||||
return new HashMapIterator(this.l, this.h, this, 1);
|
||||
};
|
||||
HashMap.prototype.rEnd = function() {
|
||||
return new HashMapIterator(this.h, this.h, this, 1);
|
||||
};
|
||||
HashMap.prototype.front = function() {
|
||||
if (this.M === 0) return;
|
||||
return [ this.H.u, this.H.p ];
|
||||
};
|
||||
HashMap.prototype.back = function() {
|
||||
if (this.M === 0) return;
|
||||
return [ this.l.u, this.l.p ];
|
||||
};
|
||||
HashMap.prototype.setElement = function(t, r, n) {
|
||||
return this.v(t, r, n);
|
||||
};
|
||||
HashMap.prototype.getElementByKey = function(t, r) {
|
||||
if (r === undefined) r = checkObject(t);
|
||||
if (r) {
|
||||
var n = t[this.HASH_TAG];
|
||||
return n !== undefined ? this._[n].p : undefined;
|
||||
}
|
||||
var e = this.I[t];
|
||||
return e ? e.p : undefined;
|
||||
};
|
||||
HashMap.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var r = this.H;
|
||||
while (t--) {
|
||||
r = r.m;
|
||||
}
|
||||
return [ r.u, r.p ];
|
||||
};
|
||||
HashMap.prototype.find = function(t, r) {
|
||||
var n = this.g(t, r);
|
||||
return new HashMapIterator(n, this.h, this);
|
||||
};
|
||||
HashMap.prototype.forEach = function(t) {
|
||||
var r = 0;
|
||||
var n = this.H;
|
||||
while (n !== this.h) {
|
||||
t([ n.u, n.p ], r++, this);
|
||||
n = n.m;
|
||||
}
|
||||
};
|
||||
HashMap.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var t;
|
||||
return __generator(this, (function(r) {
|
||||
switch (r.label) {
|
||||
case 0:
|
||||
t = this.H;
|
||||
r.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(t !== this.h)) return [ 3, 3 ];
|
||||
return [ 4, [ t.u, t.p ] ];
|
||||
|
||||
case 2:
|
||||
r.sent();
|
||||
t = t.m;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 3:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return HashMap;
|
||||
}(HashContainer);
|
||||
|
||||
export default HashMap;
|
||||
//# sourceMappingURL=HashMap.js.map
|
1
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
39
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.d.ts
generated
vendored
Normal file
39
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { initContainer, IteratorType } from "../ContainerBase";
|
||||
import { HashContainer, HashContainerIterator, HashLinkNode } from "./Base";
|
||||
declare class HashSetIterator<K> extends HashContainerIterator<K, undefined> {
|
||||
readonly container: HashSet<K>;
|
||||
constructor(node: HashLinkNode<K, undefined>, header: HashLinkNode<K, undefined>, container: HashSet<K>, iteratorType?: IteratorType);
|
||||
get pointer(): K;
|
||||
copy(): HashSetIterator<K>;
|
||||
equals(iter: HashSetIterator<K>): boolean;
|
||||
}
|
||||
export type { HashSetIterator };
|
||||
declare class HashSet<K> extends HashContainer<K, undefined> {
|
||||
constructor(container?: initContainer<K>);
|
||||
begin(): HashSetIterator<K>;
|
||||
end(): HashSetIterator<K>;
|
||||
rBegin(): HashSetIterator<K>;
|
||||
rEnd(): HashSetIterator<K>;
|
||||
front(): K | undefined;
|
||||
back(): K | undefined;
|
||||
/**
|
||||
* @description Insert element to set.
|
||||
* @param key - The key want to insert.
|
||||
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
|
||||
* If a `undefined` value is passed in, the type will be automatically judged.
|
||||
* @returns The size of container after inserting.
|
||||
*/
|
||||
insert(key: K, isObject?: boolean): number;
|
||||
getElementByPos(pos: number): K;
|
||||
/**
|
||||
* @description Check key if exist in container.
|
||||
* @param key - The element you want to search.
|
||||
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
|
||||
* If a `undefined` value is passed in, the type will be automatically judged.
|
||||
* @returns An iterator pointing to the element if found, or super end if not found.
|
||||
*/
|
||||
find(key: K, isObject?: boolean): HashSetIterator<K>;
|
||||
forEach(callback: (element: K, index: number, container: HashSet<K>) => void): void;
|
||||
[Symbol.iterator](): Generator<K, void, unknown>;
|
||||
}
|
||||
export default HashSet;
|
223
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.js
generated
vendored
Normal file
223
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.js
generated
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
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 (s[0] & 1) throw s[1];
|
||||
return s[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, n, i, s, a;
|
||||
return a = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (a[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), a;
|
||||
function verb(t) {
|
||||
return function(r) {
|
||||
return step([ t, r ]);
|
||||
};
|
||||
}
|
||||
function step(a) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (e) try {
|
||||
if (n = 1, i && (s = a[0] & 2 ? i["return"] : a[0] ? i["throw"] || ((s = i["return"]) && s.call(i),
|
||||
0) : i.next) && !(s = s.call(i, a[1])).done) return s;
|
||||
if (i = 0, s) a = [ a[0] & 2, s.value ];
|
||||
switch (a[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
s = a;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
e.label++;
|
||||
return {
|
||||
value: a[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
e.label++;
|
||||
i = a[1];
|
||||
a = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
a = e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(s = e.trys, s = s.length > 0 && s[s.length - 1]) && (a[0] === 6 || a[0] === 2)) {
|
||||
e = 0;
|
||||
continue;
|
||||
}
|
||||
if (a[0] === 3 && (!s || a[1] > s[0] && a[1] < s[3])) {
|
||||
e.label = a[1];
|
||||
break;
|
||||
}
|
||||
if (a[0] === 6 && e.label < s[1]) {
|
||||
e.label = s[1];
|
||||
s = a;
|
||||
break;
|
||||
}
|
||||
if (s && e.label < s[2]) {
|
||||
e.label = s[2];
|
||||
e.ops.push(a);
|
||||
break;
|
||||
}
|
||||
if (s[2]) e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
}
|
||||
a = r.call(t, e);
|
||||
} catch (t) {
|
||||
a = [ 6, t ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = s = 0;
|
||||
}
|
||||
if (a[0] & 5) throw a[1];
|
||||
return {
|
||||
value: a[0] ? a[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
import { HashContainer, HashContainerIterator } from "./Base";
|
||||
|
||||
import { throwIteratorAccessError } from "../../utils/throwError";
|
||||
|
||||
var HashSetIterator = function(t) {
|
||||
__extends(HashSetIterator, t);
|
||||
function HashSetIterator(r, e, n, i) {
|
||||
var s = t.call(this, r, e, i) || this;
|
||||
s.container = n;
|
||||
return s;
|
||||
}
|
||||
Object.defineProperty(HashSetIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
return this.o.u;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
HashSetIterator.prototype.copy = function() {
|
||||
return new HashSetIterator(this.o, this.h, this.container, this.iteratorType);
|
||||
};
|
||||
return HashSetIterator;
|
||||
}(HashContainerIterator);
|
||||
|
||||
var HashSet = function(t) {
|
||||
__extends(HashSet, t);
|
||||
function HashSet(r) {
|
||||
if (r === void 0) {
|
||||
r = [];
|
||||
}
|
||||
var e = t.call(this) || this;
|
||||
var n = e;
|
||||
r.forEach((function(t) {
|
||||
n.insert(t);
|
||||
}));
|
||||
return e;
|
||||
}
|
||||
HashSet.prototype.begin = function() {
|
||||
return new HashSetIterator(this.H, this.h, this);
|
||||
};
|
||||
HashSet.prototype.end = function() {
|
||||
return new HashSetIterator(this.h, this.h, this);
|
||||
};
|
||||
HashSet.prototype.rBegin = function() {
|
||||
return new HashSetIterator(this.l, this.h, this, 1);
|
||||
};
|
||||
HashSet.prototype.rEnd = function() {
|
||||
return new HashSetIterator(this.h, this.h, this, 1);
|
||||
};
|
||||
HashSet.prototype.front = function() {
|
||||
return this.H.u;
|
||||
};
|
||||
HashSet.prototype.back = function() {
|
||||
return this.l.u;
|
||||
};
|
||||
HashSet.prototype.insert = function(t, r) {
|
||||
return this.v(t, undefined, r);
|
||||
};
|
||||
HashSet.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var r = this.H;
|
||||
while (t--) {
|
||||
r = r.m;
|
||||
}
|
||||
return r.u;
|
||||
};
|
||||
HashSet.prototype.find = function(t, r) {
|
||||
var e = this.g(t, r);
|
||||
return new HashSetIterator(e, this.h, this);
|
||||
};
|
||||
HashSet.prototype.forEach = function(t) {
|
||||
var r = 0;
|
||||
var e = this.H;
|
||||
while (e !== this.h) {
|
||||
t(e.u, r++, this);
|
||||
e = e.m;
|
||||
}
|
||||
};
|
||||
HashSet.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var t;
|
||||
return __generator(this, (function(r) {
|
||||
switch (r.label) {
|
||||
case 0:
|
||||
t = this.H;
|
||||
r.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(t !== this.h)) return [ 3, 3 ];
|
||||
return [ 4, t.u ];
|
||||
|
||||
case 2:
|
||||
r.sent();
|
||||
t = t.m;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 3:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return HashSet;
|
||||
}(HashContainer);
|
||||
|
||||
export default HashSet;
|
||||
//# sourceMappingURL=HashSet.js.map
|
1
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
79
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.d.ts
generated
vendored
Normal file
79
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
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.
|
||||
* @example
|
||||
* new PriorityQueue();
|
||||
* new PriorityQueue([1, 2, 3]);
|
||||
* new PriorityQueue([1, 2, 3], (x, y) => x - y);
|
||||
* new PriorityQueue([1, 2, 3], (x, y) => x - y, false);
|
||||
*/
|
||||
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.
|
||||
* @returns The size of heap after pushing.
|
||||
* @example
|
||||
* queue.push(1);
|
||||
*/
|
||||
push(item: T): void;
|
||||
/**
|
||||
* @description Removes the top element.
|
||||
* @returns The element you popped.
|
||||
* @example
|
||||
* queue.pop();
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
/**
|
||||
* @description Accesses the top element.
|
||||
* @example
|
||||
* const top = queue.top();
|
||||
*/
|
||||
top(): T | undefined;
|
||||
/**
|
||||
* @description Check if element is in heap.
|
||||
* @param item - The item want to find.
|
||||
* @returns Whether element is in heap.
|
||||
* @example
|
||||
* const que = new PriorityQueue([], (x, y) => x.id - y.id);
|
||||
* const obj = { id: 1 };
|
||||
* que.push(obj);
|
||||
* console.log(que.find(obj)); // true
|
||||
*/
|
||||
find(item: T): boolean;
|
||||
/**
|
||||
* @description Remove specified item from heap.
|
||||
* @param item - The item want to remove.
|
||||
* @returns Whether remove success.
|
||||
* @example
|
||||
* const que = new PriorityQueue([], (x, y) => x.id - y.id);
|
||||
* const obj = { id: 1 };
|
||||
* que.push(obj);
|
||||
* que.remove(obj);
|
||||
*/
|
||||
remove(item: T): boolean;
|
||||
/**
|
||||
* @description Update item and it's pos in the heap.
|
||||
* @param item - The item want to update.
|
||||
* @returns Whether update success.
|
||||
* @example
|
||||
* const que = new PriorityQueue([], (x, y) => x.id - y.id);
|
||||
* const obj = { id: 1 };
|
||||
* que.push(obj);
|
||||
* obj.id = 2;
|
||||
* que.updateItem(obj);
|
||||
*/
|
||||
updateItem(item: T): boolean;
|
||||
/**
|
||||
* @returns Return a copy array of heap.
|
||||
* @example
|
||||
* const arr = queue.toArray();
|
||||
*/
|
||||
toArray(): T[];
|
||||
}
|
||||
export default PriorityQueue;
|
171
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.js
generated
vendored
Normal file
171
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.js
generated
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(i, r) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(i, r) {
|
||||
i.__proto__ = r;
|
||||
} || function(i, r) {
|
||||
for (var t in r) if (Object.prototype.hasOwnProperty.call(r, t)) i[t] = r[t];
|
||||
};
|
||||
return extendStatics(i, r);
|
||||
};
|
||||
return function(i, r) {
|
||||
if (typeof r !== "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
||||
extendStatics(i, r);
|
||||
function __() {
|
||||
this.constructor = i;
|
||||
}
|
||||
i.prototype = r === null ? Object.create(r) : (__.prototype = r.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __read = this && this.q || function(i, r) {
|
||||
var t = typeof Symbol === "function" && i[Symbol.iterator];
|
||||
if (!t) return i;
|
||||
var e = t.call(i), n, u = [], s;
|
||||
try {
|
||||
while ((r === void 0 || r-- > 0) && !(n = e.next()).done) u.push(n.value);
|
||||
} catch (i) {
|
||||
s = {
|
||||
error: i
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (n && !n.done && (t = e["return"])) t.call(e);
|
||||
} finally {
|
||||
if (s) throw s.error;
|
||||
}
|
||||
}
|
||||
return u;
|
||||
};
|
||||
|
||||
var __spreadArray = this && this.D || function(i, r, t) {
|
||||
if (t || arguments.length === 2) for (var e = 0, n = r.length, u; e < n; e++) {
|
||||
if (u || !(e in r)) {
|
||||
if (!u) u = Array.prototype.slice.call(r, 0, e);
|
||||
u[e] = r[e];
|
||||
}
|
||||
}
|
||||
return i.concat(u || Array.prototype.slice.call(r));
|
||||
};
|
||||
|
||||
import { Base } from "../ContainerBase";
|
||||
|
||||
var PriorityQueue = function(i) {
|
||||
__extends(PriorityQueue, i);
|
||||
function PriorityQueue(r, t, e) {
|
||||
if (r === void 0) {
|
||||
r = [];
|
||||
}
|
||||
if (t === void 0) {
|
||||
t = function(i, r) {
|
||||
if (i > r) return -1;
|
||||
if (i < r) return 1;
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
if (e === void 0) {
|
||||
e = true;
|
||||
}
|
||||
var n = i.call(this) || this;
|
||||
n.$ = t;
|
||||
if (Array.isArray(r)) {
|
||||
n.ii = e ? __spreadArray([], __read(r), false) : r;
|
||||
} else {
|
||||
n.ii = [];
|
||||
var u = n;
|
||||
r.forEach((function(i) {
|
||||
u.ii.push(i);
|
||||
}));
|
||||
}
|
||||
n.M = n.ii.length;
|
||||
var s = n.M >> 1;
|
||||
for (var o = n.M - 1 >> 1; o >= 0; --o) {
|
||||
n.ri(o, s);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
PriorityQueue.prototype.ti = function(i) {
|
||||
var r = this.ii[i];
|
||||
while (i > 0) {
|
||||
var t = i - 1 >> 1;
|
||||
var e = this.ii[t];
|
||||
if (this.$(e, r) <= 0) break;
|
||||
this.ii[i] = e;
|
||||
i = t;
|
||||
}
|
||||
this.ii[i] = r;
|
||||
};
|
||||
PriorityQueue.prototype.ri = function(i, r) {
|
||||
var t = this.ii[i];
|
||||
while (i < r) {
|
||||
var e = i << 1 | 1;
|
||||
var n = e + 1;
|
||||
var u = this.ii[e];
|
||||
if (n < this.M && this.$(u, this.ii[n]) > 0) {
|
||||
e = n;
|
||||
u = this.ii[n];
|
||||
}
|
||||
if (this.$(u, t) >= 0) break;
|
||||
this.ii[i] = u;
|
||||
i = e;
|
||||
}
|
||||
this.ii[i] = t;
|
||||
};
|
||||
PriorityQueue.prototype.clear = function() {
|
||||
this.M = 0;
|
||||
this.ii.length = 0;
|
||||
};
|
||||
PriorityQueue.prototype.push = function(i) {
|
||||
this.ii.push(i);
|
||||
this.ti(this.M);
|
||||
this.M += 1;
|
||||
};
|
||||
PriorityQueue.prototype.pop = function() {
|
||||
if (this.M === 0) return;
|
||||
var i = this.ii[0];
|
||||
var r = this.ii.pop();
|
||||
this.M -= 1;
|
||||
if (this.M) {
|
||||
this.ii[0] = r;
|
||||
this.ri(0, this.M >> 1);
|
||||
}
|
||||
return i;
|
||||
};
|
||||
PriorityQueue.prototype.top = function() {
|
||||
return this.ii[0];
|
||||
};
|
||||
PriorityQueue.prototype.find = function(i) {
|
||||
return this.ii.indexOf(i) >= 0;
|
||||
};
|
||||
PriorityQueue.prototype.remove = function(i) {
|
||||
var r = this.ii.indexOf(i);
|
||||
if (r < 0) return false;
|
||||
if (r === 0) {
|
||||
this.pop();
|
||||
} else if (r === this.M - 1) {
|
||||
this.ii.pop();
|
||||
this.M -= 1;
|
||||
} else {
|
||||
this.ii.splice(r, 1, this.ii.pop());
|
||||
this.M -= 1;
|
||||
this.ti(r);
|
||||
this.ri(r, this.M >> 1);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
PriorityQueue.prototype.updateItem = function(i) {
|
||||
var r = this.ii.indexOf(i);
|
||||
if (r < 0) return false;
|
||||
this.ti(r);
|
||||
this.ri(r, this.M >> 1);
|
||||
return true;
|
||||
};
|
||||
PriorityQueue.prototype.toArray = function() {
|
||||
return __spreadArray([], __read(this.ii), false);
|
||||
};
|
||||
return PriorityQueue;
|
||||
}(Base);
|
||||
|
||||
export default PriorityQueue;
|
||||
//# sourceMappingURL=PriorityQueue.js.map
|
1
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
22
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.d.ts
generated
vendored
Normal file
22
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Base, initContainer } from "../ContainerBase";
|
||||
declare class Queue<T> extends Base {
|
||||
constructor(container?: initContainer<T>);
|
||||
clear(): void;
|
||||
/**
|
||||
* @description Inserts element to queue's end.
|
||||
* @param element - The element you want to push to the front.
|
||||
* @returns The container length after pushing.
|
||||
*/
|
||||
push(element: T): number;
|
||||
/**
|
||||
* @description Removes the first element.
|
||||
* @returns The element you popped.
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
/**
|
||||
* @description Access the first element.
|
||||
* @returns The first element.
|
||||
*/
|
||||
front(): T | undefined;
|
||||
}
|
||||
export default Queue;
|
69
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.js
generated
vendored
Normal file
69
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
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 n in i) if (Object.prototype.hasOwnProperty.call(i, n)) t[n] = i[n];
|
||||
};
|
||||
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 __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { Base } from "../ContainerBase";
|
||||
|
||||
var Queue = function(t) {
|
||||
__extends(Queue, t);
|
||||
function Queue(i) {
|
||||
if (i === void 0) {
|
||||
i = [];
|
||||
}
|
||||
var n = t.call(this) || this;
|
||||
n.A = 0;
|
||||
n.tt = [];
|
||||
var e = n;
|
||||
i.forEach((function(t) {
|
||||
e.push(t);
|
||||
}));
|
||||
return n;
|
||||
}
|
||||
Queue.prototype.clear = function() {
|
||||
this.tt = [];
|
||||
this.M = this.A = 0;
|
||||
};
|
||||
Queue.prototype.push = function(t) {
|
||||
var i = this.tt.length;
|
||||
if (this.A / i > .5 && this.A + this.M >= i && i > 4096) {
|
||||
var n = this.M;
|
||||
for (var e = 0; e < n; ++e) {
|
||||
this.tt[e] = this.tt[this.A + e];
|
||||
}
|
||||
this.A = 0;
|
||||
this.tt[this.M] = t;
|
||||
} else this.tt[this.A + this.M] = t;
|
||||
return ++this.M;
|
||||
};
|
||||
Queue.prototype.pop = function() {
|
||||
if (this.M === 0) return;
|
||||
var t = this.tt[this.A++];
|
||||
this.M -= 1;
|
||||
return t;
|
||||
};
|
||||
Queue.prototype.front = function() {
|
||||
if (this.M === 0) return;
|
||||
return this.tt[this.A];
|
||||
};
|
||||
return Queue;
|
||||
}(Base);
|
||||
|
||||
export default Queue;
|
||||
//# sourceMappingURL=Queue.js.map
|
1
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
22
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.d.ts
generated
vendored
Normal file
22
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Base, initContainer } from "../ContainerBase";
|
||||
declare class Stack<T> extends Base {
|
||||
constructor(container?: initContainer<T>);
|
||||
clear(): void;
|
||||
/**
|
||||
* @description Insert element to stack's end.
|
||||
* @description The element you want to push to the back.
|
||||
* @returns The container length after erasing.
|
||||
*/
|
||||
push(element: T): number;
|
||||
/**
|
||||
* @description Removes the end element.
|
||||
* @returns The element you popped.
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
/**
|
||||
* @description Accesses the end element.
|
||||
* @returns The last element.
|
||||
*/
|
||||
top(): T | undefined;
|
||||
}
|
||||
export default Stack;
|
59
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js
generated
vendored
Normal file
59
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
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.nt = [];
|
||||
var r = i;
|
||||
n.forEach((function(t) {
|
||||
r.push(t);
|
||||
}));
|
||||
return i;
|
||||
}
|
||||
Stack.prototype.clear = function() {
|
||||
this.M = 0;
|
||||
this.nt = [];
|
||||
};
|
||||
Stack.prototype.push = function(t) {
|
||||
this.nt.push(t);
|
||||
this.M += 1;
|
||||
return this.M;
|
||||
};
|
||||
Stack.prototype.pop = function() {
|
||||
if (this.M === 0) return;
|
||||
this.M -= 1;
|
||||
return this.nt.pop();
|
||||
};
|
||||
Stack.prototype.top = function() {
|
||||
return this.nt[this.M - 1];
|
||||
};
|
||||
return Stack;
|
||||
}(Base);
|
||||
|
||||
export default Stack;
|
||||
//# sourceMappingURL=Stack.js.map
|
1
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["container/OtherContainer/Stack.js","../../src/container/OtherContainer/Stack.ts"],"names":["__extends","this","extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","TypeError","String","__","constructor","create","Base","Stack","_super","container","_this","_stack","self","forEach","el","push","clear","_length","element","pop","top"],"mappings":"AAAA,IAAIA,YAAaC,QAAQA,KAAKD,KAAe;IACzC,IAAIE,gBAAgB,SAAUC,GAAGC;QAC7BF,gBAAgBG,OAAOC,kBAClB;YAAEC,WAAW;qBAAgBC,SAAS,SAAUL,GAAGC;YAAKD,EAAEI,YAAYH;AAAG,aAC1E,SAAUD,GAAGC;YAAK,KAAK,IAAIK,KAAKL,GAAG,IAAIC,OAAOK,UAAUC,eAAeC,KAAKR,GAAGK,IAAIN,EAAEM,KAAKL,EAAEK;AAAI;QACpG,OAAOP,cAAcC,GAAGC;AAC5B;IACA,OAAO,SAAUD,GAAGC;QAChB,WAAWA,MAAM,cAAcA,MAAM,MACjC,MAAM,IAAIS,UAAU,yBAAyBC,OAAOV,KAAK;QAC7DF,cAAcC,GAAGC;QACjB,SAASW;YAAOd,KAAKe,cAAcb;AAAG;QACtCA,EAAEO,YAAYN,MAAM,OAAOC,OAAOY,OAAOb,MAAMW,GAAGL,YAAYN,EAAEM,WAAW,IAAIK;AACnF;AACJ,CAd6C;;SCApCG,YAAqB;;AAE9B,IAAAC,QAAA,SAAAC;IAAuBpB,UAAAmB,OAAAC;IAKrB,SAAAD,MAAYE;QAAA,IAAAA,WAAA,GAAA;YAAAA,IAAA;AAAgC;QAA5C,IAAAC,IACEF,EAAAR,KAAAX,SAAOA;QAFDqB,EAAAC,KAAc;QAGpB,IAAMC,IAAOF;QACbD,EAAUI,SAAQ,SAAUC;YAC1BF,EAAKG,KAAKD;ADiBR;QACA,OAAOJ;AACX;IChBFH,MAAAT,UAAAkB,QAAA;QACE3B,KAAK4B,IAAU;QACf5B,KAAKsB,KAAS;ADkBd;ICXFJ,MAAAT,UAAAiB,OAAA,SAAKG;QACH7B,KAAKsB,GAAOI,KAAKG;QACjB7B,KAAK4B,KAAW;QAChB,OAAO5B,KAAK4B;ADkBZ;ICZFV,MAAAT,UAAAqB,MAAA;QACE,IAAI9B,KAAK4B,MAAY,GAAG;QACxB5B,KAAK4B,KAAW;QAChB,OAAO5B,KAAKsB,GAAOQ;ADmBnB;ICbFZ,MAAAT,UAAAsB,MAAA;QACE,OAAO/B,KAAKsB,GAAOtB,KAAK4B,IAAU;ADmBlC;ICjBJ,OAAAV;AAAA,CA1CA,CAAuBD;;eA4CRC","file":"Stack.js","sourcesContent":["var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { Base } from \"../ContainerBase\";\nvar Stack = /** @class */ (function (_super) {\n __extends(Stack, _super);\n function Stack(container) {\n if (container === void 0) { container = []; }\n var _this = _super.call(this) || this;\n /**\n * @internal\n */\n _this._stack = [];\n var self = _this;\n container.forEach(function (el) {\n self.push(el);\n });\n return _this;\n }\n Stack.prototype.clear = function () {\n this._length = 0;\n this._stack = [];\n };\n /**\n * @description Insert element to stack's end.\n * @description The element you want to push to the back.\n * @returns The container length after erasing.\n */\n Stack.prototype.push = function (element) {\n this._stack.push(element);\n this._length += 1;\n return this._length;\n };\n /**\n * @description Removes the end element.\n * @returns The element you popped.\n */\n Stack.prototype.pop = function () {\n if (this._length === 0)\n return;\n this._length -= 1;\n return this._stack.pop();\n };\n /**\n * @description Accesses the end element.\n * @returns The last element.\n */\n Stack.prototype.top = function () {\n return this._stack[this._length - 1];\n };\n return Stack;\n}(Base));\nexport default Stack;\n","import { Base, initContainer } from '@/container/ContainerBase';\n\nclass Stack<T> extends Base {\n /**\n * @internal\n */\n private _stack: T[] = [];\n constructor(container: initContainer<T> = []) {\n super();\n const self = this;\n container.forEach(function (el) {\n self.push(el);\n });\n }\n clear() {\n this._length = 0;\n this._stack = [];\n }\n /**\n * @description Insert element to stack's end.\n * @description The element you want to push to the back.\n * @returns The container length after erasing.\n */\n push(element: T) {\n this._stack.push(element);\n this._length += 1;\n return this._length;\n }\n /**\n * @description Removes the end element.\n * @returns The element you popped.\n */\n pop() {\n if (this._length === 0) return;\n this._length -= 1;\n return this._stack.pop();\n }\n /**\n * @description Accesses the end element.\n * @returns The last element.\n */\n top(): T | undefined {\n return this._stack[this._length - 1];\n }\n}\n\nexport default Stack;\n"]}
|
9
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.d.ts
generated
vendored
Normal file
9
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
import SequentialContainer from "./index";
|
||||
export declare abstract class RandomIterator<T> extends ContainerIterator<T> {
|
||||
abstract readonly container: SequentialContainer<T>;
|
||||
get pointer(): T;
|
||||
set pointer(newValue: T);
|
||||
pre(): this;
|
||||
next(): this;
|
||||
}
|
78
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js
generated
vendored
Normal file
78
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
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";
|
||||
|
||||
import { throwIteratorAccessError } from "../../../utils/throwError";
|
||||
|
||||
var RandomIterator = function(t) {
|
||||
__extends(RandomIterator, t);
|
||||
function RandomIterator(r, n) {
|
||||
var o = t.call(this, n) || this;
|
||||
o.o = r;
|
||||
if (o.iteratorType === 0) {
|
||||
o.pre = function() {
|
||||
if (this.o === 0) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o -= 1;
|
||||
return this;
|
||||
};
|
||||
o.next = function() {
|
||||
if (this.o === this.container.size()) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o += 1;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
o.pre = function() {
|
||||
if (this.o === this.container.size() - 1) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o += 1;
|
||||
return this;
|
||||
};
|
||||
o.next = function() {
|
||||
if (this.o === -1) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o -= 1;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return o;
|
||||
}
|
||||
Object.defineProperty(RandomIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
return this.container.getElementByPos(this.o);
|
||||
},
|
||||
set: function(t) {
|
||||
this.container.setElementByPos(this.o, t);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return RandomIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
export { RandomIterator };
|
||||
//# sourceMappingURL=RandomIterator.js.map
|
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
67
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.d.ts
generated
vendored
Normal file
67
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
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.
|
||||
* @returns The size of container after pushing.
|
||||
*/
|
||||
abstract pushBack(element: T): number;
|
||||
/**
|
||||
* @description Removes the last element.
|
||||
* @returns The element you popped.
|
||||
*/
|
||||
abstract popBack(): T | undefined;
|
||||
/**
|
||||
* @description Sets element by position.
|
||||
* @param pos - The position you want to change.
|
||||
* @param element - The element's value you want to update.
|
||||
* @example
|
||||
* container.setElementByPos(-1, 1); // throw a RangeError
|
||||
*/
|
||||
abstract setElementByPos(pos: number, element: T): void;
|
||||
/**
|
||||
* @description Removes the elements of the specified value.
|
||||
* @param value - The value you want to remove.
|
||||
* @returns The size of container after erasing.
|
||||
* @example
|
||||
* container.eraseElementByValue(-1);
|
||||
*/
|
||||
abstract eraseElementByValue(value: T): number;
|
||||
/**
|
||||
* @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).
|
||||
* @returns The size of container after inserting.
|
||||
* @example
|
||||
* const container = new Vector([1, 2, 3]);
|
||||
* container.insert(1, 4); // [1, 4, 2, 3]
|
||||
* container.insert(1, 5, 3); // [1, 5, 5, 5, 4, 2, 3]
|
||||
*/
|
||||
abstract insert(pos: number, element: T, num?: number): number;
|
||||
/**
|
||||
* @description Reverses the container.
|
||||
* @example
|
||||
* const container = new Vector([1, 2, 3]);
|
||||
* container.reverse(); // [3, 2, 1]
|
||||
*/
|
||||
abstract reverse(): void;
|
||||
/**
|
||||
* @description Removes the duplication of elements in the container.
|
||||
* @returns The size of container after inserting.
|
||||
* @example
|
||||
* const container = new Vector([1, 1, 3, 2, 2, 5, 5, 2]);
|
||||
* container.unique(); // [1, 3, 2, 5, 2]
|
||||
*/
|
||||
abstract unique(): number;
|
||||
/**
|
||||
* @description Sort the container.
|
||||
* @param cmp - Comparison function to sort.
|
||||
* @example
|
||||
* const container = new Vector([3, 1, 10]);
|
||||
* container.sort(); // [1, 10, 3]
|
||||
* container.sort((x, y) => x - y); // [1, 3, 10]
|
||||
*/
|
||||
abstract sort(cmp?: (x: T, y: T) => number): void;
|
||||
}
|
||||
export default SequentialContainer;
|
33
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js
generated
vendored
Normal file
33
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["container/SequentialContainer/Base/index.js","../../src/container/SequentialContainer/Base/index.ts"],"names":["__extends","this","extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","TypeError","String","__","constructor","create","Container","SequentialContainer","_super","apply","arguments"],"mappings":"AAAA,IAAIA,YAAaC,QAAQA,KAAKD,KAAe;IACzC,IAAIE,gBAAgB,SAAUC,GAAGC;QAC7BF,gBAAgBG,OAAOC,kBAClB;YAAEC,WAAW;qBAAgBC,SAAS,SAAUL,GAAGC;YAAKD,EAAEI,YAAYH;AAAG,aAC1E,SAAUD,GAAGC;YAAK,KAAK,IAAIK,KAAKL,GAAG,IAAIC,OAAOK,UAAUC,eAAeC,KAAKR,GAAGK,IAAIN,EAAEM,KAAKL,EAAEK;AAAI;QACpG,OAAOP,cAAcC,GAAGC;AAC5B;IACA,OAAO,SAAUD,GAAGC;QAChB,WAAWA,MAAM,cAAcA,MAAM,MACjC,MAAM,IAAIS,UAAU,yBAAyBC,OAAOV,KAAK;QAC7DF,cAAcC,GAAGC;QACjB,SAASW;YAAOd,KAAKe,cAAcb;AAAG;QACtCA,EAAEO,YAAYN,MAAM,OAAOC,OAAOY,OAAOb,MAAMW,GAAGL,YAAYN,EAAEM,WAAW,IAAIK;AACnF;AACJ,CAd6C;;SCApCG,iBAAW;;AAEpB,IAAAC,sBAAA,SAAAC;IAA8CpB,UAAAmB,qBAAAC;IAA9C,SAAAD;QDiBQ,OAAOC,MAAW,QAAQA,EAAOC,MAAMpB,MAAMqB,cAAcrB;AC+CnE;IAAA,OAAAkB;AAAA,CAhEA,CAA8CD;;eAkE/BC","file":"index.js","sourcesContent":["var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nimport { Container } from \"../../ContainerBase\";\nvar SequentialContainer = /** @class */ (function (_super) {\n __extends(SequentialContainer, _super);\n function SequentialContainer() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n return SequentialContainer;\n}(Container));\nexport default SequentialContainer;\n","import { Container } from '@/container/ContainerBase';\n\nabstract class SequentialContainer<T> extends Container<T> {\n /**\n * @description Push the element to the back.\n * @param element - The element you want to push.\n * @returns The size of container after pushing.\n */\n abstract pushBack(element: T): number;\n /**\n * @description Removes the last element.\n * @returns The element you popped.\n */\n abstract popBack(): T | undefined;\n /**\n * @description Sets element by position.\n * @param pos - The position you want to change.\n * @param element - The element's value you want to update.\n * @example\n * container.setElementByPos(-1, 1); // throw a RangeError\n */\n abstract setElementByPos(pos: number, element: T): void;\n /**\n * @description Removes the elements of the specified value.\n * @param value - The value you want to remove.\n * @returns The size of container after erasing.\n * @example\n * container.eraseElementByValue(-1);\n */\n abstract eraseElementByValue(value: T): number;\n /**\n * @description Insert several elements after the specified position.\n * @param pos - The position you want to insert.\n * @param element - The element you want to insert.\n * @param num - The number of elements you want to insert (default 1).\n * @returns The size of container after inserting.\n * @example\n * const container = new Vector([1, 2, 3]);\n * container.insert(1, 4); // [1, 4, 2, 3]\n * container.insert(1, 5, 3); // [1, 5, 5, 5, 4, 2, 3]\n */\n abstract insert(pos: number, element: T, num?: number): number;\n /**\n * @description Reverses the container.\n * @example\n * const container = new Vector([1, 2, 3]);\n * container.reverse(); // [3, 2, 1]\n */\n abstract reverse(): void;\n /**\n * @description Removes the duplication of elements in the container.\n * @returns The size of container after inserting.\n * @example\n * const container = new Vector([1, 1, 3, 2, 2, 5, 5, 2]);\n * container.unique(); // [1, 3, 2, 5, 2]\n */\n abstract unique(): number;\n /**\n * @description Sort the container.\n * @param cmp - Comparison function to sort.\n * @example\n * const container = new Vector([3, 1, 10]);\n * container.sort(); // [1, 10, 3]\n * container.sort((x, y) => x - y); // [1, 3, 10]\n */\n abstract sort(cmp?: (x: T, y: T) => number): void;\n}\n\nexport default SequentialContainer;\n"]}
|
58
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.d.ts
generated
vendored
Normal file
58
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { IteratorType, initContainer } from "../ContainerBase";
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
declare class DequeIterator<T> extends RandomIterator<T> {
|
||||
readonly container: Deque<T>;
|
||||
constructor(node: number, container: Deque<T>, iteratorType?: IteratorType);
|
||||
copy(): DequeIterator<T>;
|
||||
equals(iter: DequeIterator<T>): boolean;
|
||||
}
|
||||
export type { DequeIterator };
|
||||
declare class Deque<T> extends SequentialContainer<T> {
|
||||
constructor(container?: initContainer<T>, _bucketSize?: number);
|
||||
clear(): void;
|
||||
begin(): DequeIterator<T>;
|
||||
end(): DequeIterator<T>;
|
||||
rBegin(): DequeIterator<T>;
|
||||
rEnd(): DequeIterator<T>;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
pushBack(element: T): number;
|
||||
popBack(): T | undefined;
|
||||
/**
|
||||
* @description Push the element to the front.
|
||||
* @param element - The element you want to push.
|
||||
* @returns The size of queue after pushing.
|
||||
*/
|
||||
pushFront(element: T): number;
|
||||
/**
|
||||
* @description Remove the _first element.
|
||||
* @returns The element you popped.
|
||||
*/
|
||||
popFront(): T | undefined;
|
||||
getElementByPos(pos: number): T;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): number;
|
||||
/**
|
||||
* @description Remove all elements after the specified position (excluding the specified position).
|
||||
* @param pos - The previous position of the first removed element.
|
||||
* @returns The size of the container after cutting.
|
||||
* @example
|
||||
* deque.cut(1); // Then deque's size will be 2. deque -> [0, 1]
|
||||
*/
|
||||
cut(pos: number): number;
|
||||
eraseElementByPos(pos: number): number;
|
||||
eraseElementByValue(value: T): number;
|
||||
eraseElementByIterator(iter: DequeIterator<T>): DequeIterator<T>;
|
||||
find(element: T): DequeIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): number;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
/**
|
||||
* @description Remove as much useless space as possible.
|
||||
*/
|
||||
shrinkToFit(): void;
|
||||
forEach(callback: (element: T, index: number, deque: Deque<T>) => void): void;
|
||||
[Symbol.iterator](): Generator<T, void, unknown>;
|
||||
}
|
||||
export default Deque;
|
498
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js
generated
vendored
Normal file
498
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js
generated
vendored
Normal file
@@ -0,0 +1,498 @@
|
||||
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 r in i) if (Object.prototype.hasOwnProperty.call(i, r)) t[r] = i[r];
|
||||
};
|
||||
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 r = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (h[0] & 1) throw h[1];
|
||||
return h[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, e, 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 (e) throw new TypeError("Generator is already executing.");
|
||||
while (r) try {
|
||||
if (e = 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:
|
||||
r.label++;
|
||||
return {
|
||||
value: n[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
r.label++;
|
||||
s = n[1];
|
||||
n = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
n = r.ops.pop();
|
||||
r.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(h = r.trys, h = h.length > 0 && h[h.length - 1]) && (n[0] === 6 || n[0] === 2)) {
|
||||
r = 0;
|
||||
continue;
|
||||
}
|
||||
if (n[0] === 3 && (!h || n[1] > h[0] && n[1] < h[3])) {
|
||||
r.label = n[1];
|
||||
break;
|
||||
}
|
||||
if (n[0] === 6 && r.label < h[1]) {
|
||||
r.label = h[1];
|
||||
h = n;
|
||||
break;
|
||||
}
|
||||
if (h && r.label < h[2]) {
|
||||
r.label = h[2];
|
||||
r.ops.push(n);
|
||||
break;
|
||||
}
|
||||
if (h[2]) r.ops.pop();
|
||||
r.trys.pop();
|
||||
continue;
|
||||
}
|
||||
n = i.call(t, r);
|
||||
} catch (t) {
|
||||
n = [ 6, t ];
|
||||
s = 0;
|
||||
} finally {
|
||||
e = h = 0;
|
||||
}
|
||||
if (n[0] & 5) throw n[1];
|
||||
return {
|
||||
value: n[0] ? n[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __read = this && this.q || function(t, i) {
|
||||
var r = typeof Symbol === "function" && t[Symbol.iterator];
|
||||
if (!r) return t;
|
||||
var e = r.call(t), s, h = [], n;
|
||||
try {
|
||||
while ((i === void 0 || i-- > 0) && !(s = e.next()).done) h.push(s.value);
|
||||
} catch (t) {
|
||||
n = {
|
||||
error: t
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (s && !s.done && (r = e["return"])) r.call(e);
|
||||
} finally {
|
||||
if (n) throw n.error;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
};
|
||||
|
||||
var __spreadArray = this && this.D || function(t, i, r) {
|
||||
if (r || arguments.length === 2) for (var e = 0, s = i.length, h; e < s; e++) {
|
||||
if (h || !(e in i)) {
|
||||
if (!h) h = Array.prototype.slice.call(i, 0, e);
|
||||
h[e] = i[e];
|
||||
}
|
||||
}
|
||||
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(i, r, e) {
|
||||
var s = t.call(this, i, e) || this;
|
||||
s.container = r;
|
||||
return s;
|
||||
}
|
||||
DequeIterator.prototype.copy = function() {
|
||||
return new DequeIterator(this.o, this.container, this.iteratorType);
|
||||
};
|
||||
return DequeIterator;
|
||||
}(RandomIterator);
|
||||
|
||||
var Deque = function(t) {
|
||||
__extends(Deque, t);
|
||||
function Deque(i, r) {
|
||||
if (i === void 0) {
|
||||
i = [];
|
||||
}
|
||||
if (r === void 0) {
|
||||
r = 1 << 12;
|
||||
}
|
||||
var e = t.call(this) || this;
|
||||
e.A = 0;
|
||||
e.S = 0;
|
||||
e.R = 0;
|
||||
e.k = 0;
|
||||
e.C = 0;
|
||||
e.j = [];
|
||||
var s = function() {
|
||||
if (typeof i.length === "number") return i.length;
|
||||
if (typeof i.size === "number") return i.size;
|
||||
if (typeof i.size === "function") return i.size();
|
||||
throw new TypeError("Cannot get the length or size of the container");
|
||||
}();
|
||||
e.B = r;
|
||||
e.C = Math.max(Math.ceil(s / e.B), 1);
|
||||
for (var h = 0; h < e.C; ++h) {
|
||||
e.j.push(new Array(e.B));
|
||||
}
|
||||
var n = Math.ceil(s / e.B);
|
||||
e.A = e.R = (e.C >> 1) - (n >> 1);
|
||||
e.S = e.k = e.B - s % e.B >> 1;
|
||||
var u = e;
|
||||
i.forEach((function(t) {
|
||||
u.pushBack(t);
|
||||
}));
|
||||
return e;
|
||||
}
|
||||
Deque.prototype.O = function() {
|
||||
var t = [];
|
||||
var i = Math.max(this.C >> 1, 1);
|
||||
for (var r = 0; r < i; ++r) {
|
||||
t[r] = new Array(this.B);
|
||||
}
|
||||
for (var r = this.A; r < this.C; ++r) {
|
||||
t[t.length] = this.j[r];
|
||||
}
|
||||
for (var r = 0; r < this.R; ++r) {
|
||||
t[t.length] = this.j[r];
|
||||
}
|
||||
t[t.length] = __spreadArray([], __read(this.j[this.R]), false);
|
||||
this.A = i;
|
||||
this.R = t.length - 1;
|
||||
for (var r = 0; r < i; ++r) {
|
||||
t[t.length] = new Array(this.B);
|
||||
}
|
||||
this.j = t;
|
||||
this.C = t.length;
|
||||
};
|
||||
Deque.prototype.T = function(t) {
|
||||
var i = this.S + t + 1;
|
||||
var r = i % this.B;
|
||||
var e = r - 1;
|
||||
var s = this.A + (i - r) / this.B;
|
||||
if (r === 0) s -= 1;
|
||||
s %= this.C;
|
||||
if (e < 0) e += this.B;
|
||||
return {
|
||||
curNodeBucketIndex: s,
|
||||
curNodePointerIndex: e
|
||||
};
|
||||
};
|
||||
Deque.prototype.clear = function() {
|
||||
this.j = [ new Array(this.B) ];
|
||||
this.C = 1;
|
||||
this.A = this.R = this.M = 0;
|
||||
this.S = this.k = this.B >> 1;
|
||||
};
|
||||
Deque.prototype.begin = function() {
|
||||
return new DequeIterator(0, this);
|
||||
};
|
||||
Deque.prototype.end = function() {
|
||||
return new DequeIterator(this.M, this);
|
||||
};
|
||||
Deque.prototype.rBegin = function() {
|
||||
return new DequeIterator(this.M - 1, this, 1);
|
||||
};
|
||||
Deque.prototype.rEnd = function() {
|
||||
return new DequeIterator(-1, this, 1);
|
||||
};
|
||||
Deque.prototype.front = function() {
|
||||
if (this.M === 0) return;
|
||||
return this.j[this.A][this.S];
|
||||
};
|
||||
Deque.prototype.back = function() {
|
||||
if (this.M === 0) return;
|
||||
return this.j[this.R][this.k];
|
||||
};
|
||||
Deque.prototype.pushBack = function(t) {
|
||||
if (this.M) {
|
||||
if (this.k < this.B - 1) {
|
||||
this.k += 1;
|
||||
} else if (this.R < this.C - 1) {
|
||||
this.R += 1;
|
||||
this.k = 0;
|
||||
} else {
|
||||
this.R = 0;
|
||||
this.k = 0;
|
||||
}
|
||||
if (this.R === this.A && this.k === this.S) this.O();
|
||||
}
|
||||
this.M += 1;
|
||||
this.j[this.R][this.k] = t;
|
||||
return this.M;
|
||||
};
|
||||
Deque.prototype.popBack = function() {
|
||||
if (this.M === 0) return;
|
||||
var t = this.j[this.R][this.k];
|
||||
if (this.M !== 1) {
|
||||
if (this.k > 0) {
|
||||
this.k -= 1;
|
||||
} else if (this.R > 0) {
|
||||
this.R -= 1;
|
||||
this.k = this.B - 1;
|
||||
} else {
|
||||
this.R = this.C - 1;
|
||||
this.k = this.B - 1;
|
||||
}
|
||||
}
|
||||
this.M -= 1;
|
||||
return t;
|
||||
};
|
||||
Deque.prototype.pushFront = function(t) {
|
||||
if (this.M) {
|
||||
if (this.S > 0) {
|
||||
this.S -= 1;
|
||||
} else if (this.A > 0) {
|
||||
this.A -= 1;
|
||||
this.S = this.B - 1;
|
||||
} else {
|
||||
this.A = this.C - 1;
|
||||
this.S = this.B - 1;
|
||||
}
|
||||
if (this.A === this.R && this.S === this.k) this.O();
|
||||
}
|
||||
this.M += 1;
|
||||
this.j[this.A][this.S] = t;
|
||||
return this.M;
|
||||
};
|
||||
Deque.prototype.popFront = function() {
|
||||
if (this.M === 0) return;
|
||||
var t = this.j[this.A][this.S];
|
||||
if (this.M !== 1) {
|
||||
if (this.S < this.B - 1) {
|
||||
this.S += 1;
|
||||
} else if (this.A < this.C - 1) {
|
||||
this.A += 1;
|
||||
this.S = 0;
|
||||
} else {
|
||||
this.A = 0;
|
||||
this.S = 0;
|
||||
}
|
||||
}
|
||||
this.M -= 1;
|
||||
return t;
|
||||
};
|
||||
Deque.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var i = this.T(t), r = i.curNodeBucketIndex, e = i.curNodePointerIndex;
|
||||
return this.j[r][e];
|
||||
};
|
||||
Deque.prototype.setElementByPos = function(t, i) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var r = this.T(t), e = r.curNodeBucketIndex, s = r.curNodePointerIndex;
|
||||
this.j[e][s] = i;
|
||||
};
|
||||
Deque.prototype.insert = function(t, i, r) {
|
||||
if (r === void 0) {
|
||||
r = 1;
|
||||
}
|
||||
if (t < 0 || t > this.M) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) {
|
||||
while (r--) this.pushFront(i);
|
||||
} else if (t === this.M) {
|
||||
while (r--) this.pushBack(i);
|
||||
} else {
|
||||
var e = [];
|
||||
for (var s = t; s < this.M; ++s) {
|
||||
e.push(this.getElementByPos(s));
|
||||
}
|
||||
this.cut(t - 1);
|
||||
for (var s = 0; s < r; ++s) this.pushBack(i);
|
||||
for (var s = 0; s < e.length; ++s) this.pushBack(e[s]);
|
||||
}
|
||||
return this.M;
|
||||
};
|
||||
Deque.prototype.cut = function(t) {
|
||||
if (t < 0) {
|
||||
this.clear();
|
||||
return 0;
|
||||
}
|
||||
var i = this.T(t), r = i.curNodeBucketIndex, e = i.curNodePointerIndex;
|
||||
this.R = r;
|
||||
this.k = e;
|
||||
this.M = t + 1;
|
||||
return this.M;
|
||||
};
|
||||
Deque.prototype.eraseElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) this.popFront(); else if (t === this.M - 1) this.popBack(); else {
|
||||
var i = [];
|
||||
for (var r = t + 1; r < this.M; ++r) {
|
||||
i.push(this.getElementByPos(r));
|
||||
}
|
||||
this.cut(t);
|
||||
this.popBack();
|
||||
var e = this;
|
||||
i.forEach((function(t) {
|
||||
e.pushBack(t);
|
||||
}));
|
||||
}
|
||||
return this.M;
|
||||
};
|
||||
Deque.prototype.eraseElementByValue = function(t) {
|
||||
if (this.M === 0) return 0;
|
||||
var i = [];
|
||||
for (var r = 0; r < this.M; ++r) {
|
||||
var e = this.getElementByPos(r);
|
||||
if (e !== t) i.push(e);
|
||||
}
|
||||
var s = i.length;
|
||||
for (var r = 0; r < s; ++r) this.setElementByPos(r, i[r]);
|
||||
return this.cut(s - 1);
|
||||
};
|
||||
Deque.prototype.eraseElementByIterator = function(t) {
|
||||
var i = t.o;
|
||||
this.eraseElementByPos(i);
|
||||
t = t.next();
|
||||
return t;
|
||||
};
|
||||
Deque.prototype.find = function(t) {
|
||||
for (var i = 0; i < this.M; ++i) {
|
||||
if (this.getElementByPos(i) === t) {
|
||||
return new DequeIterator(i, this);
|
||||
}
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
Deque.prototype.reverse = function() {
|
||||
var t = 0;
|
||||
var i = this.M - 1;
|
||||
while (t < i) {
|
||||
var r = this.getElementByPos(t);
|
||||
this.setElementByPos(t, this.getElementByPos(i));
|
||||
this.setElementByPos(i, r);
|
||||
t += 1;
|
||||
i -= 1;
|
||||
}
|
||||
};
|
||||
Deque.prototype.unique = function() {
|
||||
if (this.M <= 1) {
|
||||
return this.M;
|
||||
}
|
||||
var t = 1;
|
||||
var i = this.getElementByPos(0);
|
||||
for (var r = 1; r < this.M; ++r) {
|
||||
var e = this.getElementByPos(r);
|
||||
if (e !== i) {
|
||||
i = e;
|
||||
this.setElementByPos(t++, e);
|
||||
}
|
||||
}
|
||||
while (this.M > t) this.popBack();
|
||||
return this.M;
|
||||
};
|
||||
Deque.prototype.sort = function(t) {
|
||||
var i = [];
|
||||
for (var r = 0; r < this.M; ++r) {
|
||||
i.push(this.getElementByPos(r));
|
||||
}
|
||||
i.sort(t);
|
||||
for (var r = 0; r < this.M; ++r) this.setElementByPos(r, i[r]);
|
||||
};
|
||||
Deque.prototype.shrinkToFit = function() {
|
||||
if (this.M === 0) return;
|
||||
var t = [];
|
||||
this.forEach((function(i) {
|
||||
t.push(i);
|
||||
}));
|
||||
this.C = Math.max(Math.ceil(this.M / this.B), 1);
|
||||
this.M = this.A = this.R = this.S = this.k = 0;
|
||||
this.j = [];
|
||||
for (var i = 0; i < this.C; ++i) {
|
||||
this.j.push(new Array(this.B));
|
||||
}
|
||||
for (var i = 0; i < t.length; ++i) this.pushBack(t[i]);
|
||||
};
|
||||
Deque.prototype.forEach = function(t) {
|
||||
for (var i = 0; i < this.M; ++i) {
|
||||
t(this.getElementByPos(i), i, this);
|
||||
}
|
||||
};
|
||||
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.M)) 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;
|
||||
//# sourceMappingURL=Deque.js.map
|
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
58
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.d.ts
generated
vendored
Normal file
58
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { ContainerIterator, initContainer } from "../ContainerBase";
|
||||
declare class LinkListIterator<T> extends ContainerIterator<T> {
|
||||
readonly container: LinkList<T>;
|
||||
get pointer(): T;
|
||||
set pointer(newValue: T);
|
||||
copy(): LinkListIterator<T>;
|
||||
equals(iter: LinkListIterator<T>): boolean;
|
||||
pre(): this;
|
||||
next(): this;
|
||||
}
|
||||
export type { LinkListIterator };
|
||||
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;
|
||||
getElementByPos(pos: number): T;
|
||||
eraseElementByPos(pos: number): number;
|
||||
eraseElementByValue(_value: T): number;
|
||||
eraseElementByIterator(iter: LinkListIterator<T>): LinkListIterator<T>;
|
||||
pushBack(element: T): number;
|
||||
popBack(): T | undefined;
|
||||
/**
|
||||
* @description Push an element to the front.
|
||||
* @param element - The element you want to push.
|
||||
* @returns The size of queue after pushing.
|
||||
*/
|
||||
pushFront(element: T): number;
|
||||
/**
|
||||
* @description Removes the first element.
|
||||
* @returns The element you popped.
|
||||
*/
|
||||
popFront(): T | undefined;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): number;
|
||||
find(element: T): LinkListIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): number;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
/**
|
||||
* @description Merges two sorted lists.
|
||||
* @param list - The other list you want to merge (must be sorted).
|
||||
* @returns The size of list after merging.
|
||||
* @example
|
||||
* const linkA = new LinkList([1, 3, 5]);
|
||||
* const linkB = new LinkList([2, 4, 6]);
|
||||
* linkA.merge(linkB); // [1, 2, 3, 4, 5];
|
||||
*/
|
||||
merge(list: LinkList<T>): number;
|
||||
forEach(callback: (element: T, index: number, list: LinkList<T>) => void): void;
|
||||
[Symbol.iterator](): Generator<T, void, unknown>;
|
||||
}
|
||||
export default LinkList;
|
456
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js
generated
vendored
Normal file
456
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js
generated
vendored
Normal file
@@ -0,0 +1,456 @@
|
||||
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 r in i) if (Object.prototype.hasOwnProperty.call(i, r)) t[r] = i[r];
|
||||
};
|
||||
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 r = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (e[0] & 1) throw e[1];
|
||||
return e[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, n, s, e, h;
|
||||
return h = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (h[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), h;
|
||||
function verb(t) {
|
||||
return function(i) {
|
||||
return step([ t, i ]);
|
||||
};
|
||||
}
|
||||
function step(h) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (r) try {
|
||||
if (n = 1, s && (e = h[0] & 2 ? s["return"] : h[0] ? s["throw"] || ((e = s["return"]) && e.call(s),
|
||||
0) : s.next) && !(e = e.call(s, h[1])).done) return e;
|
||||
if (s = 0, e) h = [ h[0] & 2, e.value ];
|
||||
switch (h[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
e = h;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
r.label++;
|
||||
return {
|
||||
value: h[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
r.label++;
|
||||
s = h[1];
|
||||
h = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
h = r.ops.pop();
|
||||
r.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(e = r.trys, e = e.length > 0 && e[e.length - 1]) && (h[0] === 6 || h[0] === 2)) {
|
||||
r = 0;
|
||||
continue;
|
||||
}
|
||||
if (h[0] === 3 && (!e || h[1] > e[0] && h[1] < e[3])) {
|
||||
r.label = h[1];
|
||||
break;
|
||||
}
|
||||
if (h[0] === 6 && r.label < e[1]) {
|
||||
r.label = e[1];
|
||||
e = h;
|
||||
break;
|
||||
}
|
||||
if (e && r.label < e[2]) {
|
||||
r.label = e[2];
|
||||
r.ops.push(h);
|
||||
break;
|
||||
}
|
||||
if (e[2]) r.ops.pop();
|
||||
r.trys.pop();
|
||||
continue;
|
||||
}
|
||||
h = i.call(t, r);
|
||||
} catch (t) {
|
||||
h = [ 6, t ];
|
||||
s = 0;
|
||||
} finally {
|
||||
n = e = 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";
|
||||
|
||||
import { throwIteratorAccessError } from "../../utils/throwError";
|
||||
|
||||
var LinkListIterator = function(t) {
|
||||
__extends(LinkListIterator, t);
|
||||
function LinkListIterator(i, r, n, s) {
|
||||
var e = t.call(this, s) || this;
|
||||
e.o = i;
|
||||
e.h = r;
|
||||
e.container = n;
|
||||
if (e.iteratorType === 0) {
|
||||
e.pre = function() {
|
||||
if (this.o.L === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.L;
|
||||
return this;
|
||||
};
|
||||
e.next = function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.m;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
e.pre = function() {
|
||||
if (this.o.m === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.m;
|
||||
return this;
|
||||
};
|
||||
e.next = function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.L;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return e;
|
||||
}
|
||||
Object.defineProperty(LinkListIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
return this.o.p;
|
||||
},
|
||||
set: function(t) {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o.p = t;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
LinkListIterator.prototype.copy = function() {
|
||||
return new LinkListIterator(this.o, this.h, this.container, this.iteratorType);
|
||||
};
|
||||
return LinkListIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
var LinkList = function(t) {
|
||||
__extends(LinkList, t);
|
||||
function LinkList(i) {
|
||||
if (i === void 0) {
|
||||
i = [];
|
||||
}
|
||||
var r = t.call(this) || this;
|
||||
r.h = {};
|
||||
r.H = r.l = r.h.L = r.h.m = r.h;
|
||||
var n = r;
|
||||
i.forEach((function(t) {
|
||||
n.pushBack(t);
|
||||
}));
|
||||
return r;
|
||||
}
|
||||
LinkList.prototype.G = function(t) {
|
||||
var i = t.L, r = t.m;
|
||||
i.m = r;
|
||||
r.L = i;
|
||||
if (t === this.H) {
|
||||
this.H = r;
|
||||
}
|
||||
if (t === this.l) {
|
||||
this.l = i;
|
||||
}
|
||||
this.M -= 1;
|
||||
};
|
||||
LinkList.prototype.F = function(t, i) {
|
||||
var r = i.m;
|
||||
var n = {
|
||||
p: t,
|
||||
L: i,
|
||||
m: r
|
||||
};
|
||||
i.m = n;
|
||||
r.L = n;
|
||||
if (i === this.h) {
|
||||
this.H = n;
|
||||
}
|
||||
if (r === this.h) {
|
||||
this.l = n;
|
||||
}
|
||||
this.M += 1;
|
||||
};
|
||||
LinkList.prototype.clear = function() {
|
||||
this.M = 0;
|
||||
this.H = this.l = this.h.L = this.h.m = this.h;
|
||||
};
|
||||
LinkList.prototype.begin = function() {
|
||||
return new LinkListIterator(this.H, this.h, this);
|
||||
};
|
||||
LinkList.prototype.end = function() {
|
||||
return new LinkListIterator(this.h, this.h, this);
|
||||
};
|
||||
LinkList.prototype.rBegin = function() {
|
||||
return new LinkListIterator(this.l, this.h, this, 1);
|
||||
};
|
||||
LinkList.prototype.rEnd = function() {
|
||||
return new LinkListIterator(this.h, this.h, this, 1);
|
||||
};
|
||||
LinkList.prototype.front = function() {
|
||||
return this.H.p;
|
||||
};
|
||||
LinkList.prototype.back = function() {
|
||||
return this.l.p;
|
||||
};
|
||||
LinkList.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var i = this.H;
|
||||
while (t--) {
|
||||
i = i.m;
|
||||
}
|
||||
return i.p;
|
||||
};
|
||||
LinkList.prototype.eraseElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var i = this.H;
|
||||
while (t--) {
|
||||
i = i.m;
|
||||
}
|
||||
this.G(i);
|
||||
return this.M;
|
||||
};
|
||||
LinkList.prototype.eraseElementByValue = function(t) {
|
||||
var i = this.H;
|
||||
while (i !== this.h) {
|
||||
if (i.p === t) {
|
||||
this.G(i);
|
||||
}
|
||||
i = i.m;
|
||||
}
|
||||
return this.M;
|
||||
};
|
||||
LinkList.prototype.eraseElementByIterator = function(t) {
|
||||
var i = t.o;
|
||||
if (i === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
t = t.next();
|
||||
this.G(i);
|
||||
return t;
|
||||
};
|
||||
LinkList.prototype.pushBack = function(t) {
|
||||
this.F(t, this.l);
|
||||
return this.M;
|
||||
};
|
||||
LinkList.prototype.popBack = function() {
|
||||
if (this.M === 0) return;
|
||||
var t = this.l.p;
|
||||
this.G(this.l);
|
||||
return t;
|
||||
};
|
||||
LinkList.prototype.pushFront = function(t) {
|
||||
this.F(t, this.h);
|
||||
return this.M;
|
||||
};
|
||||
LinkList.prototype.popFront = function() {
|
||||
if (this.M === 0) return;
|
||||
var t = this.H.p;
|
||||
this.G(this.H);
|
||||
return t;
|
||||
};
|
||||
LinkList.prototype.setElementByPos = function(t, i) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var r = this.H;
|
||||
while (t--) {
|
||||
r = r.m;
|
||||
}
|
||||
r.p = i;
|
||||
};
|
||||
LinkList.prototype.insert = function(t, i, r) {
|
||||
if (r === void 0) {
|
||||
r = 1;
|
||||
}
|
||||
if (t < 0 || t > this.M) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (r <= 0) return this.M;
|
||||
if (t === 0) {
|
||||
while (r--) this.pushFront(i);
|
||||
} else if (t === this.M) {
|
||||
while (r--) this.pushBack(i);
|
||||
} else {
|
||||
var n = this.H;
|
||||
for (var s = 1; s < t; ++s) {
|
||||
n = n.m;
|
||||
}
|
||||
var e = n.m;
|
||||
this.M += r;
|
||||
while (r--) {
|
||||
n.m = {
|
||||
p: i,
|
||||
L: n
|
||||
};
|
||||
n.m.L = n;
|
||||
n = n.m;
|
||||
}
|
||||
n.m = e;
|
||||
e.L = n;
|
||||
}
|
||||
return this.M;
|
||||
};
|
||||
LinkList.prototype.find = function(t) {
|
||||
var i = this.H;
|
||||
while (i !== this.h) {
|
||||
if (i.p === t) {
|
||||
return new LinkListIterator(i, this.h, this);
|
||||
}
|
||||
i = i.m;
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
LinkList.prototype.reverse = function() {
|
||||
if (this.M <= 1) return;
|
||||
var t = this.H;
|
||||
var i = this.l;
|
||||
var r = 0;
|
||||
while (r << 1 < this.M) {
|
||||
var n = t.p;
|
||||
t.p = i.p;
|
||||
i.p = n;
|
||||
t = t.m;
|
||||
i = i.L;
|
||||
r += 1;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.unique = function() {
|
||||
if (this.M <= 1) {
|
||||
return this.M;
|
||||
}
|
||||
var t = this.H;
|
||||
while (t !== this.h) {
|
||||
var i = t;
|
||||
while (i.m !== this.h && i.p === i.m.p) {
|
||||
i = i.m;
|
||||
this.M -= 1;
|
||||
}
|
||||
t.m = i.m;
|
||||
t.m.L = t;
|
||||
t = t.m;
|
||||
}
|
||||
return this.M;
|
||||
};
|
||||
LinkList.prototype.sort = function(t) {
|
||||
if (this.M <= 1) return;
|
||||
var i = [];
|
||||
this.forEach((function(t) {
|
||||
i.push(t);
|
||||
}));
|
||||
i.sort(t);
|
||||
var r = this.H;
|
||||
i.forEach((function(t) {
|
||||
r.p = t;
|
||||
r = r.m;
|
||||
}));
|
||||
};
|
||||
LinkList.prototype.merge = function(t) {
|
||||
var i = this;
|
||||
if (this.M === 0) {
|
||||
t.forEach((function(t) {
|
||||
i.pushBack(t);
|
||||
}));
|
||||
} else {
|
||||
var r = this.H;
|
||||
t.forEach((function(t) {
|
||||
while (r !== i.h && r.p <= t) {
|
||||
r = r.m;
|
||||
}
|
||||
i.F(t, r.L);
|
||||
}));
|
||||
}
|
||||
return this.M;
|
||||
};
|
||||
LinkList.prototype.forEach = function(t) {
|
||||
var i = this.H;
|
||||
var r = 0;
|
||||
while (i !== this.h) {
|
||||
t(i.p, r++, this);
|
||||
i = i.m;
|
||||
}
|
||||
};
|
||||
LinkList.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var t;
|
||||
return __generator(this, (function(i) {
|
||||
switch (i.label) {
|
||||
case 0:
|
||||
if (this.M === 0) return [ 2 ];
|
||||
t = this.H;
|
||||
i.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(t !== this.h)) return [ 3, 3 ];
|
||||
return [ 4, t.p ];
|
||||
|
||||
case 2:
|
||||
i.sent();
|
||||
t = t.m;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 3:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return LinkList;
|
||||
}(SequentialContainer);
|
||||
|
||||
export default LinkList;
|
||||
//# sourceMappingURL=LinkList.js.map
|
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
40
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.d.ts
generated
vendored
Normal file
40
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { initContainer, IteratorType } from "../ContainerBase";
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
declare class VectorIterator<T> extends RandomIterator<T> {
|
||||
container: Vector<T>;
|
||||
constructor(node: number, container: Vector<T>, iteratorType?: IteratorType);
|
||||
copy(): VectorIterator<T>;
|
||||
equals(iter: VectorIterator<T>): boolean;
|
||||
}
|
||||
export type { VectorIterator };
|
||||
declare class Vector<T> extends SequentialContainer<T> {
|
||||
/**
|
||||
* @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;
|
||||
getElementByPos(pos: number): T;
|
||||
eraseElementByPos(pos: number): number;
|
||||
eraseElementByValue(value: T): number;
|
||||
eraseElementByIterator(iter: VectorIterator<T>): VectorIterator<T>;
|
||||
pushBack(element: T): number;
|
||||
popBack(): T | undefined;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): number;
|
||||
find(element: T): VectorIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): number;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
forEach(callback: (element: T, index: number, vector: Vector<T>) => void): void;
|
||||
[Symbol.iterator](): Generator<T, void, undefined>;
|
||||
}
|
||||
export default Vector;
|
323
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js
generated
vendored
Normal file
323
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js
generated
vendored
Normal file
@@ -0,0 +1,323 @@
|
||||
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, u;
|
||||
return u = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (u[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), u;
|
||||
function verb(t) {
|
||||
return function(r) {
|
||||
return step([ t, r ]);
|
||||
};
|
||||
}
|
||||
function step(u) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (e) 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:
|
||||
e.label++;
|
||||
return {
|
||||
value: u[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
e.label++;
|
||||
i = u[1];
|
||||
u = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
u = e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(o = e.trys, o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
|
||||
e = 0;
|
||||
continue;
|
||||
}
|
||||
if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
|
||||
e.label = u[1];
|
||||
break;
|
||||
}
|
||||
if (u[0] === 6 && e.label < o[1]) {
|
||||
e.label = o[1];
|
||||
o = u;
|
||||
break;
|
||||
}
|
||||
if (o && e.label < o[2]) {
|
||||
e.label = o[2];
|
||||
e.ops.push(u);
|
||||
break;
|
||||
}
|
||||
if (o[2]) e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
}
|
||||
u = r.call(t, e);
|
||||
} catch (t) {
|
||||
u = [ 6, t ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = o = 0;
|
||||
}
|
||||
if (u[0] & 5) throw u[1];
|
||||
return {
|
||||
value: u[0] ? u[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __read = this && this.q || function(t, r) {
|
||||
var e = typeof Symbol === "function" && t[Symbol.iterator];
|
||||
if (!e) return t;
|
||||
var n = e.call(t), i, o = [], u;
|
||||
try {
|
||||
while ((r === void 0 || r-- > 0) && !(i = n.next()).done) o.push(i.value);
|
||||
} catch (t) {
|
||||
u = {
|
||||
error: t
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (i && !i.done && (e = n["return"])) e.call(n);
|
||||
} finally {
|
||||
if (u) throw u.error;
|
||||
}
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
var __spreadArray = this && this.D || 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.V || 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(r, e, n) {
|
||||
var i = t.call(this, r, n) || this;
|
||||
i.container = e;
|
||||
return i;
|
||||
}
|
||||
VectorIterator.prototype.copy = function() {
|
||||
return new VectorIterator(this.o, this.container, this.iteratorType);
|
||||
};
|
||||
return VectorIterator;
|
||||
}(RandomIterator);
|
||||
|
||||
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.J = e ? __spreadArray([], __read(r), false) : r;
|
||||
n.M = r.length;
|
||||
} else {
|
||||
n.J = [];
|
||||
var i = n;
|
||||
r.forEach((function(t) {
|
||||
i.pushBack(t);
|
||||
}));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
Vector.prototype.clear = function() {
|
||||
this.M = 0;
|
||||
this.J.length = 0;
|
||||
};
|
||||
Vector.prototype.begin = function() {
|
||||
return new VectorIterator(0, this);
|
||||
};
|
||||
Vector.prototype.end = function() {
|
||||
return new VectorIterator(this.M, this);
|
||||
};
|
||||
Vector.prototype.rBegin = function() {
|
||||
return new VectorIterator(this.M - 1, this, 1);
|
||||
};
|
||||
Vector.prototype.rEnd = function() {
|
||||
return new VectorIterator(-1, this, 1);
|
||||
};
|
||||
Vector.prototype.front = function() {
|
||||
return this.J[0];
|
||||
};
|
||||
Vector.prototype.back = function() {
|
||||
return this.J[this.M - 1];
|
||||
};
|
||||
Vector.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
return this.J[t];
|
||||
};
|
||||
Vector.prototype.eraseElementByPos = function(t) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.J.splice(t, 1);
|
||||
this.M -= 1;
|
||||
return this.M;
|
||||
};
|
||||
Vector.prototype.eraseElementByValue = function(t) {
|
||||
var r = 0;
|
||||
for (var e = 0; e < this.M; ++e) {
|
||||
if (this.J[e] !== t) {
|
||||
this.J[r++] = this.J[e];
|
||||
}
|
||||
}
|
||||
this.M = this.J.length = r;
|
||||
return this.M;
|
||||
};
|
||||
Vector.prototype.eraseElementByIterator = function(t) {
|
||||
var r = t.o;
|
||||
t = t.next();
|
||||
this.eraseElementByPos(r);
|
||||
return t;
|
||||
};
|
||||
Vector.prototype.pushBack = function(t) {
|
||||
this.J.push(t);
|
||||
this.M += 1;
|
||||
return this.M;
|
||||
};
|
||||
Vector.prototype.popBack = function() {
|
||||
if (this.M === 0) return;
|
||||
this.M -= 1;
|
||||
return this.J.pop();
|
||||
};
|
||||
Vector.prototype.setElementByPos = function(t, r) {
|
||||
if (t < 0 || t > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.J[t] = r;
|
||||
};
|
||||
Vector.prototype.insert = function(t, r, e) {
|
||||
var n;
|
||||
if (e === void 0) {
|
||||
e = 1;
|
||||
}
|
||||
if (t < 0 || t > this.M) {
|
||||
throw new RangeError;
|
||||
}
|
||||
(n = this.J).splice.apply(n, __spreadArray([ t, 0 ], __read(new Array(e).fill(r)), false));
|
||||
this.M += e;
|
||||
return this.M;
|
||||
};
|
||||
Vector.prototype.find = function(t) {
|
||||
for (var r = 0; r < this.M; ++r) {
|
||||
if (this.J[r] === t) {
|
||||
return new VectorIterator(r, this);
|
||||
}
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
Vector.prototype.reverse = function() {
|
||||
this.J.reverse();
|
||||
};
|
||||
Vector.prototype.unique = function() {
|
||||
var t = 1;
|
||||
for (var r = 1; r < this.M; ++r) {
|
||||
if (this.J[r] !== this.J[r - 1]) {
|
||||
this.J[t++] = this.J[r];
|
||||
}
|
||||
}
|
||||
this.M = this.J.length = t;
|
||||
return this.M;
|
||||
};
|
||||
Vector.prototype.sort = function(t) {
|
||||
this.J.sort(t);
|
||||
};
|
||||
Vector.prototype.forEach = function(t) {
|
||||
for (var r = 0; r < this.M; ++r) {
|
||||
t(this.J[r], r, this);
|
||||
}
|
||||
};
|
||||
Vector.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
return __generator(this, (function(t) {
|
||||
switch (t.label) {
|
||||
case 0:
|
||||
return [ 5, __values(this.J) ];
|
||||
|
||||
case 1:
|
||||
t.sent();
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return Vector;
|
||||
}(SequentialContainer);
|
||||
|
||||
export default Vector;
|
||||
//# sourceMappingURL=Vector.js.map
|
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.d.ts
generated
vendored
Normal file
18
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
import TreeContainer from "./index";
|
||||
declare abstract class TreeIterator<K, V> extends ContainerIterator<K | [K, V]> {
|
||||
abstract readonly container: TreeContainer<K, V>;
|
||||
/**
|
||||
* @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`.
|
||||
* @returns The index subscript of the node in the tree.
|
||||
* @example
|
||||
* const st = new OrderedSet([1, 2, 3], true);
|
||||
* console.log(st.begin().next().index); // 1
|
||||
*/
|
||||
get index(): number;
|
||||
pre(): this;
|
||||
next(): this;
|
||||
}
|
||||
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(r, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(r, t) {
|
||||
r.__proto__ = t;
|
||||
} || function(r, t) {
|
||||
for (var e in t) if (Object.prototype.hasOwnProperty.call(t, e)) r[e] = t[e];
|
||||
};
|
||||
return extendStatics(r, t);
|
||||
};
|
||||
return function(r, t) {
|
||||
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
||||
extendStatics(r, t);
|
||||
function __() {
|
||||
this.constructor = r;
|
||||
}
|
||||
r.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
|
||||
import { throwIteratorAccessError } from "../../../utils/throwError";
|
||||
|
||||
var TreeIterator = function(r) {
|
||||
__extends(TreeIterator, r);
|
||||
function TreeIterator(t, e, i) {
|
||||
var n = r.call(this, i) || this;
|
||||
n.o = t;
|
||||
n.h = e;
|
||||
if (n.iteratorType === 0) {
|
||||
n.pre = function() {
|
||||
if (this.o === this.h.K) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.L();
|
||||
return this;
|
||||
};
|
||||
n.next = function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.m();
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
n.pre = function() {
|
||||
if (this.o === this.h.N) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.m();
|
||||
return this;
|
||||
};
|
||||
n.next = function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
this.o = this.o.L();
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return n;
|
||||
}
|
||||
Object.defineProperty(TreeIterator.prototype, "index", {
|
||||
get: function() {
|
||||
var r = this.o;
|
||||
var t = this.h.rr;
|
||||
if (r === this.h) {
|
||||
if (t) {
|
||||
return t.tr - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
var e = 0;
|
||||
if (r.K) {
|
||||
e += r.K.tr;
|
||||
}
|
||||
while (r !== t) {
|
||||
var i = r.rr;
|
||||
if (r === i.N) {
|
||||
e += 1;
|
||||
if (i.K) {
|
||||
e += i.K.tr;
|
||||
}
|
||||
}
|
||||
r = i;
|
||||
}
|
||||
return e;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return TreeIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
export default TreeIterator;
|
||||
//# sourceMappingURL=TreeIterator.js.map
|
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
47
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.d.ts
generated
vendored
Normal file
47
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
export declare const enum TreeNodeColor {
|
||||
RED = 1,
|
||||
BLACK = 0
|
||||
}
|
||||
export declare class TreeNode<K, V> {
|
||||
_color: TreeNodeColor;
|
||||
_key: K | undefined;
|
||||
_value: V | undefined;
|
||||
_left: TreeNode<K, V> | undefined;
|
||||
_right: TreeNode<K, V> | undefined;
|
||||
_parent: TreeNode<K, V> | undefined;
|
||||
constructor(key?: K, value?: V);
|
||||
/**
|
||||
* @description Get the pre node.
|
||||
* @returns TreeNode about the pre node.
|
||||
*/
|
||||
_pre(): TreeNode<K, V>;
|
||||
/**
|
||||
* @description Get the next node.
|
||||
* @returns TreeNode about the next node.
|
||||
*/
|
||||
_next(): TreeNode<K, V>;
|
||||
/**
|
||||
* @description Rotate left.
|
||||
* @returns TreeNode about moved to original position after rotation.
|
||||
*/
|
||||
_rotateLeft(): TreeNode<K, V>;
|
||||
/**
|
||||
* @description Rotate right.
|
||||
* @returns TreeNode about moved to original position after rotation.
|
||||
*/
|
||||
_rotateRight(): TreeNode<K, V>;
|
||||
}
|
||||
export declare class TreeNodeEnableIndex<K, V> extends TreeNode<K, V> {
|
||||
_subTreeSize: number;
|
||||
/**
|
||||
* @description Rotate left and do recount.
|
||||
* @returns TreeNode about moved to original position after rotation.
|
||||
*/
|
||||
_rotateLeft(): TreeNodeEnableIndex<K, V>;
|
||||
/**
|
||||
* @description Rotate right and do recount.
|
||||
* @returns TreeNode about moved to original position after rotation.
|
||||
*/
|
||||
_rotateRight(): TreeNodeEnableIndex<K, V>;
|
||||
_recount(): void;
|
||||
}
|
132
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js
generated
vendored
Normal file
132
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
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 t in n) if (Object.prototype.hasOwnProperty.call(n, t)) e[t] = n[t];
|
||||
};
|
||||
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.u = undefined;
|
||||
this.p = undefined;
|
||||
this.K = undefined;
|
||||
this.N = undefined;
|
||||
this.rr = undefined;
|
||||
this.u = e;
|
||||
this.p = n;
|
||||
}
|
||||
TreeNode.prototype.L = function() {
|
||||
var e = this;
|
||||
if (e.ee === 1 && e.rr.rr === e) {
|
||||
e = e.N;
|
||||
} else if (e.K) {
|
||||
e = e.K;
|
||||
while (e.N) {
|
||||
e = e.N;
|
||||
}
|
||||
} else {
|
||||
var n = e.rr;
|
||||
while (n.K === e) {
|
||||
e = n;
|
||||
n = e.rr;
|
||||
}
|
||||
e = n;
|
||||
}
|
||||
return e;
|
||||
};
|
||||
TreeNode.prototype.m = function() {
|
||||
var e = this;
|
||||
if (e.N) {
|
||||
e = e.N;
|
||||
while (e.K) {
|
||||
e = e.K;
|
||||
}
|
||||
return e;
|
||||
} else {
|
||||
var n = e.rr;
|
||||
while (n.N === e) {
|
||||
e = n;
|
||||
n = e.rr;
|
||||
}
|
||||
if (e.N !== n) {
|
||||
return n;
|
||||
} else return e;
|
||||
}
|
||||
};
|
||||
TreeNode.prototype.ne = function() {
|
||||
var e = this.rr;
|
||||
var n = this.N;
|
||||
var t = n.K;
|
||||
if (e.rr === this) e.rr = n; else if (e.K === this) e.K = n; else e.N = n;
|
||||
n.rr = e;
|
||||
n.K = this;
|
||||
this.rr = n;
|
||||
this.N = t;
|
||||
if (t) t.rr = this;
|
||||
return n;
|
||||
};
|
||||
TreeNode.prototype.te = function() {
|
||||
var e = this.rr;
|
||||
var n = this.K;
|
||||
var t = n.N;
|
||||
if (e.rr === this) e.rr = n; else if (e.K === this) e.K = n; else e.N = n;
|
||||
n.rr = e;
|
||||
n.N = this;
|
||||
this.rr = n;
|
||||
this.K = t;
|
||||
if (t) t.rr = 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.tr = 1;
|
||||
return n;
|
||||
}
|
||||
TreeNodeEnableIndex.prototype.ne = function() {
|
||||
var n = e.prototype.ne.call(this);
|
||||
this.ie();
|
||||
n.ie();
|
||||
return n;
|
||||
};
|
||||
TreeNodeEnableIndex.prototype.te = function() {
|
||||
var n = e.prototype.te.call(this);
|
||||
this.ie();
|
||||
n.ie();
|
||||
return n;
|
||||
};
|
||||
TreeNodeEnableIndex.prototype.ie = function() {
|
||||
this.tr = 1;
|
||||
if (this.K) {
|
||||
this.tr += this.K.tr;
|
||||
}
|
||||
if (this.N) {
|
||||
this.tr += this.N.tr;
|
||||
}
|
||||
};
|
||||
return TreeNodeEnableIndex;
|
||||
}(TreeNode);
|
||||
|
||||
export { TreeNodeEnableIndex };
|
||||
//# sourceMappingURL=TreeNode.js.map
|
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
58
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.d.ts
generated
vendored
Normal file
58
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import type TreeIterator from './TreeIterator';
|
||||
import { Container } from "../../ContainerBase";
|
||||
declare abstract class TreeContainer<K, V> extends Container<K | [K, V]> {
|
||||
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.
|
||||
* @returns Whether the modification is successful.
|
||||
* @example
|
||||
* const st = new orderedSet([1, 2, 5]);
|
||||
* const iter = st.find(2);
|
||||
* st.updateKeyByIterator(iter, 3); // then st will become [1, 3, 5]
|
||||
*/
|
||||
updateKeyByIterator(iter: TreeIterator<K, V>, key: K): boolean;
|
||||
eraseElementByPos(pos: number): number;
|
||||
/**
|
||||
* @description Remove the element of the specified key.
|
||||
* @param key - The key you want to remove.
|
||||
* @returns Whether erase successfully.
|
||||
*/
|
||||
eraseElementByKey(key: K): boolean;
|
||||
eraseElementByIterator(iter: TreeIterator<K, V>): TreeIterator<K, V>;
|
||||
forEach(callback: (element: K | [K, V], index: number, tree: TreeContainer<K, V>) => void): void;
|
||||
getElementByPos(pos: number): K | [K, V];
|
||||
/**
|
||||
* @description Get the height of the tree.
|
||||
* @returns Number about the height of the RB-tree.
|
||||
*/
|
||||
getHeight(): number;
|
||||
/**
|
||||
* @param key - The given key you want to compare.
|
||||
* @returns 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.
|
||||
* @returns The size of the tree after union.
|
||||
*/
|
||||
abstract union(other: TreeContainer<K, V>): number;
|
||||
/**
|
||||
* @param key - The given key you want to compare.
|
||||
* @returns 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.
|
||||
* @returns 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.
|
||||
* @returns An iterator to the first element greater than the given key.
|
||||
*/
|
||||
abstract upperBound(key: K): TreeIterator<K, V>;
|
||||
}
|
||||
export default TreeContainer;
|
600
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.js
generated
vendored
Normal file
600
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.js
generated
vendored
Normal file
@@ -0,0 +1,600 @@
|
||||
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 i in r) if (Object.prototype.hasOwnProperty.call(r, i)) e[i] = r[i];
|
||||
};
|
||||
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 __read = this && this.q || function(e, r) {
|
||||
var i = typeof Symbol === "function" && e[Symbol.iterator];
|
||||
if (!i) return e;
|
||||
var t = i.call(e), n, s = [], f;
|
||||
try {
|
||||
while ((r === void 0 || r-- > 0) && !(n = t.next()).done) s.push(n.value);
|
||||
} catch (e) {
|
||||
f = {
|
||||
error: e
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (n && !n.done && (i = t["return"])) i.call(t);
|
||||
} finally {
|
||||
if (f) throw f.error;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
var __values = this && this.V || function(e) {
|
||||
var r = typeof Symbol === "function" && Symbol.iterator, i = r && e[r], t = 0;
|
||||
if (i) return i.call(e);
|
||||
if (e && typeof e.length === "number") return {
|
||||
next: function() {
|
||||
if (e && t >= e.length) e = void 0;
|
||||
return {
|
||||
value: e && e[t++],
|
||||
done: !e
|
||||
};
|
||||
}
|
||||
};
|
||||
throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
|
||||
import { TreeNode, TreeNodeEnableIndex } from "./TreeNode";
|
||||
|
||||
import { Container } from "../../ContainerBase";
|
||||
|
||||
import { throwIteratorAccessError } from "../../../utils/throwError";
|
||||
|
||||
var TreeContainer = function(e) {
|
||||
__extends(TreeContainer, e);
|
||||
function TreeContainer(r, i) {
|
||||
if (r === void 0) {
|
||||
r = function(e, r) {
|
||||
if (e < r) return -1;
|
||||
if (e > r) return 1;
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
if (i === void 0) {
|
||||
i = false;
|
||||
}
|
||||
var t = e.call(this) || this;
|
||||
t.W = undefined;
|
||||
t.$ = r;
|
||||
if (i) {
|
||||
t.re = TreeNodeEnableIndex;
|
||||
t.v = function(e, r, i) {
|
||||
var t = this.se(e, r, i);
|
||||
if (t) {
|
||||
var n = t.rr;
|
||||
while (n !== this.h) {
|
||||
n.tr += 1;
|
||||
n = n.rr;
|
||||
}
|
||||
var s = this.fe(t);
|
||||
if (s) {
|
||||
var f = s, h = f.parentNode, u = f.grandParent, a = f.curNode;
|
||||
h.ie();
|
||||
u.ie();
|
||||
a.ie();
|
||||
}
|
||||
}
|
||||
return this.M;
|
||||
};
|
||||
t.G = function(e) {
|
||||
var r = this.he(e);
|
||||
while (r !== this.h) {
|
||||
r.tr -= 1;
|
||||
r = r.rr;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
t.re = TreeNode;
|
||||
t.v = function(e, r, i) {
|
||||
var t = this.se(e, r, i);
|
||||
if (t) this.fe(t);
|
||||
return this.M;
|
||||
};
|
||||
t.G = t.he;
|
||||
}
|
||||
t.h = new t.re;
|
||||
return t;
|
||||
}
|
||||
TreeContainer.prototype.U = function(e, r) {
|
||||
var i = this.h;
|
||||
while (e) {
|
||||
var t = this.$(e.u, r);
|
||||
if (t < 0) {
|
||||
e = e.N;
|
||||
} else if (t > 0) {
|
||||
i = e;
|
||||
e = e.K;
|
||||
} else return e;
|
||||
}
|
||||
return i;
|
||||
};
|
||||
TreeContainer.prototype.X = function(e, r) {
|
||||
var i = this.h;
|
||||
while (e) {
|
||||
var t = this.$(e.u, r);
|
||||
if (t <= 0) {
|
||||
e = e.N;
|
||||
} else {
|
||||
i = e;
|
||||
e = e.K;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
TreeContainer.prototype.Y = function(e, r) {
|
||||
var i = this.h;
|
||||
while (e) {
|
||||
var t = this.$(e.u, r);
|
||||
if (t < 0) {
|
||||
i = e;
|
||||
e = e.N;
|
||||
} else if (t > 0) {
|
||||
e = e.K;
|
||||
} else return e;
|
||||
}
|
||||
return i;
|
||||
};
|
||||
TreeContainer.prototype.Z = function(e, r) {
|
||||
var i = this.h;
|
||||
while (e) {
|
||||
var t = this.$(e.u, r);
|
||||
if (t < 0) {
|
||||
i = e;
|
||||
e = e.N;
|
||||
} else {
|
||||
e = e.K;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
TreeContainer.prototype.ue = function(e) {
|
||||
while (true) {
|
||||
var r = e.rr;
|
||||
if (r === this.h) return;
|
||||
if (e.ee === 1) {
|
||||
e.ee = 0;
|
||||
return;
|
||||
}
|
||||
if (e === r.K) {
|
||||
var i = r.N;
|
||||
if (i.ee === 1) {
|
||||
i.ee = 0;
|
||||
r.ee = 1;
|
||||
if (r === this.W) {
|
||||
this.W = r.ne();
|
||||
} else r.ne();
|
||||
} else {
|
||||
if (i.N && i.N.ee === 1) {
|
||||
i.ee = r.ee;
|
||||
r.ee = 0;
|
||||
i.N.ee = 0;
|
||||
if (r === this.W) {
|
||||
this.W = r.ne();
|
||||
} else r.ne();
|
||||
return;
|
||||
} else if (i.K && i.K.ee === 1) {
|
||||
i.ee = 1;
|
||||
i.K.ee = 0;
|
||||
i.te();
|
||||
} else {
|
||||
i.ee = 1;
|
||||
e = r;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var i = r.K;
|
||||
if (i.ee === 1) {
|
||||
i.ee = 0;
|
||||
r.ee = 1;
|
||||
if (r === this.W) {
|
||||
this.W = r.te();
|
||||
} else r.te();
|
||||
} else {
|
||||
if (i.K && i.K.ee === 1) {
|
||||
i.ee = r.ee;
|
||||
r.ee = 0;
|
||||
i.K.ee = 0;
|
||||
if (r === this.W) {
|
||||
this.W = r.te();
|
||||
} else r.te();
|
||||
return;
|
||||
} else if (i.N && i.N.ee === 1) {
|
||||
i.ee = 1;
|
||||
i.N.ee = 0;
|
||||
i.ne();
|
||||
} else {
|
||||
i.ee = 1;
|
||||
e = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
TreeContainer.prototype.he = function(e) {
|
||||
var r, i;
|
||||
if (this.M === 1) {
|
||||
this.clear();
|
||||
return this.h;
|
||||
}
|
||||
var t = e;
|
||||
while (t.K || t.N) {
|
||||
if (t.N) {
|
||||
t = t.N;
|
||||
while (t.K) t = t.K;
|
||||
} else {
|
||||
t = t.K;
|
||||
}
|
||||
r = __read([ t.u, e.u ], 2), e.u = r[0], t.u = r[1];
|
||||
i = __read([ t.p, e.p ], 2), e.p = i[0], t.p = i[1];
|
||||
e = t;
|
||||
}
|
||||
if (this.h.K === t) {
|
||||
this.h.K = t.rr;
|
||||
} else if (this.h.N === t) {
|
||||
this.h.N = t.rr;
|
||||
}
|
||||
this.ue(t);
|
||||
var n = t.rr;
|
||||
if (t === n.K) {
|
||||
n.K = undefined;
|
||||
} else n.N = undefined;
|
||||
this.M -= 1;
|
||||
this.W.ee = 0;
|
||||
return n;
|
||||
};
|
||||
TreeContainer.prototype.ae = function(e, r) {
|
||||
if (e === undefined) return false;
|
||||
var i = this.ae(e.K, r);
|
||||
if (i) return true;
|
||||
if (r(e)) return true;
|
||||
return this.ae(e.N, r);
|
||||
};
|
||||
TreeContainer.prototype.fe = function(e) {
|
||||
while (true) {
|
||||
var r = e.rr;
|
||||
if (r.ee === 0) return;
|
||||
var i = r.rr;
|
||||
if (r === i.K) {
|
||||
var t = i.N;
|
||||
if (t && t.ee === 1) {
|
||||
t.ee = r.ee = 0;
|
||||
if (i === this.W) return;
|
||||
i.ee = 1;
|
||||
e = i;
|
||||
continue;
|
||||
} else if (e === r.N) {
|
||||
e.ee = 0;
|
||||
if (e.K) e.K.rr = r;
|
||||
if (e.N) e.N.rr = i;
|
||||
r.N = e.K;
|
||||
i.K = e.N;
|
||||
e.K = r;
|
||||
e.N = i;
|
||||
if (i === this.W) {
|
||||
this.W = e;
|
||||
this.h.rr = e;
|
||||
} else {
|
||||
var n = i.rr;
|
||||
if (n.K === i) {
|
||||
n.K = e;
|
||||
} else n.N = e;
|
||||
}
|
||||
e.rr = i.rr;
|
||||
r.rr = e;
|
||||
i.rr = e;
|
||||
i.ee = 1;
|
||||
return {
|
||||
parentNode: r,
|
||||
grandParent: i,
|
||||
curNode: e
|
||||
};
|
||||
} else {
|
||||
r.ee = 0;
|
||||
if (i === this.W) {
|
||||
this.W = i.te();
|
||||
} else i.te();
|
||||
i.ee = 1;
|
||||
}
|
||||
} else {
|
||||
var t = i.K;
|
||||
if (t && t.ee === 1) {
|
||||
t.ee = r.ee = 0;
|
||||
if (i === this.W) return;
|
||||
i.ee = 1;
|
||||
e = i;
|
||||
continue;
|
||||
} else if (e === r.K) {
|
||||
e.ee = 0;
|
||||
if (e.K) e.K.rr = i;
|
||||
if (e.N) e.N.rr = r;
|
||||
i.N = e.K;
|
||||
r.K = e.N;
|
||||
e.K = i;
|
||||
e.N = r;
|
||||
if (i === this.W) {
|
||||
this.W = e;
|
||||
this.h.rr = e;
|
||||
} else {
|
||||
var n = i.rr;
|
||||
if (n.K === i) {
|
||||
n.K = e;
|
||||
} else n.N = e;
|
||||
}
|
||||
e.rr = i.rr;
|
||||
r.rr = e;
|
||||
i.rr = e;
|
||||
i.ee = 1;
|
||||
return {
|
||||
parentNode: r,
|
||||
grandParent: i,
|
||||
curNode: e
|
||||
};
|
||||
} else {
|
||||
r.ee = 0;
|
||||
if (i === this.W) {
|
||||
this.W = i.ne();
|
||||
} else i.ne();
|
||||
i.ee = 1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
TreeContainer.prototype.se = function(e, r, i) {
|
||||
if (this.W === undefined) {
|
||||
this.M += 1;
|
||||
this.W = new this.re(e, r);
|
||||
this.W.ee = 0;
|
||||
this.W.rr = this.h;
|
||||
this.h.rr = this.W;
|
||||
this.h.K = this.W;
|
||||
this.h.N = this.W;
|
||||
return;
|
||||
}
|
||||
var t;
|
||||
var n = this.h.K;
|
||||
var s = this.$(n.u, e);
|
||||
if (s === 0) {
|
||||
n.p = r;
|
||||
return;
|
||||
} else if (s > 0) {
|
||||
n.K = new this.re(e, r);
|
||||
n.K.rr = n;
|
||||
t = n.K;
|
||||
this.h.K = t;
|
||||
} else {
|
||||
var f = this.h.N;
|
||||
var h = this.$(f.u, e);
|
||||
if (h === 0) {
|
||||
f.p = r;
|
||||
return;
|
||||
} else if (h < 0) {
|
||||
f.N = new this.re(e, r);
|
||||
f.N.rr = f;
|
||||
t = f.N;
|
||||
this.h.N = t;
|
||||
} else {
|
||||
if (i !== undefined) {
|
||||
var u = i.o;
|
||||
if (u !== this.h) {
|
||||
var a = this.$(u.u, e);
|
||||
if (a === 0) {
|
||||
u.p = r;
|
||||
return;
|
||||
} else if (a > 0) {
|
||||
var o = u.L();
|
||||
var l = this.$(o.u, e);
|
||||
if (l === 0) {
|
||||
o.p = r;
|
||||
return;
|
||||
} else if (l < 0) {
|
||||
t = new this.re(e, r);
|
||||
if (o.N === undefined) {
|
||||
o.N = t;
|
||||
t.rr = o;
|
||||
} else {
|
||||
u.K = t;
|
||||
t.rr = u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t === undefined) {
|
||||
t = this.W;
|
||||
while (true) {
|
||||
var v = this.$(t.u, e);
|
||||
if (v > 0) {
|
||||
if (t.K === undefined) {
|
||||
t.K = new this.re(e, r);
|
||||
t.K.rr = t;
|
||||
t = t.K;
|
||||
break;
|
||||
}
|
||||
t = t.K;
|
||||
} else if (v < 0) {
|
||||
if (t.N === undefined) {
|
||||
t.N = new this.re(e, r);
|
||||
t.N.rr = t;
|
||||
t = t.N;
|
||||
break;
|
||||
}
|
||||
t = t.N;
|
||||
} else {
|
||||
t.p = r;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.M += 1;
|
||||
return t;
|
||||
};
|
||||
TreeContainer.prototype.g = function(e, r) {
|
||||
while (e) {
|
||||
var i = this.$(e.u, r);
|
||||
if (i < 0) {
|
||||
e = e.N;
|
||||
} else if (i > 0) {
|
||||
e = e.K;
|
||||
} else return e;
|
||||
}
|
||||
return e || this.h;
|
||||
};
|
||||
TreeContainer.prototype.clear = function() {
|
||||
this.M = 0;
|
||||
this.W = undefined;
|
||||
this.h.rr = undefined;
|
||||
this.h.K = this.h.N = undefined;
|
||||
};
|
||||
TreeContainer.prototype.updateKeyByIterator = function(e, r) {
|
||||
var i = e.o;
|
||||
if (i === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
if (this.M === 1) {
|
||||
i.u = r;
|
||||
return true;
|
||||
}
|
||||
if (i === this.h.K) {
|
||||
if (this.$(i.m().u, r) > 0) {
|
||||
i.u = r;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (i === this.h.N) {
|
||||
if (this.$(i.L().u, r) < 0) {
|
||||
i.u = r;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var t = i.L().u;
|
||||
if (this.$(t, r) >= 0) return false;
|
||||
var n = i.m().u;
|
||||
if (this.$(n, r) <= 0) return false;
|
||||
i.u = r;
|
||||
return true;
|
||||
};
|
||||
TreeContainer.prototype.eraseElementByPos = function(e) {
|
||||
if (e < 0 || e > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var r = 0;
|
||||
var i = this;
|
||||
this.ae(this.W, (function(t) {
|
||||
if (e === r) {
|
||||
i.G(t);
|
||||
return true;
|
||||
}
|
||||
r += 1;
|
||||
return false;
|
||||
}));
|
||||
return this.M;
|
||||
};
|
||||
TreeContainer.prototype.eraseElementByKey = function(e) {
|
||||
if (this.M === 0) return false;
|
||||
var r = this.g(this.W, e);
|
||||
if (r === this.h) return false;
|
||||
this.G(r);
|
||||
return true;
|
||||
};
|
||||
TreeContainer.prototype.eraseElementByIterator = function(e) {
|
||||
var r = e.o;
|
||||
if (r === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
var i = r.N === undefined;
|
||||
var t = e.iteratorType === 0;
|
||||
if (t) {
|
||||
if (i) e.next();
|
||||
} else {
|
||||
if (!i || r.K === undefined) e.next();
|
||||
}
|
||||
this.G(r);
|
||||
return e;
|
||||
};
|
||||
TreeContainer.prototype.forEach = function(e) {
|
||||
var r, i;
|
||||
var t = 0;
|
||||
try {
|
||||
for (var n = __values(this), s = n.next(); !s.done; s = n.next()) {
|
||||
var f = s.value;
|
||||
e(f, t++, this);
|
||||
}
|
||||
} catch (e) {
|
||||
r = {
|
||||
error: e
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (s && !s.done && (i = n.return)) i.call(n);
|
||||
} finally {
|
||||
if (r) throw r.error;
|
||||
}
|
||||
}
|
||||
};
|
||||
TreeContainer.prototype.getElementByPos = function(e) {
|
||||
var r, i;
|
||||
if (e < 0 || e > this.M - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var t;
|
||||
var n = 0;
|
||||
try {
|
||||
for (var s = __values(this), f = s.next(); !f.done; f = s.next()) {
|
||||
var h = f.value;
|
||||
if (n === e) {
|
||||
t = h;
|
||||
break;
|
||||
}
|
||||
n += 1;
|
||||
}
|
||||
} catch (e) {
|
||||
r = {
|
||||
error: e
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (f && !f.done && (i = s.return)) i.call(s);
|
||||
} finally {
|
||||
if (r) throw r.error;
|
||||
}
|
||||
}
|
||||
return t;
|
||||
};
|
||||
TreeContainer.prototype.getHeight = function() {
|
||||
if (this.M === 0) return 0;
|
||||
var traversal = function(e) {
|
||||
if (!e) return 0;
|
||||
return Math.max(traversal(e.K), traversal(e.N)) + 1;
|
||||
};
|
||||
return traversal(this.W);
|
||||
};
|
||||
return TreeContainer;
|
||||
}(Container);
|
||||
|
||||
export default TreeContainer;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
62
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.d.ts
generated
vendored
Normal file
62
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import TreeContainer from './Base';
|
||||
import TreeIterator from './Base/TreeIterator';
|
||||
import { TreeNode } from './Base/TreeNode';
|
||||
import { initContainer, IteratorType } from "../ContainerBase";
|
||||
declare class OrderedMapIterator<K, V> extends TreeIterator<K, V> {
|
||||
container: OrderedMap<K, V>;
|
||||
constructor(node: TreeNode<K, V>, header: TreeNode<K, V>, container: OrderedMap<K, V>, iteratorType?: IteratorType);
|
||||
get pointer(): [K, V];
|
||||
copy(): OrderedMapIterator<K, V>;
|
||||
equals(iter: OrderedMapIterator<K, V>): boolean;
|
||||
}
|
||||
export type { OrderedMapIterator };
|
||||
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.
|
||||
* @example
|
||||
* new OrderedMap();
|
||||
* new OrderedMap([[0, 1], [2, 1]]);
|
||||
* new OrderedMap([[0, 1], [2, 1]], (x, y) => x - y);
|
||||
* new OrderedMap([[0, 1], [2, 1]], (x, y) => x - y, true);
|
||||
*/
|
||||
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;
|
||||
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.
|
||||
* @return The size of container after setting.
|
||||
* @example
|
||||
* const mp = new OrderedMap([[2, 0], [4, 0], [5, 0]]);
|
||||
* const iter = mp.begin();
|
||||
* mp.setElement(1, 0);
|
||||
* mp.setElement(3, 0, iter); // give a hint will be faster.
|
||||
*/
|
||||
setElement(key: K, value: V, hint?: OrderedMapIterator<K, V>): number;
|
||||
find(key: K): OrderedMapIterator<K, V>;
|
||||
/**
|
||||
* @description Get the value of the element of the specified key.
|
||||
* @param key - The specified key you want to get.
|
||||
* @example
|
||||
* const val = container.getElementByKey(1);
|
||||
*/
|
||||
getElementByKey(key: K): V | undefined;
|
||||
union(other: OrderedMap<K, V>): number;
|
||||
[Symbol.iterator](): Generator<[K, V], void, unknown>;
|
||||
eraseElementByIterator(iter: OrderedMapIterator<K, V>): OrderedMapIterator<K, V>;
|
||||
forEach(callback: (element: [K, V], index: number, map: OrderedMap<K, V>) => void): void;
|
||||
getElementByPos(pos: number): [K, V];
|
||||
}
|
||||
export default OrderedMap;
|
265
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.js
generated
vendored
Normal file
265
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.js
generated
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
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 (o[0] & 1) throw o[1];
|
||||
return o[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, n, i, o, a;
|
||||
return a = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (a[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), a;
|
||||
function verb(r) {
|
||||
return function(e) {
|
||||
return step([ r, e ]);
|
||||
};
|
||||
}
|
||||
function step(a) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (t) try {
|
||||
if (n = 1, i && (o = a[0] & 2 ? i["return"] : a[0] ? i["throw"] || ((o = i["return"]) && o.call(i),
|
||||
0) : i.next) && !(o = o.call(i, a[1])).done) return o;
|
||||
if (i = 0, o) a = [ a[0] & 2, o.value ];
|
||||
switch (a[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
o = a;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
t.label++;
|
||||
return {
|
||||
value: a[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
t.label++;
|
||||
i = a[1];
|
||||
a = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
a = t.ops.pop();
|
||||
t.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(o = t.trys, o = o.length > 0 && o[o.length - 1]) && (a[0] === 6 || a[0] === 2)) {
|
||||
t = 0;
|
||||
continue;
|
||||
}
|
||||
if (a[0] === 3 && (!o || a[1] > o[0] && a[1] < o[3])) {
|
||||
t.label = a[1];
|
||||
break;
|
||||
}
|
||||
if (a[0] === 6 && t.label < o[1]) {
|
||||
t.label = o[1];
|
||||
o = a;
|
||||
break;
|
||||
}
|
||||
if (o && t.label < o[2]) {
|
||||
t.label = o[2];
|
||||
t.ops.push(a);
|
||||
break;
|
||||
}
|
||||
if (o[2]) t.ops.pop();
|
||||
t.trys.pop();
|
||||
continue;
|
||||
}
|
||||
a = e.call(r, t);
|
||||
} catch (r) {
|
||||
a = [ 6, r ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = o = 0;
|
||||
}
|
||||
if (a[0] & 5) throw a[1];
|
||||
return {
|
||||
value: a[0] ? a[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __values = this && this.V || 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";
|
||||
|
||||
import { throwIteratorAccessError } from "../../utils/throwError";
|
||||
|
||||
var OrderedMapIterator = function(r) {
|
||||
__extends(OrderedMapIterator, r);
|
||||
function OrderedMapIterator(e, t, n, i) {
|
||||
var o = r.call(this, e, t, i) || this;
|
||||
o.container = n;
|
||||
return o;
|
||||
}
|
||||
Object.defineProperty(OrderedMapIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
var r = this;
|
||||
return new Proxy([], {
|
||||
get: function(e, t) {
|
||||
if (t === "0") return r.o.u; else if (t === "1") return r.o.p;
|
||||
},
|
||||
set: function(e, t, n) {
|
||||
if (t !== "1") {
|
||||
throw new TypeError("props must be 1");
|
||||
}
|
||||
r.o.p = n;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
OrderedMapIterator.prototype.copy = function() {
|
||||
return new OrderedMapIterator(this.o, this.h, this.container, this.iteratorType);
|
||||
};
|
||||
return OrderedMapIterator;
|
||||
}(TreeIterator);
|
||||
|
||||
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;
|
||||
var o = i;
|
||||
e.forEach((function(r) {
|
||||
o.setElement(r[0], r[1]);
|
||||
}));
|
||||
return i;
|
||||
}
|
||||
OrderedMap.prototype.P = function(r) {
|
||||
return __generator(this, (function(e) {
|
||||
switch (e.label) {
|
||||
case 0:
|
||||
if (r === undefined) return [ 2 ];
|
||||
return [ 5, __values(this.P(r.K)) ];
|
||||
|
||||
case 1:
|
||||
e.sent();
|
||||
return [ 4, [ r.u, r.p ] ];
|
||||
|
||||
case 2:
|
||||
e.sent();
|
||||
return [ 5, __values(this.P(r.N)) ];
|
||||
|
||||
case 3:
|
||||
e.sent();
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
};
|
||||
OrderedMap.prototype.begin = function() {
|
||||
return new OrderedMapIterator(this.h.K || this.h, this.h, this);
|
||||
};
|
||||
OrderedMap.prototype.end = function() {
|
||||
return new OrderedMapIterator(this.h, this.h, this);
|
||||
};
|
||||
OrderedMap.prototype.rBegin = function() {
|
||||
return new OrderedMapIterator(this.h.N || this.h, this.h, this, 1);
|
||||
};
|
||||
OrderedMap.prototype.rEnd = function() {
|
||||
return new OrderedMapIterator(this.h, this.h, this, 1);
|
||||
};
|
||||
OrderedMap.prototype.front = function() {
|
||||
if (this.M === 0) return;
|
||||
var r = this.h.K;
|
||||
return [ r.u, r.p ];
|
||||
};
|
||||
OrderedMap.prototype.back = function() {
|
||||
if (this.M === 0) return;
|
||||
var r = this.h.N;
|
||||
return [ r.u, r.p ];
|
||||
};
|
||||
OrderedMap.prototype.lowerBound = function(r) {
|
||||
var e = this.U(this.W, r);
|
||||
return new OrderedMapIterator(e, this.h, this);
|
||||
};
|
||||
OrderedMap.prototype.upperBound = function(r) {
|
||||
var e = this.X(this.W, r);
|
||||
return new OrderedMapIterator(e, this.h, this);
|
||||
};
|
||||
OrderedMap.prototype.reverseLowerBound = function(r) {
|
||||
var e = this.Y(this.W, r);
|
||||
return new OrderedMapIterator(e, this.h, this);
|
||||
};
|
||||
OrderedMap.prototype.reverseUpperBound = function(r) {
|
||||
var e = this.Z(this.W, r);
|
||||
return new OrderedMapIterator(e, this.h, this);
|
||||
};
|
||||
OrderedMap.prototype.setElement = function(r, e, t) {
|
||||
return this.v(r, e, t);
|
||||
};
|
||||
OrderedMap.prototype.find = function(r) {
|
||||
var e = this.g(this.W, r);
|
||||
return new OrderedMapIterator(e, this.h, this);
|
||||
};
|
||||
OrderedMap.prototype.getElementByKey = function(r) {
|
||||
var e = this.g(this.W, r);
|
||||
return e.p;
|
||||
};
|
||||
OrderedMap.prototype.union = function(r) {
|
||||
var e = this;
|
||||
r.forEach((function(r) {
|
||||
e.setElement(r[0], r[1]);
|
||||
}));
|
||||
return this.M;
|
||||
};
|
||||
OrderedMap.prototype[Symbol.iterator] = function() {
|
||||
return this.P(this.W);
|
||||
};
|
||||
return OrderedMap;
|
||||
}(TreeContainer);
|
||||
|
||||
export default OrderedMap;
|
||||
//# sourceMappingURL=OrderedMap.js.map
|
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
54
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.d.ts
generated
vendored
Normal file
54
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.d.ts
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import TreeContainer from './Base';
|
||||
import TreeIterator from './Base/TreeIterator';
|
||||
import { TreeNode } from './Base/TreeNode';
|
||||
import { initContainer, IteratorType } from "../ContainerBase";
|
||||
declare class OrderedSetIterator<K> extends TreeIterator<K, undefined> {
|
||||
container: OrderedSet<K>;
|
||||
constructor(node: TreeNode<K, undefined>, header: TreeNode<K, undefined>, container: OrderedSet<K>, iteratorType?: IteratorType);
|
||||
get pointer(): NonNullable<K>;
|
||||
copy(): OrderedSetIterator<K>;
|
||||
equals(iter: OrderedSetIterator<K>): boolean;
|
||||
}
|
||||
export type { OrderedSetIterator };
|
||||
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.
|
||||
* @example
|
||||
* new OrderedSet();
|
||||
* new OrderedSet([0, 1, 2]);
|
||||
* new OrderedSet([0, 1, 2], (x, y) => x - y);
|
||||
* new OrderedSet([0, 1, 2], (x, y) => x - y, true);
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* @description Insert element to set.
|
||||
* @param key - The key want to insert.
|
||||
* @param hint - You can give an iterator hint to improve insertion efficiency.
|
||||
* @return The size of container after setting.
|
||||
* @example
|
||||
* const st = new OrderedSet([2, 4, 5]);
|
||||
* const iter = st.begin();
|
||||
* st.insert(1);
|
||||
* st.insert(3, iter); // give a hint will be faster.
|
||||
*/
|
||||
insert(key: K, hint?: OrderedSetIterator<K>): number;
|
||||
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>): number;
|
||||
[Symbol.iterator](): Generator<K, void, unknown>;
|
||||
eraseElementByIterator(iter: OrderedSetIterator<K>): OrderedSetIterator<K>;
|
||||
forEach(callback: (element: K, index: number, tree: OrderedSet<K>) => void): void;
|
||||
getElementByPos(pos: number): K;
|
||||
}
|
||||
export default OrderedSet;
|
245
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.js
generated
vendored
Normal file
245
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.js
generated
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
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 (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(t) {
|
||||
return step([ e, t ]);
|
||||
};
|
||||
}
|
||||
function step(u) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (r) 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:
|
||||
r.label++;
|
||||
return {
|
||||
value: u[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
r.label++;
|
||||
i = u[1];
|
||||
u = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
u = r.ops.pop();
|
||||
r.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(o = r.trys, o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
|
||||
r = 0;
|
||||
continue;
|
||||
}
|
||||
if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
|
||||
r.label = u[1];
|
||||
break;
|
||||
}
|
||||
if (u[0] === 6 && r.label < o[1]) {
|
||||
r.label = o[1];
|
||||
o = u;
|
||||
break;
|
||||
}
|
||||
if (o && r.label < o[2]) {
|
||||
r.label = o[2];
|
||||
r.ops.push(u);
|
||||
break;
|
||||
}
|
||||
if (o[2]) r.ops.pop();
|
||||
r.trys.pop();
|
||||
continue;
|
||||
}
|
||||
u = t.call(e, r);
|
||||
} 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.V || 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 TreeContainer from "./Base";
|
||||
|
||||
import TreeIterator from "./Base/TreeIterator";
|
||||
|
||||
import { throwIteratorAccessError } from "../../utils/throwError";
|
||||
|
||||
var OrderedSetIterator = function(e) {
|
||||
__extends(OrderedSetIterator, e);
|
||||
function OrderedSetIterator(t, r, n, i) {
|
||||
var o = e.call(this, t, r, i) || this;
|
||||
o.container = n;
|
||||
return o;
|
||||
}
|
||||
Object.defineProperty(OrderedSetIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.o === this.h) {
|
||||
throwIteratorAccessError();
|
||||
}
|
||||
return this.o.u;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
OrderedSetIterator.prototype.copy = function() {
|
||||
return new OrderedSetIterator(this.o, this.h, this.container, this.iteratorType);
|
||||
};
|
||||
return OrderedSetIterator;
|
||||
}(TreeIterator);
|
||||
|
||||
var OrderedSet = function(e) {
|
||||
__extends(OrderedSet, e);
|
||||
function OrderedSet(t, r, n) {
|
||||
if (t === void 0) {
|
||||
t = [];
|
||||
}
|
||||
var i = e.call(this, r, n) || this;
|
||||
var o = i;
|
||||
t.forEach((function(e) {
|
||||
o.insert(e);
|
||||
}));
|
||||
return i;
|
||||
}
|
||||
OrderedSet.prototype.P = function(e) {
|
||||
return __generator(this, (function(t) {
|
||||
switch (t.label) {
|
||||
case 0:
|
||||
if (e === undefined) return [ 2 ];
|
||||
return [ 5, __values(this.P(e.K)) ];
|
||||
|
||||
case 1:
|
||||
t.sent();
|
||||
return [ 4, e.u ];
|
||||
|
||||
case 2:
|
||||
t.sent();
|
||||
return [ 5, __values(this.P(e.N)) ];
|
||||
|
||||
case 3:
|
||||
t.sent();
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
};
|
||||
OrderedSet.prototype.begin = function() {
|
||||
return new OrderedSetIterator(this.h.K || this.h, this.h, this);
|
||||
};
|
||||
OrderedSet.prototype.end = function() {
|
||||
return new OrderedSetIterator(this.h, this.h, this);
|
||||
};
|
||||
OrderedSet.prototype.rBegin = function() {
|
||||
return new OrderedSetIterator(this.h.N || this.h, this.h, this, 1);
|
||||
};
|
||||
OrderedSet.prototype.rEnd = function() {
|
||||
return new OrderedSetIterator(this.h, this.h, this, 1);
|
||||
};
|
||||
OrderedSet.prototype.front = function() {
|
||||
return this.h.K ? this.h.K.u : undefined;
|
||||
};
|
||||
OrderedSet.prototype.back = function() {
|
||||
return this.h.N ? this.h.N.u : undefined;
|
||||
};
|
||||
OrderedSet.prototype.insert = function(e, t) {
|
||||
return this.v(e, undefined, t);
|
||||
};
|
||||
OrderedSet.prototype.find = function(e) {
|
||||
var t = this.g(this.W, e);
|
||||
return new OrderedSetIterator(t, this.h, this);
|
||||
};
|
||||
OrderedSet.prototype.lowerBound = function(e) {
|
||||
var t = this.U(this.W, e);
|
||||
return new OrderedSetIterator(t, this.h, this);
|
||||
};
|
||||
OrderedSet.prototype.upperBound = function(e) {
|
||||
var t = this.X(this.W, e);
|
||||
return new OrderedSetIterator(t, this.h, this);
|
||||
};
|
||||
OrderedSet.prototype.reverseLowerBound = function(e) {
|
||||
var t = this.Y(this.W, e);
|
||||
return new OrderedSetIterator(t, this.h, this);
|
||||
};
|
||||
OrderedSet.prototype.reverseUpperBound = function(e) {
|
||||
var t = this.Z(this.W, e);
|
||||
return new OrderedSetIterator(t, this.h, this);
|
||||
};
|
||||
OrderedSet.prototype.union = function(e) {
|
||||
var t = this;
|
||||
e.forEach((function(e) {
|
||||
t.insert(e);
|
||||
}));
|
||||
return this.M;
|
||||
};
|
||||
OrderedSet.prototype[Symbol.iterator] = function() {
|
||||
return this.P(this.W);
|
||||
};
|
||||
return OrderedSet;
|
||||
}(TreeContainer);
|
||||
|
||||
export default OrderedSet;
|
||||
//# sourceMappingURL=OrderedSet.js.map
|
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.js.map
generated
vendored
Normal file
1
node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user