Insane number of adds to setup env and packages
This commit is contained in:
8
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.d.ts
generated
vendored
Normal file
8
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
export declare abstract class RandomIterator<T> extends ContainerIterator<T> {
|
||||
pre: () => this;
|
||||
next: () => this;
|
||||
get pointer(): T;
|
||||
set pointer(newValue: T);
|
||||
equals(obj: RandomIterator<T>): boolean;
|
||||
}
|
||||
67
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.js
generated
vendored
Normal file
67
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "t", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.RandomIterator = void 0;
|
||||
|
||||
var _ContainerBase = require("../../ContainerBase");
|
||||
|
||||
class RandomIterator extends _ContainerBase.ContainerIterator {
|
||||
constructor(t, r, e, i, s) {
|
||||
super(s);
|
||||
this.I = t;
|
||||
this.D = r;
|
||||
this.g = e;
|
||||
this.m = i;
|
||||
if (this.iteratorType === 0) {
|
||||
this.pre = function() {
|
||||
if (this.I === 0) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.I -= 1;
|
||||
return this;
|
||||
};
|
||||
this.next = function() {
|
||||
if (this.I === this.D()) {
|
||||
throw new RangeError("Random Iterator access denied!");
|
||||
}
|
||||
this.I += 1;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
this.pre = function() {
|
||||
if (this.I === this.D() - 1) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.I += 1;
|
||||
return this;
|
||||
};
|
||||
this.next = function() {
|
||||
if (this.I === -1) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.I -= 1;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
}
|
||||
get pointer() {
|
||||
if (this.I < 0 || this.I > this.D() - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
return this.g(this.I);
|
||||
}
|
||||
set pointer(t) {
|
||||
if (this.I < 0 || this.I > this.D() - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.m(this.I, t);
|
||||
}
|
||||
equals(t) {
|
||||
return this.I === t.I;
|
||||
}
|
||||
}
|
||||
|
||||
exports.RandomIterator = RandomIterator;
|
||||
44
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.d.ts
generated
vendored
Normal file
44
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Container } from "../../ContainerBase";
|
||||
declare abstract class SequentialContainer<T> extends Container<T> {
|
||||
/**
|
||||
* @description Push the element to the back.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
abstract pushBack(element: T): void;
|
||||
/**
|
||||
* @description Removes the last element.
|
||||
*/
|
||||
abstract popBack(): void;
|
||||
/**
|
||||
* @description Sets element by position.
|
||||
* @param pos The position you want to change.
|
||||
* @param element The element's value you want to update.
|
||||
*/
|
||||
abstract setElementByPos(pos: number, element: T): void;
|
||||
/**
|
||||
* @description Removes the elements of the specified value.
|
||||
* @param value The value you want to remove.
|
||||
*/
|
||||
abstract eraseElementByValue(value: T): void;
|
||||
/**
|
||||
* @description Insert several elements after the specified position.
|
||||
* @param pos The position you want to insert.
|
||||
* @param element The element you want to insert.
|
||||
* @param num The number of elements you want to insert (default 1).
|
||||
*/
|
||||
abstract insert(pos: number, element: T, num?: number): void;
|
||||
/**
|
||||
* @description Reverses the container.
|
||||
*/
|
||||
abstract reverse(): void;
|
||||
/**
|
||||
* @description Removes the duplication of elements in the container.
|
||||
*/
|
||||
abstract unique(): void;
|
||||
/**
|
||||
* @description Sort the container.
|
||||
* @param cmp Comparison function.
|
||||
*/
|
||||
abstract sort(cmp?: (x: T, y: T) => number): void;
|
||||
}
|
||||
export default SequentialContainer;
|
||||
15
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.js
generated
vendored
Normal file
15
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "t", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = void 0;
|
||||
|
||||
var _ContainerBase = require("../../ContainerBase");
|
||||
|
||||
class SequentialContainer extends _ContainerBase.Container {}
|
||||
|
||||
var _default = SequentialContainer;
|
||||
|
||||
exports.default = _default;
|
||||
50
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.d.ts
generated
vendored
Normal file
50
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.d.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
export declare class DequeIterator<T> extends RandomIterator<T> {
|
||||
copy(): DequeIterator<T>;
|
||||
}
|
||||
declare class Deque<T> extends SequentialContainer<T> {
|
||||
constructor(container?: initContainer<T>, _bucketSize?: number);
|
||||
clear(): void;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
begin(): DequeIterator<T>;
|
||||
end(): DequeIterator<T>;
|
||||
rBegin(): DequeIterator<T>;
|
||||
rEnd(): DequeIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
/**
|
||||
* @description Push the element to the front.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
pushFront(element: T): void;
|
||||
/**
|
||||
* @description Remove the _first element.
|
||||
*/
|
||||
popFront(): void;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
/**
|
||||
* @description Remove all elements after the specified position (excluding the specified position).
|
||||
* @param pos The previous position of the _first removed element.
|
||||
* @example deque.cut(1); // Then deque's size will be 2. deque -> [0, 1]
|
||||
*/
|
||||
cut(pos: number): void;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(value: T): void;
|
||||
eraseElementByIterator(iter: DequeIterator<T>): DequeIterator<T>;
|
||||
find(element: T): DequeIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
/**
|
||||
* @description Remove as much useless space as possible.
|
||||
*/
|
||||
shrinkToFit(): void;
|
||||
[Symbol.iterator](): Generator<T, void, unknown>;
|
||||
}
|
||||
export default Deque;
|
||||
324
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.js
generated
vendored
Normal file
324
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.js
generated
vendored
Normal file
@@ -0,0 +1,324 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "t", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = exports.DequeIterator = void 0;
|
||||
|
||||
var _Base = _interopRequireDefault(require("./Base"));
|
||||
|
||||
var _RandomIterator = require("./Base/RandomIterator");
|
||||
|
||||
function _interopRequireDefault(t) {
|
||||
return t && t.t ? t : {
|
||||
default: t
|
||||
};
|
||||
}
|
||||
|
||||
class DequeIterator extends _RandomIterator.RandomIterator {
|
||||
copy() {
|
||||
return new DequeIterator(this.I, this.D, this.g, this.m, this.iteratorType);
|
||||
}
|
||||
}
|
||||
|
||||
exports.DequeIterator = DequeIterator;
|
||||
|
||||
class Deque extends _Base.default {
|
||||
constructor(t = [], i = 1 << 12) {
|
||||
super();
|
||||
this.R = 0;
|
||||
this.k = 0;
|
||||
this.N = 0;
|
||||
this.M = 0;
|
||||
this.u = 0;
|
||||
this.P = [];
|
||||
let s;
|
||||
if ("size" in t) {
|
||||
if (typeof t.size === "number") {
|
||||
s = t.size;
|
||||
} else {
|
||||
s = t.size();
|
||||
}
|
||||
} else if ("length" in t) {
|
||||
s = t.length;
|
||||
} else {
|
||||
throw new RangeError("Can't get container's size!");
|
||||
}
|
||||
this.A = i;
|
||||
this.u = Math.max(Math.ceil(s / this.A), 1);
|
||||
for (let t = 0; t < this.u; ++t) {
|
||||
this.P.push(new Array(this.A));
|
||||
}
|
||||
const h = Math.ceil(s / this.A);
|
||||
this.R = this.N = (this.u >> 1) - (h >> 1);
|
||||
this.k = this.M = this.A - s % this.A >> 1;
|
||||
t.forEach((t => this.pushBack(t)));
|
||||
this.size = this.size.bind(this);
|
||||
this.getElementByPos = this.getElementByPos.bind(this);
|
||||
this.setElementByPos = this.setElementByPos.bind(this);
|
||||
}
|
||||
h() {
|
||||
const t = [];
|
||||
const i = Math.max(this.u >> 1, 1);
|
||||
for (let s = 0; s < i; ++s) {
|
||||
t[s] = new Array(this.A);
|
||||
}
|
||||
for (let i = this.R; i < this.u; ++i) {
|
||||
t[t.length] = this.P[i];
|
||||
}
|
||||
for (let i = 0; i < this.N; ++i) {
|
||||
t[t.length] = this.P[i];
|
||||
}
|
||||
t[t.length] = [ ...this.P[this.N] ];
|
||||
this.R = i;
|
||||
this.N = t.length - 1;
|
||||
for (let s = 0; s < i; ++s) {
|
||||
t[t.length] = new Array(this.A);
|
||||
}
|
||||
this.P = t;
|
||||
this.u = t.length;
|
||||
}
|
||||
F(t) {
|
||||
const i = this.k + t + 1;
|
||||
const s = i % this.A;
|
||||
let h = s - 1;
|
||||
let e = this.R + (i - s) / this.A;
|
||||
if (s === 0) e -= 1;
|
||||
e %= this.u;
|
||||
if (h < 0) h += this.A;
|
||||
return {
|
||||
curNodeBucketIndex: e,
|
||||
curNodePointerIndex: h
|
||||
};
|
||||
}
|
||||
clear() {
|
||||
this.P = [ [] ];
|
||||
this.u = 1;
|
||||
this.R = this.N = this.o = 0;
|
||||
this.k = this.M = this.A >> 1;
|
||||
}
|
||||
front() {
|
||||
return this.P[this.R][this.k];
|
||||
}
|
||||
back() {
|
||||
return this.P[this.N][this.M];
|
||||
}
|
||||
begin() {
|
||||
return new DequeIterator(0, this.size, this.getElementByPos, this.setElementByPos);
|
||||
}
|
||||
end() {
|
||||
return new DequeIterator(this.o, this.size, this.getElementByPos, this.setElementByPos);
|
||||
}
|
||||
rBegin() {
|
||||
return new DequeIterator(this.o - 1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
}
|
||||
rEnd() {
|
||||
return new DequeIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
}
|
||||
pushBack(t) {
|
||||
if (this.o) {
|
||||
if (this.M < this.A - 1) {
|
||||
this.M += 1;
|
||||
} else if (this.N < this.u - 1) {
|
||||
this.N += 1;
|
||||
this.M = 0;
|
||||
} else {
|
||||
this.N = 0;
|
||||
this.M = 0;
|
||||
}
|
||||
if (this.N === this.R && this.M === this.k) this.h();
|
||||
}
|
||||
this.o += 1;
|
||||
this.P[this.N][this.M] = t;
|
||||
}
|
||||
popBack() {
|
||||
if (!this.o) return;
|
||||
this.P[this.N][this.M] = undefined;
|
||||
if (this.o !== 1) {
|
||||
if (this.M > 0) {
|
||||
this.M -= 1;
|
||||
} else if (this.N > 0) {
|
||||
this.N -= 1;
|
||||
this.M = this.A - 1;
|
||||
} else {
|
||||
this.N = this.u - 1;
|
||||
this.M = this.A - 1;
|
||||
}
|
||||
}
|
||||
this.o -= 1;
|
||||
}
|
||||
pushFront(t) {
|
||||
if (this.o) {
|
||||
if (this.k > 0) {
|
||||
this.k -= 1;
|
||||
} else if (this.R > 0) {
|
||||
this.R -= 1;
|
||||
this.k = this.A - 1;
|
||||
} else {
|
||||
this.R = this.u - 1;
|
||||
this.k = this.A - 1;
|
||||
}
|
||||
if (this.R === this.N && this.k === this.M) this.h();
|
||||
}
|
||||
this.o += 1;
|
||||
this.P[this.R][this.k] = t;
|
||||
}
|
||||
popFront() {
|
||||
if (!this.o) return;
|
||||
this.P[this.R][this.k] = undefined;
|
||||
if (this.o !== 1) {
|
||||
if (this.k < this.A - 1) {
|
||||
this.k += 1;
|
||||
} else if (this.R < this.u - 1) {
|
||||
this.R += 1;
|
||||
this.k = 0;
|
||||
} else {
|
||||
this.R = 0;
|
||||
this.k = 0;
|
||||
}
|
||||
}
|
||||
this.o -= 1;
|
||||
}
|
||||
forEach(t) {
|
||||
for (let i = 0; i < this.o; ++i) {
|
||||
t(this.getElementByPos(i), i);
|
||||
}
|
||||
}
|
||||
getElementByPos(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
const {curNodeBucketIndex: i, curNodePointerIndex: s} = this.F(t);
|
||||
return this.P[i][s];
|
||||
}
|
||||
setElementByPos(t, i) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
const {curNodeBucketIndex: s, curNodePointerIndex: h} = this.F(t);
|
||||
this.P[s][h] = i;
|
||||
}
|
||||
insert(t, i, s = 1) {
|
||||
if (t < 0 || t > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) {
|
||||
while (s--) this.pushFront(i);
|
||||
} else if (t === this.o) {
|
||||
while (s--) this.pushBack(i);
|
||||
} else {
|
||||
const h = [];
|
||||
for (let i = t; i < this.o; ++i) {
|
||||
h.push(this.getElementByPos(i));
|
||||
}
|
||||
this.cut(t - 1);
|
||||
for (let t = 0; t < s; ++t) this.pushBack(i);
|
||||
for (let t = 0; t < h.length; ++t) this.pushBack(h[t]);
|
||||
}
|
||||
}
|
||||
cut(t) {
|
||||
if (t < 0) {
|
||||
this.clear();
|
||||
return;
|
||||
}
|
||||
const {curNodeBucketIndex: i, curNodePointerIndex: s} = this.F(t);
|
||||
this.N = i;
|
||||
this.M = s;
|
||||
this.o = t + 1;
|
||||
}
|
||||
eraseElementByPos(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) this.popFront(); else if (t === this.o - 1) this.popBack(); else {
|
||||
const i = [];
|
||||
for (let s = t + 1; s < this.o; ++s) {
|
||||
i.push(this.getElementByPos(s));
|
||||
}
|
||||
this.cut(t);
|
||||
this.popBack();
|
||||
i.forEach((t => this.pushBack(t)));
|
||||
}
|
||||
}
|
||||
eraseElementByValue(t) {
|
||||
if (!this.o) return;
|
||||
const i = [];
|
||||
for (let s = 0; s < this.o; ++s) {
|
||||
const h = this.getElementByPos(s);
|
||||
if (h !== t) i.push(h);
|
||||
}
|
||||
const s = i.length;
|
||||
for (let t = 0; t < s; ++t) this.setElementByPos(t, i[t]);
|
||||
this.cut(s - 1);
|
||||
}
|
||||
eraseElementByIterator(t) {
|
||||
const i = t.I;
|
||||
this.eraseElementByPos(i);
|
||||
t = t.next();
|
||||
return t;
|
||||
}
|
||||
find(t) {
|
||||
for (let i = 0; i < this.o; ++i) {
|
||||
if (this.getElementByPos(i) === t) {
|
||||
return new DequeIterator(i, this.size, this.getElementByPos, this.setElementByPos);
|
||||
}
|
||||
}
|
||||
return this.end();
|
||||
}
|
||||
reverse() {
|
||||
let t = 0;
|
||||
let i = this.o - 1;
|
||||
while (t < i) {
|
||||
const s = this.getElementByPos(t);
|
||||
this.setElementByPos(t, this.getElementByPos(i));
|
||||
this.setElementByPos(i, s);
|
||||
t += 1;
|
||||
i -= 1;
|
||||
}
|
||||
}
|
||||
unique() {
|
||||
if (this.o <= 1) return;
|
||||
let t = 1;
|
||||
let i = this.getElementByPos(0);
|
||||
for (let s = 1; s < this.o; ++s) {
|
||||
const h = this.getElementByPos(s);
|
||||
if (h !== i) {
|
||||
i = h;
|
||||
this.setElementByPos(t++, h);
|
||||
}
|
||||
}
|
||||
while (this.o > t) this.popBack();
|
||||
}
|
||||
sort(t) {
|
||||
const i = [];
|
||||
for (let t = 0; t < this.o; ++t) {
|
||||
i.push(this.getElementByPos(t));
|
||||
}
|
||||
i.sort(t);
|
||||
for (let t = 0; t < this.o; ++t) this.setElementByPos(t, i[t]);
|
||||
}
|
||||
shrinkToFit() {
|
||||
if (!this.o) return;
|
||||
const t = [];
|
||||
this.forEach((i => t.push(i)));
|
||||
this.u = Math.max(Math.ceil(this.o / this.A), 1);
|
||||
this.o = this.R = this.N = this.k = this.M = 0;
|
||||
this.P = [];
|
||||
for (let t = 0; t < this.u; ++t) {
|
||||
this.P.push(new Array(this.A));
|
||||
}
|
||||
for (let i = 0; i < t.length; ++i) this.pushBack(t[i]);
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return function*() {
|
||||
for (let t = 0; t < this.o; ++t) {
|
||||
yield this.getElementByPos(t);
|
||||
}
|
||||
}.bind(this)();
|
||||
}
|
||||
}
|
||||
|
||||
var _default = Deque;
|
||||
|
||||
exports.default = _default;
|
||||
49
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.d.ts
generated
vendored
Normal file
49
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.d.ts
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { ContainerIterator, initContainer } from "../ContainerBase";
|
||||
export declare class LinkListIterator<T> extends ContainerIterator<T> {
|
||||
pre: () => this;
|
||||
next: () => this;
|
||||
get pointer(): T;
|
||||
set pointer(newValue: T);
|
||||
equals(obj: LinkListIterator<T>): boolean;
|
||||
copy(): LinkListIterator<T>;
|
||||
}
|
||||
declare class LinkList<T> extends SequentialContainer<T> {
|
||||
constructor(container?: initContainer<T>);
|
||||
clear(): void;
|
||||
begin(): LinkListIterator<T>;
|
||||
end(): LinkListIterator<T>;
|
||||
rBegin(): LinkListIterator<T>;
|
||||
rEnd(): LinkListIterator<T>;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(_value: T): void;
|
||||
eraseElementByIterator(iter: LinkListIterator<T>): LinkListIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
find(element: T): LinkListIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
/**
|
||||
* @description Push an element to the front.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
pushFront(element: T): void;
|
||||
/**
|
||||
* @description Removes the first element.
|
||||
*/
|
||||
popFront(): void;
|
||||
/**
|
||||
* @description Merges two sorted lists.
|
||||
* @param list The other list you want to merge (must be sorted).
|
||||
*/
|
||||
merge(list: LinkList<T>): void;
|
||||
[Symbol.iterator](): Generator<T, void, unknown>;
|
||||
}
|
||||
export default LinkList;
|
||||
366
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.js
generated
vendored
Normal file
366
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.js
generated
vendored
Normal file
@@ -0,0 +1,366 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "t", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = exports.LinkNode = exports.LinkListIterator = void 0;
|
||||
|
||||
var _Base = _interopRequireDefault(require("./Base"));
|
||||
|
||||
var _ContainerBase = require("../ContainerBase");
|
||||
|
||||
function _interopRequireDefault(t) {
|
||||
return t && t.t ? t : {
|
||||
default: t
|
||||
};
|
||||
}
|
||||
|
||||
class LinkNode {
|
||||
constructor(t) {
|
||||
this.L = undefined;
|
||||
this.j = undefined;
|
||||
this.O = undefined;
|
||||
this.L = t;
|
||||
}
|
||||
}
|
||||
|
||||
exports.LinkNode = LinkNode;
|
||||
|
||||
class LinkListIterator extends _ContainerBase.ContainerIterator {
|
||||
constructor(t, i, s) {
|
||||
super(s);
|
||||
this.I = t;
|
||||
this.S = i;
|
||||
if (this.iteratorType === 0) {
|
||||
this.pre = function() {
|
||||
if (this.I.j === this.S) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.I = this.I.j;
|
||||
return this;
|
||||
};
|
||||
this.next = function() {
|
||||
if (this.I === this.S) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.I = this.I.O;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
this.pre = function() {
|
||||
if (this.I.O === this.S) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.I = this.I.O;
|
||||
return this;
|
||||
};
|
||||
this.next = function() {
|
||||
if (this.I === this.S) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.I = this.I.j;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
}
|
||||
get pointer() {
|
||||
if (this.I === this.S) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
return this.I.L;
|
||||
}
|
||||
set pointer(t) {
|
||||
if (this.I === this.S) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.I.L = t;
|
||||
}
|
||||
equals(t) {
|
||||
return this.I === t.I;
|
||||
}
|
||||
copy() {
|
||||
return new LinkListIterator(this.I, this.S, this.iteratorType);
|
||||
}
|
||||
}
|
||||
|
||||
exports.LinkListIterator = LinkListIterator;
|
||||
|
||||
class LinkList extends _Base.default {
|
||||
constructor(t = []) {
|
||||
super();
|
||||
this.S = new LinkNode;
|
||||
this.V = undefined;
|
||||
this.G = undefined;
|
||||
t.forEach((t => this.pushBack(t)));
|
||||
}
|
||||
clear() {
|
||||
this.o = 0;
|
||||
this.V = this.G = undefined;
|
||||
this.S.j = this.S.O = undefined;
|
||||
}
|
||||
begin() {
|
||||
return new LinkListIterator(this.V || this.S, this.S);
|
||||
}
|
||||
end() {
|
||||
return new LinkListIterator(this.S, this.S);
|
||||
}
|
||||
rBegin() {
|
||||
return new LinkListIterator(this.G || this.S, this.S, 1);
|
||||
}
|
||||
rEnd() {
|
||||
return new LinkListIterator(this.S, this.S, 1);
|
||||
}
|
||||
front() {
|
||||
return this.V ? this.V.L : undefined;
|
||||
}
|
||||
back() {
|
||||
return this.G ? this.G.L : undefined;
|
||||
}
|
||||
forEach(t) {
|
||||
if (!this.o) return;
|
||||
let i = this.V;
|
||||
let s = 0;
|
||||
while (i !== this.S) {
|
||||
t(i.L, s++);
|
||||
i = i.O;
|
||||
}
|
||||
}
|
||||
getElementByPos(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
let i = this.V;
|
||||
while (t--) {
|
||||
i = i.O;
|
||||
}
|
||||
return i.L;
|
||||
}
|
||||
eraseElementByPos(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) this.popFront(); else if (t === this.o - 1) this.popBack(); else {
|
||||
let i = this.V;
|
||||
while (t--) {
|
||||
i = i.O;
|
||||
}
|
||||
i = i;
|
||||
const s = i.j;
|
||||
const e = i.O;
|
||||
e.j = s;
|
||||
s.O = e;
|
||||
this.o -= 1;
|
||||
}
|
||||
}
|
||||
eraseElementByValue(t) {
|
||||
while (this.V && this.V.L === t) this.popFront();
|
||||
while (this.G && this.G.L === t) this.popBack();
|
||||
if (!this.V) return;
|
||||
let i = this.V;
|
||||
while (i !== this.S) {
|
||||
if (i.L === t) {
|
||||
const t = i.j;
|
||||
const s = i.O;
|
||||
s.j = t;
|
||||
t.O = s;
|
||||
this.o -= 1;
|
||||
}
|
||||
i = i.O;
|
||||
}
|
||||
}
|
||||
eraseElementByIterator(t) {
|
||||
const i = t.I;
|
||||
if (i === this.S) {
|
||||
throw new RangeError("Invalid iterator");
|
||||
}
|
||||
t = t.next();
|
||||
if (this.V === i) this.popFront(); else if (this.G === i) this.popBack(); else {
|
||||
const t = i.j;
|
||||
const s = i.O;
|
||||
s.j = t;
|
||||
t.O = s;
|
||||
this.o -= 1;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
pushBack(t) {
|
||||
this.o += 1;
|
||||
const i = new LinkNode(t);
|
||||
if (!this.G) {
|
||||
this.V = this.G = i;
|
||||
this.S.O = this.V;
|
||||
this.V.j = this.S;
|
||||
} else {
|
||||
this.G.O = i;
|
||||
i.j = this.G;
|
||||
this.G = i;
|
||||
}
|
||||
this.G.O = this.S;
|
||||
this.S.j = this.G;
|
||||
}
|
||||
popBack() {
|
||||
if (!this.G) return;
|
||||
this.o -= 1;
|
||||
if (this.V === this.G) {
|
||||
this.V = this.G = undefined;
|
||||
this.S.O = undefined;
|
||||
} else {
|
||||
this.G = this.G.j;
|
||||
this.G.O = this.S;
|
||||
}
|
||||
this.S.j = this.G;
|
||||
}
|
||||
setElementByPos(t, i) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
let s = this.V;
|
||||
while (t--) {
|
||||
s = s.O;
|
||||
}
|
||||
s.L = i;
|
||||
}
|
||||
insert(t, i, s = 1) {
|
||||
if (t < 0 || t > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (s <= 0) return;
|
||||
if (t === 0) {
|
||||
while (s--) this.pushFront(i);
|
||||
} else if (t === this.o) {
|
||||
while (s--) this.pushBack(i);
|
||||
} else {
|
||||
let e = this.V;
|
||||
for (let i = 1; i < t; ++i) {
|
||||
e = e.O;
|
||||
}
|
||||
const h = e.O;
|
||||
this.o += s;
|
||||
while (s--) {
|
||||
e.O = new LinkNode(i);
|
||||
e.O.j = e;
|
||||
e = e.O;
|
||||
}
|
||||
e.O = h;
|
||||
h.j = e;
|
||||
}
|
||||
}
|
||||
find(t) {
|
||||
if (!this.V) return this.end();
|
||||
let i = this.V;
|
||||
while (i !== this.S) {
|
||||
if (i.L === t) {
|
||||
return new LinkListIterator(i, this.S);
|
||||
}
|
||||
i = i.O;
|
||||
}
|
||||
return this.end();
|
||||
}
|
||||
reverse() {
|
||||
if (this.o <= 1) return;
|
||||
let t = this.V;
|
||||
let i = this.G;
|
||||
let s = 0;
|
||||
while (s << 1 < this.o) {
|
||||
const e = t.L;
|
||||
t.L = i.L;
|
||||
i.L = e;
|
||||
t = t.O;
|
||||
i = i.j;
|
||||
s += 1;
|
||||
}
|
||||
}
|
||||
unique() {
|
||||
if (this.o <= 1) return;
|
||||
let t = this.V;
|
||||
while (t !== this.S) {
|
||||
let i = t;
|
||||
while (i.O && i.L === i.O.L) {
|
||||
i = i.O;
|
||||
this.o -= 1;
|
||||
}
|
||||
t.O = i.O;
|
||||
t.O.j = t;
|
||||
t = t.O;
|
||||
}
|
||||
}
|
||||
sort(t) {
|
||||
if (this.o <= 1) return;
|
||||
const i = [];
|
||||
this.forEach((t => i.push(t)));
|
||||
i.sort(t);
|
||||
let s = this.V;
|
||||
i.forEach((t => {
|
||||
s.L = t;
|
||||
s = s.O;
|
||||
}));
|
||||
}
|
||||
pushFront(t) {
|
||||
this.o += 1;
|
||||
const i = new LinkNode(t);
|
||||
if (!this.V) {
|
||||
this.V = this.G = i;
|
||||
this.G.O = this.S;
|
||||
this.S.j = this.G;
|
||||
} else {
|
||||
i.O = this.V;
|
||||
this.V.j = i;
|
||||
this.V = i;
|
||||
}
|
||||
this.S.O = this.V;
|
||||
this.V.j = this.S;
|
||||
}
|
||||
popFront() {
|
||||
if (!this.V) return;
|
||||
this.o -= 1;
|
||||
if (this.V === this.G) {
|
||||
this.V = this.G = undefined;
|
||||
this.S.j = this.G;
|
||||
} else {
|
||||
this.V = this.V.O;
|
||||
this.V.j = this.S;
|
||||
}
|
||||
this.S.O = this.V;
|
||||
}
|
||||
merge(t) {
|
||||
if (!this.V) {
|
||||
t.forEach((t => this.pushBack(t)));
|
||||
return;
|
||||
}
|
||||
let i = this.V;
|
||||
t.forEach((t => {
|
||||
while (i && i !== this.S && i.L <= t) {
|
||||
i = i.O;
|
||||
}
|
||||
if (i === this.S) {
|
||||
this.pushBack(t);
|
||||
i = this.G;
|
||||
} else if (i === this.V) {
|
||||
this.pushFront(t);
|
||||
i = this.V;
|
||||
} else {
|
||||
this.o += 1;
|
||||
const s = i.j;
|
||||
s.O = new LinkNode(t);
|
||||
s.O.j = s;
|
||||
s.O.O = i;
|
||||
i.j = s.O;
|
||||
}
|
||||
}));
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return function*() {
|
||||
if (!this.V) return;
|
||||
let t = this.V;
|
||||
while (t !== this.S) {
|
||||
yield t.L;
|
||||
t = t.O;
|
||||
}
|
||||
}.bind(this)();
|
||||
}
|
||||
}
|
||||
|
||||
var _default = LinkList;
|
||||
|
||||
exports.default = _default;
|
||||
37
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.d.ts
generated
vendored
Normal file
37
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
export declare class VectorIterator<T> extends RandomIterator<T> {
|
||||
copy(): VectorIterator<T>;
|
||||
}
|
||||
declare class Vector<T> extends SequentialContainer<T> {
|
||||
/**
|
||||
* @description Vector's constructor.
|
||||
* @param container Initialize container, must have a forEach function.
|
||||
* @param copy When the container is an array, you can choose to directly operate on the original object of
|
||||
* the array or perform a shallow copy. The default is shallow copy.
|
||||
*/
|
||||
constructor(container?: initContainer<T>, copy?: boolean);
|
||||
clear(): void;
|
||||
begin(): VectorIterator<T>;
|
||||
end(): VectorIterator<T>;
|
||||
rBegin(): VectorIterator<T>;
|
||||
rEnd(): VectorIterator<T>;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(value: T): void;
|
||||
eraseElementByIterator(iter: VectorIterator<T>): VectorIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
find(element: T): VectorIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
[Symbol.iterator](): Generator<T, any, undefined>;
|
||||
}
|
||||
export default Vector;
|
||||
150
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.js
generated
vendored
Normal file
150
node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.js
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "t", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = exports.VectorIterator = void 0;
|
||||
|
||||
var _Base = _interopRequireDefault(require("./Base"));
|
||||
|
||||
var _RandomIterator = require("./Base/RandomIterator");
|
||||
|
||||
function _interopRequireDefault(t) {
|
||||
return t && t.t ? t : {
|
||||
default: t
|
||||
};
|
||||
}
|
||||
|
||||
class VectorIterator extends _RandomIterator.RandomIterator {
|
||||
copy() {
|
||||
return new VectorIterator(this.I, this.D, this.g, this.m, this.iteratorType);
|
||||
}
|
||||
}
|
||||
|
||||
exports.VectorIterator = VectorIterator;
|
||||
|
||||
class Vector extends _Base.default {
|
||||
constructor(t = [], e = true) {
|
||||
super();
|
||||
if (Array.isArray(t)) {
|
||||
this.H = e ? [ ...t ] : t;
|
||||
this.o = t.length;
|
||||
} else {
|
||||
this.H = [];
|
||||
t.forEach((t => this.pushBack(t)));
|
||||
}
|
||||
this.size = this.size.bind(this);
|
||||
this.getElementByPos = this.getElementByPos.bind(this);
|
||||
this.setElementByPos = this.setElementByPos.bind(this);
|
||||
}
|
||||
clear() {
|
||||
this.o = 0;
|
||||
this.H.length = 0;
|
||||
}
|
||||
begin() {
|
||||
return new VectorIterator(0, this.size, this.getElementByPos, this.setElementByPos);
|
||||
}
|
||||
end() {
|
||||
return new VectorIterator(this.o, this.size, this.getElementByPos, this.setElementByPos);
|
||||
}
|
||||
rBegin() {
|
||||
return new VectorIterator(this.o - 1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
}
|
||||
rEnd() {
|
||||
return new VectorIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
}
|
||||
front() {
|
||||
return this.H[0];
|
||||
}
|
||||
back() {
|
||||
return this.H[this.o - 1];
|
||||
}
|
||||
forEach(t) {
|
||||
for (let e = 0; e < this.o; ++e) {
|
||||
t(this.H[e], e);
|
||||
}
|
||||
}
|
||||
getElementByPos(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
return this.H[t];
|
||||
}
|
||||
eraseElementByPos(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.H.splice(t, 1);
|
||||
this.o -= 1;
|
||||
}
|
||||
eraseElementByValue(t) {
|
||||
let e = 0;
|
||||
for (let r = 0; r < this.o; ++r) {
|
||||
if (this.H[r] !== t) {
|
||||
this.H[e++] = this.H[r];
|
||||
}
|
||||
}
|
||||
this.o = this.H.length = e;
|
||||
}
|
||||
eraseElementByIterator(t) {
|
||||
const e = t.I;
|
||||
t = t.next();
|
||||
this.eraseElementByPos(e);
|
||||
return t;
|
||||
}
|
||||
pushBack(t) {
|
||||
this.H.push(t);
|
||||
this.o += 1;
|
||||
}
|
||||
popBack() {
|
||||
if (!this.o) return;
|
||||
this.H.pop();
|
||||
this.o -= 1;
|
||||
}
|
||||
setElementByPos(t, e) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.H[t] = e;
|
||||
}
|
||||
insert(t, e, r = 1) {
|
||||
if (t < 0 || t > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.H.splice(t, 0, ...new Array(r).fill(e));
|
||||
this.o += r;
|
||||
}
|
||||
find(t) {
|
||||
for (let e = 0; e < this.o; ++e) {
|
||||
if (this.H[e] === t) {
|
||||
return new VectorIterator(e, this.size, this.getElementByPos, this.getElementByPos);
|
||||
}
|
||||
}
|
||||
return this.end();
|
||||
}
|
||||
reverse() {
|
||||
this.H.reverse();
|
||||
}
|
||||
unique() {
|
||||
let t = 1;
|
||||
for (let e = 1; e < this.o; ++e) {
|
||||
if (this.H[e] !== this.H[e - 1]) {
|
||||
this.H[t++] = this.H[e];
|
||||
}
|
||||
}
|
||||
this.o = this.H.length = t;
|
||||
}
|
||||
sort(t) {
|
||||
this.H.sort(t);
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return function*() {
|
||||
return yield* this.H;
|
||||
}.bind(this)();
|
||||
}
|
||||
}
|
||||
|
||||
var _default = Vector;
|
||||
|
||||
exports.default = _default;
|
||||
Reference in New Issue
Block a user