Insane number of adds to setup env and packages
This commit is contained in:
8
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.d.ts
generated
vendored
Normal file
8
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
export declare abstract class RandomIterator<T> extends ContainerIterator<T> {
|
||||
pre: () => this;
|
||||
next: () => this;
|
||||
get pointer(): T;
|
||||
set pointer(newValue: T);
|
||||
equals(obj: RandomIterator<T>): boolean;
|
||||
}
|
||||
87
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js
generated
vendored
Normal file
87
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(t, r) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(t, r) {
|
||||
t.__proto__ = r;
|
||||
} || function(t, r) {
|
||||
for (var n in r) if (Object.prototype.hasOwnProperty.call(r, n)) t[n] = r[n];
|
||||
};
|
||||
return extendStatics(t, r);
|
||||
};
|
||||
return function(t, r) {
|
||||
if (typeof r !== "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
||||
extendStatics(t, r);
|
||||
function __() {
|
||||
this.constructor = t;
|
||||
}
|
||||
t.prototype = r === null ? Object.create(r) : (__.prototype = r.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { ContainerIterator } from "../../ContainerBase";
|
||||
|
||||
var RandomIterator = function(t) {
|
||||
__extends(RandomIterator, t);
|
||||
function RandomIterator(r, n, e, i, o) {
|
||||
var a = t.call(this, o) || this;
|
||||
a.D = r;
|
||||
a.I = n;
|
||||
a.g = e;
|
||||
a.R = i;
|
||||
if (a.iteratorType === 0) {
|
||||
a.pre = function() {
|
||||
if (this.D === 0) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.D -= 1;
|
||||
return this;
|
||||
};
|
||||
a.next = function() {
|
||||
if (this.D === this.I()) {
|
||||
throw new RangeError("Random Iterator access denied!");
|
||||
}
|
||||
this.D += 1;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
a.pre = function() {
|
||||
if (this.D === this.I() - 1) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.D += 1;
|
||||
return this;
|
||||
};
|
||||
a.next = function() {
|
||||
if (this.D === -1) {
|
||||
throw new RangeError("Random iterator access denied!");
|
||||
}
|
||||
this.D -= 1;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return a;
|
||||
}
|
||||
Object.defineProperty(RandomIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.D < 0 || this.D > this.I() - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
return this.g(this.D);
|
||||
},
|
||||
set: function(t) {
|
||||
if (this.D < 0 || this.D > this.I() - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.R(this.D, t);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
RandomIterator.prototype.equals = function(t) {
|
||||
return this.D === t.D;
|
||||
};
|
||||
return RandomIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
export { RandomIterator };
|
||||
44
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.d.ts
generated
vendored
Normal file
44
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Container } from "../../ContainerBase";
|
||||
declare abstract class SequentialContainer<T> extends Container<T> {
|
||||
/**
|
||||
* @description Push the element to the back.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
abstract pushBack(element: T): void;
|
||||
/**
|
||||
* @description Removes the last element.
|
||||
*/
|
||||
abstract popBack(): void;
|
||||
/**
|
||||
* @description Sets element by position.
|
||||
* @param pos The position you want to change.
|
||||
* @param element The element's value you want to update.
|
||||
*/
|
||||
abstract setElementByPos(pos: number, element: T): void;
|
||||
/**
|
||||
* @description Removes the elements of the specified value.
|
||||
* @param value The value you want to remove.
|
||||
*/
|
||||
abstract eraseElementByValue(value: T): void;
|
||||
/**
|
||||
* @description Insert several elements after the specified position.
|
||||
* @param pos The position you want to insert.
|
||||
* @param element The element you want to insert.
|
||||
* @param num The number of elements you want to insert (default 1).
|
||||
*/
|
||||
abstract insert(pos: number, element: T, num?: number): void;
|
||||
/**
|
||||
* @description Reverses the container.
|
||||
*/
|
||||
abstract reverse(): void;
|
||||
/**
|
||||
* @description Removes the duplication of elements in the container.
|
||||
*/
|
||||
abstract unique(): void;
|
||||
/**
|
||||
* @description Sort the container.
|
||||
* @param cmp Comparison function.
|
||||
*/
|
||||
abstract sort(cmp?: (x: T, y: T) => number): void;
|
||||
}
|
||||
export default SequentialContainer;
|
||||
32
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js
generated
vendored
Normal file
32
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(n, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(n, t) {
|
||||
n.__proto__ = t;
|
||||
} || function(n, t) {
|
||||
for (var e in t) if (Object.prototype.hasOwnProperty.call(t, e)) n[e] = t[e];
|
||||
};
|
||||
return extendStatics(n, t);
|
||||
};
|
||||
return function(n, t) {
|
||||
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
||||
extendStatics(n, t);
|
||||
function __() {
|
||||
this.constructor = n;
|
||||
}
|
||||
n.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
import { Container } from "../../ContainerBase";
|
||||
|
||||
var SequentialContainer = function(n) {
|
||||
__extends(SequentialContainer, n);
|
||||
function SequentialContainer() {
|
||||
return n !== null && n.apply(this, arguments) || this;
|
||||
}
|
||||
return SequentialContainer;
|
||||
}(Container);
|
||||
|
||||
export default SequentialContainer;
|
||||
50
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.d.ts
generated
vendored
Normal file
50
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.d.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
export declare class DequeIterator<T> extends RandomIterator<T> {
|
||||
copy(): DequeIterator<T>;
|
||||
}
|
||||
declare class Deque<T> extends SequentialContainer<T> {
|
||||
constructor(container?: initContainer<T>, _bucketSize?: number);
|
||||
clear(): void;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
begin(): DequeIterator<T>;
|
||||
end(): DequeIterator<T>;
|
||||
rBegin(): DequeIterator<T>;
|
||||
rEnd(): DequeIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
/**
|
||||
* @description Push the element to the front.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
pushFront(element: T): void;
|
||||
/**
|
||||
* @description Remove the _first element.
|
||||
*/
|
||||
popFront(): void;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
/**
|
||||
* @description Remove all elements after the specified position (excluding the specified position).
|
||||
* @param pos The previous position of the _first removed element.
|
||||
* @example deque.cut(1); // Then deque's size will be 2. deque -> [0, 1]
|
||||
*/
|
||||
cut(pos: number): void;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(value: T): void;
|
||||
eraseElementByIterator(iter: DequeIterator<T>): DequeIterator<T>;
|
||||
find(element: T): DequeIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
/**
|
||||
* @description Remove as much useless space as possible.
|
||||
*/
|
||||
shrinkToFit(): void;
|
||||
[Symbol.iterator](): Generator<T, void, unknown>;
|
||||
}
|
||||
export default Deque;
|
||||
493
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js
generated
vendored
Normal file
493
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js
generated
vendored
Normal file
@@ -0,0 +1,493 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(t, i) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(t, i) {
|
||||
t.__proto__ = i;
|
||||
} || function(t, i) {
|
||||
for (var e in i) if (Object.prototype.hasOwnProperty.call(i, e)) t[e] = i[e];
|
||||
};
|
||||
return extendStatics(t, i);
|
||||
};
|
||||
return function(t, i) {
|
||||
if (typeof i !== "function" && i !== null) throw new TypeError("Class extends value " + String(i) + " is not a constructor or null");
|
||||
extendStatics(t, i);
|
||||
function __() {
|
||||
this.constructor = t;
|
||||
}
|
||||
t.prototype = i === null ? Object.create(i) : (__.prototype = i.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(t, i) {
|
||||
var e = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (h[0] & 1) throw h[1];
|
||||
return h[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, r, s, h, n;
|
||||
return n = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (n[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), n;
|
||||
function verb(t) {
|
||||
return function(i) {
|
||||
return step([ t, i ]);
|
||||
};
|
||||
}
|
||||
function step(n) {
|
||||
if (r) throw new TypeError("Generator is already executing.");
|
||||
while (e) try {
|
||||
if (r = 1, s && (h = n[0] & 2 ? s["return"] : n[0] ? s["throw"] || ((h = s["return"]) && h.call(s),
|
||||
0) : s.next) && !(h = h.call(s, n[1])).done) return h;
|
||||
if (s = 0, h) n = [ n[0] & 2, h.value ];
|
||||
switch (n[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
h = n;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
e.label++;
|
||||
return {
|
||||
value: n[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
e.label++;
|
||||
s = n[1];
|
||||
n = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
n = e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(h = e.trys, h = h.length > 0 && h[h.length - 1]) && (n[0] === 6 || n[0] === 2)) {
|
||||
e = 0;
|
||||
continue;
|
||||
}
|
||||
if (n[0] === 3 && (!h || n[1] > h[0] && n[1] < h[3])) {
|
||||
e.label = n[1];
|
||||
break;
|
||||
}
|
||||
if (n[0] === 6 && e.label < h[1]) {
|
||||
e.label = h[1];
|
||||
h = n;
|
||||
break;
|
||||
}
|
||||
if (h && e.label < h[2]) {
|
||||
e.label = h[2];
|
||||
e.ops.push(n);
|
||||
break;
|
||||
}
|
||||
if (h[2]) e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
}
|
||||
n = i.call(t, e);
|
||||
} catch (t) {
|
||||
n = [ 6, t ];
|
||||
s = 0;
|
||||
} finally {
|
||||
r = h = 0;
|
||||
}
|
||||
if (n[0] & 5) throw n[1];
|
||||
return {
|
||||
value: n[0] ? n[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __read = this && this._ || function(t, i) {
|
||||
var e = typeof Symbol === "function" && t[Symbol.iterator];
|
||||
if (!e) return t;
|
||||
var r = e.call(t), s, h = [], n;
|
||||
try {
|
||||
while ((i === void 0 || i-- > 0) && !(s = r.next()).done) h.push(s.value);
|
||||
} catch (t) {
|
||||
n = {
|
||||
error: t
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (s && !s.done && (e = r["return"])) e.call(r);
|
||||
} finally {
|
||||
if (n) throw n.error;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
};
|
||||
|
||||
var __spreadArray = this && this.P || function(t, i, e) {
|
||||
if (e || arguments.length === 2) for (var r = 0, s = i.length, h; r < s; r++) {
|
||||
if (h || !(r in i)) {
|
||||
if (!h) h = Array.prototype.slice.call(i, 0, r);
|
||||
h[r] = i[r];
|
||||
}
|
||||
}
|
||||
return t.concat(h || Array.prototype.slice.call(i));
|
||||
};
|
||||
|
||||
import SequentialContainer from "./Base";
|
||||
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
|
||||
var DequeIterator = function(t) {
|
||||
__extends(DequeIterator, t);
|
||||
function DequeIterator() {
|
||||
return t !== null && t.apply(this, arguments) || this;
|
||||
}
|
||||
DequeIterator.prototype.copy = function() {
|
||||
return new DequeIterator(this.D, this.I, this.g, this.R, this.iteratorType);
|
||||
};
|
||||
return DequeIterator;
|
||||
}(RandomIterator);
|
||||
|
||||
export { DequeIterator };
|
||||
|
||||
var Deque = function(t) {
|
||||
__extends(Deque, t);
|
||||
function Deque(i, e) {
|
||||
if (i === void 0) {
|
||||
i = [];
|
||||
}
|
||||
if (e === void 0) {
|
||||
e = 1 << 12;
|
||||
}
|
||||
var r = t.call(this) || this;
|
||||
r.M = 0;
|
||||
r.k = 0;
|
||||
r.C = 0;
|
||||
r.O = 0;
|
||||
r.l = 0;
|
||||
r.N = [];
|
||||
var s;
|
||||
if ("size" in i) {
|
||||
if (typeof i.size === "number") {
|
||||
s = i.size;
|
||||
} else {
|
||||
s = i.size();
|
||||
}
|
||||
} else if ("length" in i) {
|
||||
s = i.length;
|
||||
} else {
|
||||
throw new RangeError("Can't get container's size!");
|
||||
}
|
||||
r.T = e;
|
||||
r.l = Math.max(Math.ceil(s / r.T), 1);
|
||||
for (var h = 0; h < r.l; ++h) {
|
||||
r.N.push(new Array(r.T));
|
||||
}
|
||||
var n = Math.ceil(s / r.T);
|
||||
r.M = r.C = (r.l >> 1) - (n >> 1);
|
||||
r.k = r.O = r.T - s % r.T >> 1;
|
||||
i.forEach((function(t) {
|
||||
return r.pushBack(t);
|
||||
}));
|
||||
r.size = r.size.bind(r);
|
||||
r.getElementByPos = r.getElementByPos.bind(r);
|
||||
r.setElementByPos = r.setElementByPos.bind(r);
|
||||
return r;
|
||||
}
|
||||
Deque.prototype.v = function() {
|
||||
var t = [];
|
||||
var i = Math.max(this.l >> 1, 1);
|
||||
for (var e = 0; e < i; ++e) {
|
||||
t[e] = new Array(this.T);
|
||||
}
|
||||
for (var e = this.M; e < this.l; ++e) {
|
||||
t[t.length] = this.N[e];
|
||||
}
|
||||
for (var e = 0; e < this.C; ++e) {
|
||||
t[t.length] = this.N[e];
|
||||
}
|
||||
t[t.length] = __spreadArray([], __read(this.N[this.C]), false);
|
||||
this.M = i;
|
||||
this.C = t.length - 1;
|
||||
for (var e = 0; e < i; ++e) {
|
||||
t[t.length] = new Array(this.T);
|
||||
}
|
||||
this.N = t;
|
||||
this.l = t.length;
|
||||
};
|
||||
Deque.prototype.G = function(t) {
|
||||
var i = this.k + t + 1;
|
||||
var e = i % this.T;
|
||||
var r = e - 1;
|
||||
var s = this.M + (i - e) / this.T;
|
||||
if (e === 0) s -= 1;
|
||||
s %= this.l;
|
||||
if (r < 0) r += this.T;
|
||||
return {
|
||||
curNodeBucketIndex: s,
|
||||
curNodePointerIndex: r
|
||||
};
|
||||
};
|
||||
Deque.prototype.clear = function() {
|
||||
this.N = [ [] ];
|
||||
this.l = 1;
|
||||
this.M = this.C = this.o = 0;
|
||||
this.k = this.O = this.T >> 1;
|
||||
};
|
||||
Deque.prototype.front = function() {
|
||||
return this.N[this.M][this.k];
|
||||
};
|
||||
Deque.prototype.back = function() {
|
||||
return this.N[this.C][this.O];
|
||||
};
|
||||
Deque.prototype.begin = function() {
|
||||
return new DequeIterator(0, this.size, this.getElementByPos, this.setElementByPos);
|
||||
};
|
||||
Deque.prototype.end = function() {
|
||||
return new DequeIterator(this.o, this.size, this.getElementByPos, this.setElementByPos);
|
||||
};
|
||||
Deque.prototype.rBegin = function() {
|
||||
return new DequeIterator(this.o - 1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
};
|
||||
Deque.prototype.rEnd = function() {
|
||||
return new DequeIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
};
|
||||
Deque.prototype.pushBack = function(t) {
|
||||
if (this.o) {
|
||||
if (this.O < this.T - 1) {
|
||||
this.O += 1;
|
||||
} else if (this.C < this.l - 1) {
|
||||
this.C += 1;
|
||||
this.O = 0;
|
||||
} else {
|
||||
this.C = 0;
|
||||
this.O = 0;
|
||||
}
|
||||
if (this.C === this.M && this.O === this.k) this.v();
|
||||
}
|
||||
this.o += 1;
|
||||
this.N[this.C][this.O] = t;
|
||||
};
|
||||
Deque.prototype.popBack = function() {
|
||||
if (!this.o) return;
|
||||
this.N[this.C][this.O] = undefined;
|
||||
if (this.o !== 1) {
|
||||
if (this.O > 0) {
|
||||
this.O -= 1;
|
||||
} else if (this.C > 0) {
|
||||
this.C -= 1;
|
||||
this.O = this.T - 1;
|
||||
} else {
|
||||
this.C = this.l - 1;
|
||||
this.O = this.T - 1;
|
||||
}
|
||||
}
|
||||
this.o -= 1;
|
||||
};
|
||||
Deque.prototype.pushFront = function(t) {
|
||||
if (this.o) {
|
||||
if (this.k > 0) {
|
||||
this.k -= 1;
|
||||
} else if (this.M > 0) {
|
||||
this.M -= 1;
|
||||
this.k = this.T - 1;
|
||||
} else {
|
||||
this.M = this.l - 1;
|
||||
this.k = this.T - 1;
|
||||
}
|
||||
if (this.M === this.C && this.k === this.O) this.v();
|
||||
}
|
||||
this.o += 1;
|
||||
this.N[this.M][this.k] = t;
|
||||
};
|
||||
Deque.prototype.popFront = function() {
|
||||
if (!this.o) return;
|
||||
this.N[this.M][this.k] = undefined;
|
||||
if (this.o !== 1) {
|
||||
if (this.k < this.T - 1) {
|
||||
this.k += 1;
|
||||
} else if (this.M < this.l - 1) {
|
||||
this.M += 1;
|
||||
this.k = 0;
|
||||
} else {
|
||||
this.M = 0;
|
||||
this.k = 0;
|
||||
}
|
||||
}
|
||||
this.o -= 1;
|
||||
};
|
||||
Deque.prototype.forEach = function(t) {
|
||||
for (var i = 0; i < this.o; ++i) {
|
||||
t(this.getElementByPos(i), i);
|
||||
}
|
||||
};
|
||||
Deque.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var i = this.G(t), e = i.curNodeBucketIndex, r = i.curNodePointerIndex;
|
||||
return this.N[e][r];
|
||||
};
|
||||
Deque.prototype.setElementByPos = function(t, i) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var e = this.G(t), r = e.curNodeBucketIndex, s = e.curNodePointerIndex;
|
||||
this.N[r][s] = i;
|
||||
};
|
||||
Deque.prototype.insert = function(t, i, e) {
|
||||
if (e === void 0) {
|
||||
e = 1;
|
||||
}
|
||||
if (t < 0 || t > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) {
|
||||
while (e--) this.pushFront(i);
|
||||
} else if (t === this.o) {
|
||||
while (e--) this.pushBack(i);
|
||||
} else {
|
||||
var r = [];
|
||||
for (var s = t; s < this.o; ++s) {
|
||||
r.push(this.getElementByPos(s));
|
||||
}
|
||||
this.cut(t - 1);
|
||||
for (var s = 0; s < e; ++s) this.pushBack(i);
|
||||
for (var s = 0; s < r.length; ++s) this.pushBack(r[s]);
|
||||
}
|
||||
};
|
||||
Deque.prototype.cut = function(t) {
|
||||
if (t < 0) {
|
||||
this.clear();
|
||||
return;
|
||||
}
|
||||
var i = this.G(t), e = i.curNodeBucketIndex, r = i.curNodePointerIndex;
|
||||
this.C = e;
|
||||
this.O = r;
|
||||
this.o = t + 1;
|
||||
};
|
||||
Deque.prototype.eraseElementByPos = function(t) {
|
||||
var i = this;
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (t === 0) this.popFront(); else if (t === this.o - 1) this.popBack(); else {
|
||||
var e = [];
|
||||
for (var r = t + 1; r < this.o; ++r) {
|
||||
e.push(this.getElementByPos(r));
|
||||
}
|
||||
this.cut(t);
|
||||
this.popBack();
|
||||
e.forEach((function(t) {
|
||||
return i.pushBack(t);
|
||||
}));
|
||||
}
|
||||
};
|
||||
Deque.prototype.eraseElementByValue = function(t) {
|
||||
if (!this.o) return;
|
||||
var i = [];
|
||||
for (var e = 0; e < this.o; ++e) {
|
||||
var r = this.getElementByPos(e);
|
||||
if (r !== t) i.push(r);
|
||||
}
|
||||
var s = i.length;
|
||||
for (var e = 0; e < s; ++e) this.setElementByPos(e, i[e]);
|
||||
this.cut(s - 1);
|
||||
};
|
||||
Deque.prototype.eraseElementByIterator = function(t) {
|
||||
var i = t.D;
|
||||
this.eraseElementByPos(i);
|
||||
t = t.next();
|
||||
return t;
|
||||
};
|
||||
Deque.prototype.find = function(t) {
|
||||
for (var i = 0; i < this.o; ++i) {
|
||||
if (this.getElementByPos(i) === t) {
|
||||
return new DequeIterator(i, this.size, this.getElementByPos, this.setElementByPos);
|
||||
}
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
Deque.prototype.reverse = function() {
|
||||
var t = 0;
|
||||
var i = this.o - 1;
|
||||
while (t < i) {
|
||||
var e = this.getElementByPos(t);
|
||||
this.setElementByPos(t, this.getElementByPos(i));
|
||||
this.setElementByPos(i, e);
|
||||
t += 1;
|
||||
i -= 1;
|
||||
}
|
||||
};
|
||||
Deque.prototype.unique = function() {
|
||||
if (this.o <= 1) return;
|
||||
var t = 1;
|
||||
var i = this.getElementByPos(0);
|
||||
for (var e = 1; e < this.o; ++e) {
|
||||
var r = this.getElementByPos(e);
|
||||
if (r !== i) {
|
||||
i = r;
|
||||
this.setElementByPos(t++, r);
|
||||
}
|
||||
}
|
||||
while (this.o > t) this.popBack();
|
||||
};
|
||||
Deque.prototype.sort = function(t) {
|
||||
var i = [];
|
||||
for (var e = 0; e < this.o; ++e) {
|
||||
i.push(this.getElementByPos(e));
|
||||
}
|
||||
i.sort(t);
|
||||
for (var e = 0; e < this.o; ++e) this.setElementByPos(e, i[e]);
|
||||
};
|
||||
Deque.prototype.shrinkToFit = function() {
|
||||
if (!this.o) return;
|
||||
var t = [];
|
||||
this.forEach((function(i) {
|
||||
return t.push(i);
|
||||
}));
|
||||
this.l = Math.max(Math.ceil(this.o / this.T), 1);
|
||||
this.o = this.M = this.C = this.k = this.O = 0;
|
||||
this.N = [];
|
||||
for (var i = 0; i < this.l; ++i) {
|
||||
this.N.push(new Array(this.T));
|
||||
}
|
||||
for (var i = 0; i < t.length; ++i) this.pushBack(t[i]);
|
||||
};
|
||||
Deque.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var t;
|
||||
return __generator(this, (function(i) {
|
||||
switch (i.label) {
|
||||
case 0:
|
||||
t = 0;
|
||||
i.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(t < this.o)) return [ 3, 4 ];
|
||||
return [ 4, this.getElementByPos(t) ];
|
||||
|
||||
case 2:
|
||||
i.sent();
|
||||
i.label = 3;
|
||||
|
||||
case 3:
|
||||
++t;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 4:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return Deque;
|
||||
}(SequentialContainer);
|
||||
|
||||
export default Deque;
|
||||
49
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.d.ts
generated
vendored
Normal file
49
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.d.ts
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { ContainerIterator, initContainer } from "../ContainerBase";
|
||||
export declare class LinkListIterator<T> extends ContainerIterator<T> {
|
||||
pre: () => this;
|
||||
next: () => this;
|
||||
get pointer(): T;
|
||||
set pointer(newValue: T);
|
||||
equals(obj: LinkListIterator<T>): boolean;
|
||||
copy(): LinkListIterator<T>;
|
||||
}
|
||||
declare class LinkList<T> extends SequentialContainer<T> {
|
||||
constructor(container?: initContainer<T>);
|
||||
clear(): void;
|
||||
begin(): LinkListIterator<T>;
|
||||
end(): LinkListIterator<T>;
|
||||
rBegin(): LinkListIterator<T>;
|
||||
rEnd(): LinkListIterator<T>;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(_value: T): void;
|
||||
eraseElementByIterator(iter: LinkListIterator<T>): LinkListIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
find(element: T): LinkListIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
/**
|
||||
* @description Push an element to the front.
|
||||
* @param element The element you want to push.
|
||||
*/
|
||||
pushFront(element: T): void;
|
||||
/**
|
||||
* @description Removes the first element.
|
||||
*/
|
||||
popFront(): void;
|
||||
/**
|
||||
* @description Merges two sorted lists.
|
||||
* @param list The other list you want to merge (must be sorted).
|
||||
*/
|
||||
merge(list: LinkList<T>): void;
|
||||
[Symbol.iterator](): Generator<T, void, unknown>;
|
||||
}
|
||||
export default LinkList;
|
||||
500
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js
generated
vendored
Normal file
500
node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js
generated
vendored
Normal file
@@ -0,0 +1,500 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(i, t) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(i, t) {
|
||||
i.__proto__ = t;
|
||||
} || function(i, t) {
|
||||
for (var n in t) if (Object.prototype.hasOwnProperty.call(t, n)) i[n] = t[n];
|
||||
};
|
||||
return extendStatics(i, t);
|
||||
};
|
||||
return function(i, t) {
|
||||
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
||||
extendStatics(i, t);
|
||||
function __() {
|
||||
this.constructor = i;
|
||||
}
|
||||
i.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(i, t) {
|
||||
var n = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (s[0] & 1) throw s[1];
|
||||
return s[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, r, e, s, h;
|
||||
return h = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (h[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), h;
|
||||
function verb(i) {
|
||||
return function(t) {
|
||||
return step([ i, t ]);
|
||||
};
|
||||
}
|
||||
function step(h) {
|
||||
if (r) throw new TypeError("Generator is already executing.");
|
||||
while (n) try {
|
||||
if (r = 1, e && (s = h[0] & 2 ? e["return"] : h[0] ? e["throw"] || ((s = e["return"]) && s.call(e),
|
||||
0) : e.next) && !(s = s.call(e, h[1])).done) return s;
|
||||
if (e = 0, s) h = [ h[0] & 2, s.value ];
|
||||
switch (h[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
s = h;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
n.label++;
|
||||
return {
|
||||
value: h[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
n.label++;
|
||||
e = h[1];
|
||||
h = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
h = n.ops.pop();
|
||||
n.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(s = n.trys, s = s.length > 0 && s[s.length - 1]) && (h[0] === 6 || h[0] === 2)) {
|
||||
n = 0;
|
||||
continue;
|
||||
}
|
||||
if (h[0] === 3 && (!s || h[1] > s[0] && h[1] < s[3])) {
|
||||
n.label = h[1];
|
||||
break;
|
||||
}
|
||||
if (h[0] === 6 && n.label < s[1]) {
|
||||
n.label = s[1];
|
||||
s = h;
|
||||
break;
|
||||
}
|
||||
if (s && n.label < s[2]) {
|
||||
n.label = s[2];
|
||||
n.ops.push(h);
|
||||
break;
|
||||
}
|
||||
if (s[2]) n.ops.pop();
|
||||
n.trys.pop();
|
||||
continue;
|
||||
}
|
||||
h = t.call(i, n);
|
||||
} catch (i) {
|
||||
h = [ 6, i ];
|
||||
e = 0;
|
||||
} finally {
|
||||
r = s = 0;
|
||||
}
|
||||
if (h[0] & 5) throw h[1];
|
||||
return {
|
||||
value: h[0] ? h[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
import SequentialContainer from "./Base";
|
||||
|
||||
import { ContainerIterator } from "../ContainerBase";
|
||||
|
||||
var LinkNode = function() {
|
||||
function LinkNode(i) {
|
||||
this.L = undefined;
|
||||
this.F = undefined;
|
||||
this.H = undefined;
|
||||
this.L = i;
|
||||
}
|
||||
return LinkNode;
|
||||
}();
|
||||
|
||||
export { LinkNode };
|
||||
|
||||
var LinkListIterator = function(i) {
|
||||
__extends(LinkListIterator, i);
|
||||
function LinkListIterator(t, n, r) {
|
||||
var e = i.call(this, r) || this;
|
||||
e.D = t;
|
||||
e.J = n;
|
||||
if (e.iteratorType === 0) {
|
||||
e.pre = function() {
|
||||
if (this.D.F === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D = this.D.F;
|
||||
return this;
|
||||
};
|
||||
e.next = function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D = this.D.H;
|
||||
return this;
|
||||
};
|
||||
} else {
|
||||
e.pre = function() {
|
||||
if (this.D.H === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D = this.D.H;
|
||||
return this;
|
||||
};
|
||||
e.next = function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D = this.D.F;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
return e;
|
||||
}
|
||||
Object.defineProperty(LinkListIterator.prototype, "pointer", {
|
||||
get: function() {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
return this.D.L;
|
||||
},
|
||||
set: function(i) {
|
||||
if (this.D === this.J) {
|
||||
throw new RangeError("LinkList iterator access denied!");
|
||||
}
|
||||
this.D.L = i;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
LinkListIterator.prototype.equals = function(i) {
|
||||
return this.D === i.D;
|
||||
};
|
||||
LinkListIterator.prototype.copy = function() {
|
||||
return new LinkListIterator(this.D, this.J, this.iteratorType);
|
||||
};
|
||||
return LinkListIterator;
|
||||
}(ContainerIterator);
|
||||
|
||||
export { LinkListIterator };
|
||||
|
||||
var LinkList = function(i) {
|
||||
__extends(LinkList, i);
|
||||
function LinkList(t) {
|
||||
if (t === void 0) {
|
||||
t = [];
|
||||
}
|
||||
var n = i.call(this) || this;
|
||||
n.J = new LinkNode;
|
||||
n.K = undefined;
|
||||
n.U = undefined;
|
||||
t.forEach((function(i) {
|
||||
return n.pushBack(i);
|
||||
}));
|
||||
return n;
|
||||
}
|
||||
LinkList.prototype.clear = function() {
|
||||
this.o = 0;
|
||||
this.K = this.U = undefined;
|
||||
this.J.F = this.J.H = undefined;
|
||||
};
|
||||
LinkList.prototype.begin = function() {
|
||||
return new LinkListIterator(this.K || this.J, this.J);
|
||||
};
|
||||
LinkList.prototype.end = function() {
|
||||
return new LinkListIterator(this.J, this.J);
|
||||
};
|
||||
LinkList.prototype.rBegin = function() {
|
||||
return new LinkListIterator(this.U || this.J, this.J, 1);
|
||||
};
|
||||
LinkList.prototype.rEnd = function() {
|
||||
return new LinkListIterator(this.J, this.J, 1);
|
||||
};
|
||||
LinkList.prototype.front = function() {
|
||||
return this.K ? this.K.L : undefined;
|
||||
};
|
||||
LinkList.prototype.back = function() {
|
||||
return this.U ? this.U.L : undefined;
|
||||
};
|
||||
LinkList.prototype.forEach = function(i) {
|
||||
if (!this.o) return;
|
||||
var t = this.K;
|
||||
var n = 0;
|
||||
while (t !== this.J) {
|
||||
i(t.L, n++);
|
||||
t = t.H;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.getElementByPos = function(i) {
|
||||
if (i < 0 || i > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var t = this.K;
|
||||
while (i--) {
|
||||
t = t.H;
|
||||
}
|
||||
return t.L;
|
||||
};
|
||||
LinkList.prototype.eraseElementByPos = function(i) {
|
||||
if (i < 0 || i > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (i === 0) this.popFront(); else if (i === this.o - 1) this.popBack(); else {
|
||||
var t = this.K;
|
||||
while (i--) {
|
||||
t = t.H;
|
||||
}
|
||||
t = t;
|
||||
var n = t.F;
|
||||
var r = t.H;
|
||||
r.F = n;
|
||||
n.H = r;
|
||||
this.o -= 1;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.eraseElementByValue = function(i) {
|
||||
while (this.K && this.K.L === i) this.popFront();
|
||||
while (this.U && this.U.L === i) this.popBack();
|
||||
if (!this.K) return;
|
||||
var t = this.K;
|
||||
while (t !== this.J) {
|
||||
if (t.L === i) {
|
||||
var n = t.F;
|
||||
var r = t.H;
|
||||
r.F = n;
|
||||
n.H = r;
|
||||
this.o -= 1;
|
||||
}
|
||||
t = t.H;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.eraseElementByIterator = function(i) {
|
||||
var t = i.D;
|
||||
if (t === this.J) {
|
||||
throw new RangeError("Invalid iterator");
|
||||
}
|
||||
i = i.next();
|
||||
if (this.K === t) this.popFront(); else if (this.U === t) this.popBack(); else {
|
||||
var n = t.F;
|
||||
var r = t.H;
|
||||
r.F = n;
|
||||
n.H = r;
|
||||
this.o -= 1;
|
||||
}
|
||||
return i;
|
||||
};
|
||||
LinkList.prototype.pushBack = function(i) {
|
||||
this.o += 1;
|
||||
var t = new LinkNode(i);
|
||||
if (!this.U) {
|
||||
this.K = this.U = t;
|
||||
this.J.H = this.K;
|
||||
this.K.F = this.J;
|
||||
} else {
|
||||
this.U.H = t;
|
||||
t.F = this.U;
|
||||
this.U = t;
|
||||
}
|
||||
this.U.H = this.J;
|
||||
this.J.F = this.U;
|
||||
};
|
||||
LinkList.prototype.popBack = function() {
|
||||
if (!this.U) return;
|
||||
this.o -= 1;
|
||||
if (this.K === this.U) {
|
||||
this.K = this.U = undefined;
|
||||
this.J.H = undefined;
|
||||
} else {
|
||||
this.U = this.U.F;
|
||||
this.U.H = this.J;
|
||||
}
|
||||
this.J.F = this.U;
|
||||
};
|
||||
LinkList.prototype.setElementByPos = function(i, t) {
|
||||
if (i < 0 || i > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
var n = this.K;
|
||||
while (i--) {
|
||||
n = n.H;
|
||||
}
|
||||
n.L = t;
|
||||
};
|
||||
LinkList.prototype.insert = function(i, t, n) {
|
||||
if (n === void 0) {
|
||||
n = 1;
|
||||
}
|
||||
if (i < 0 || i > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
if (n <= 0) return;
|
||||
if (i === 0) {
|
||||
while (n--) this.pushFront(t);
|
||||
} else if (i === this.o) {
|
||||
while (n--) this.pushBack(t);
|
||||
} else {
|
||||
var r = this.K;
|
||||
for (var e = 1; e < i; ++e) {
|
||||
r = r.H;
|
||||
}
|
||||
var s = r.H;
|
||||
this.o += n;
|
||||
while (n--) {
|
||||
r.H = new LinkNode(t);
|
||||
r.H.F = r;
|
||||
r = r.H;
|
||||
}
|
||||
r.H = s;
|
||||
s.F = r;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.find = function(i) {
|
||||
if (!this.K) return this.end();
|
||||
var t = this.K;
|
||||
while (t !== this.J) {
|
||||
if (t.L === i) {
|
||||
return new LinkListIterator(t, this.J);
|
||||
}
|
||||
t = t.H;
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
LinkList.prototype.reverse = function() {
|
||||
if (this.o <= 1) return;
|
||||
var i = this.K;
|
||||
var t = this.U;
|
||||
var n = 0;
|
||||
while (n << 1 < this.o) {
|
||||
var r = i.L;
|
||||
i.L = t.L;
|
||||
t.L = r;
|
||||
i = i.H;
|
||||
t = t.F;
|
||||
n += 1;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.unique = function() {
|
||||
if (this.o <= 1) return;
|
||||
var i = this.K;
|
||||
while (i !== this.J) {
|
||||
var t = i;
|
||||
while (t.H && t.L === t.H.L) {
|
||||
t = t.H;
|
||||
this.o -= 1;
|
||||
}
|
||||
i.H = t.H;
|
||||
i.H.F = i;
|
||||
i = i.H;
|
||||
}
|
||||
};
|
||||
LinkList.prototype.sort = function(i) {
|
||||
if (this.o <= 1) return;
|
||||
var t = [];
|
||||
this.forEach((function(i) {
|
||||
return t.push(i);
|
||||
}));
|
||||
t.sort(i);
|
||||
var n = this.K;
|
||||
t.forEach((function(i) {
|
||||
n.L = i;
|
||||
n = n.H;
|
||||
}));
|
||||
};
|
||||
LinkList.prototype.pushFront = function(i) {
|
||||
this.o += 1;
|
||||
var t = new LinkNode(i);
|
||||
if (!this.K) {
|
||||
this.K = this.U = t;
|
||||
this.U.H = this.J;
|
||||
this.J.F = this.U;
|
||||
} else {
|
||||
t.H = this.K;
|
||||
this.K.F = t;
|
||||
this.K = t;
|
||||
}
|
||||
this.J.H = this.K;
|
||||
this.K.F = this.J;
|
||||
};
|
||||
LinkList.prototype.popFront = function() {
|
||||
if (!this.K) return;
|
||||
this.o -= 1;
|
||||
if (this.K === this.U) {
|
||||
this.K = this.U = undefined;
|
||||
this.J.F = this.U;
|
||||
} else {
|
||||
this.K = this.K.H;
|
||||
this.K.F = this.J;
|
||||
}
|
||||
this.J.H = this.K;
|
||||
};
|
||||
LinkList.prototype.merge = function(i) {
|
||||
var t = this;
|
||||
if (!this.K) {
|
||||
i.forEach((function(i) {
|
||||
return t.pushBack(i);
|
||||
}));
|
||||
return;
|
||||
}
|
||||
var n = this.K;
|
||||
i.forEach((function(i) {
|
||||
while (n && n !== t.J && n.L <= i) {
|
||||
n = n.H;
|
||||
}
|
||||
if (n === t.J) {
|
||||
t.pushBack(i);
|
||||
n = t.U;
|
||||
} else if (n === t.K) {
|
||||
t.pushFront(i);
|
||||
n = t.K;
|
||||
} else {
|
||||
t.o += 1;
|
||||
var r = n.F;
|
||||
r.H = new LinkNode(i);
|
||||
r.H.F = r;
|
||||
r.H.H = n;
|
||||
n.F = r.H;
|
||||
}
|
||||
}));
|
||||
};
|
||||
LinkList.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
var i;
|
||||
return __generator(this, (function(t) {
|
||||
switch (t.label) {
|
||||
case 0:
|
||||
if (!this.K) return [ 2 ];
|
||||
i = this.K;
|
||||
t.label = 1;
|
||||
|
||||
case 1:
|
||||
if (!(i !== this.J)) return [ 3, 3 ];
|
||||
return [ 4, i.L ];
|
||||
|
||||
case 2:
|
||||
t.sent();
|
||||
i = i.H;
|
||||
return [ 3, 1 ];
|
||||
|
||||
case 3:
|
||||
return [ 2 ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return LinkList;
|
||||
}(SequentialContainer);
|
||||
|
||||
export default LinkList;
|
||||
37
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.d.ts
generated
vendored
Normal file
37
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import SequentialContainer from './Base';
|
||||
import { initContainer } from "../ContainerBase";
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
export declare class VectorIterator<T> extends RandomIterator<T> {
|
||||
copy(): VectorIterator<T>;
|
||||
}
|
||||
declare class Vector<T> extends SequentialContainer<T> {
|
||||
/**
|
||||
* @description Vector's constructor.
|
||||
* @param container Initialize container, must have a forEach function.
|
||||
* @param copy When the container is an array, you can choose to directly operate on the original object of
|
||||
* the array or perform a shallow copy. The default is shallow copy.
|
||||
*/
|
||||
constructor(container?: initContainer<T>, copy?: boolean);
|
||||
clear(): void;
|
||||
begin(): VectorIterator<T>;
|
||||
end(): VectorIterator<T>;
|
||||
rBegin(): VectorIterator<T>;
|
||||
rEnd(): VectorIterator<T>;
|
||||
front(): T | undefined;
|
||||
back(): T | undefined;
|
||||
forEach(callback: (element: T, index: number) => void): void;
|
||||
getElementByPos(pos: number): T;
|
||||
eraseElementByPos(pos: number): void;
|
||||
eraseElementByValue(value: T): void;
|
||||
eraseElementByIterator(iter: VectorIterator<T>): VectorIterator<T>;
|
||||
pushBack(element: T): void;
|
||||
popBack(): void;
|
||||
setElementByPos(pos: number, element: T): void;
|
||||
insert(pos: number, element: T, num?: number): void;
|
||||
find(element: T): VectorIterator<T>;
|
||||
reverse(): void;
|
||||
unique(): void;
|
||||
sort(cmp?: (x: T, y: T) => number): void;
|
||||
[Symbol.iterator](): Generator<T, any, undefined>;
|
||||
}
|
||||
export default Vector;
|
||||
318
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js
generated
vendored
Normal file
318
node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js
generated
vendored
Normal file
@@ -0,0 +1,318 @@
|
||||
var __extends = this && this.t || function() {
|
||||
var extendStatics = function(t, r) {
|
||||
extendStatics = Object.setPrototypeOf || {
|
||||
__proto__: []
|
||||
} instanceof Array && function(t, r) {
|
||||
t.__proto__ = r;
|
||||
} || function(t, r) {
|
||||
for (var e in r) if (Object.prototype.hasOwnProperty.call(r, e)) t[e] = r[e];
|
||||
};
|
||||
return extendStatics(t, r);
|
||||
};
|
||||
return function(t, r) {
|
||||
if (typeof r !== "function" && r !== null) throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
||||
extendStatics(t, r);
|
||||
function __() {
|
||||
this.constructor = t;
|
||||
}
|
||||
t.prototype = r === null ? Object.create(r) : (__.prototype = r.prototype, new __);
|
||||
};
|
||||
}();
|
||||
|
||||
var __generator = this && this.i || function(t, r) {
|
||||
var e = {
|
||||
label: 0,
|
||||
sent: function() {
|
||||
if (o[0] & 1) throw o[1];
|
||||
return o[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: []
|
||||
}, n, i, o, s;
|
||||
return s = {
|
||||
next: verb(0),
|
||||
throw: verb(1),
|
||||
return: verb(2)
|
||||
}, typeof Symbol === "function" && (s[Symbol.iterator] = function() {
|
||||
return this;
|
||||
}), s;
|
||||
function verb(t) {
|
||||
return function(r) {
|
||||
return step([ t, r ]);
|
||||
};
|
||||
}
|
||||
function step(s) {
|
||||
if (n) throw new TypeError("Generator is already executing.");
|
||||
while (e) try {
|
||||
if (n = 1, i && (o = s[0] & 2 ? i["return"] : s[0] ? i["throw"] || ((o = i["return"]) && o.call(i),
|
||||
0) : i.next) && !(o = o.call(i, s[1])).done) return o;
|
||||
if (i = 0, o) s = [ s[0] & 2, o.value ];
|
||||
switch (s[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
o = s;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
e.label++;
|
||||
return {
|
||||
value: s[1],
|
||||
done: false
|
||||
};
|
||||
|
||||
case 5:
|
||||
e.label++;
|
||||
i = s[1];
|
||||
s = [ 0 ];
|
||||
continue;
|
||||
|
||||
case 7:
|
||||
s = e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (!(o = e.trys, o = o.length > 0 && o[o.length - 1]) && (s[0] === 6 || s[0] === 2)) {
|
||||
e = 0;
|
||||
continue;
|
||||
}
|
||||
if (s[0] === 3 && (!o || s[1] > o[0] && s[1] < o[3])) {
|
||||
e.label = s[1];
|
||||
break;
|
||||
}
|
||||
if (s[0] === 6 && e.label < o[1]) {
|
||||
e.label = o[1];
|
||||
o = s;
|
||||
break;
|
||||
}
|
||||
if (o && e.label < o[2]) {
|
||||
e.label = o[2];
|
||||
e.ops.push(s);
|
||||
break;
|
||||
}
|
||||
if (o[2]) e.ops.pop();
|
||||
e.trys.pop();
|
||||
continue;
|
||||
}
|
||||
s = r.call(t, e);
|
||||
} catch (t) {
|
||||
s = [ 6, t ];
|
||||
i = 0;
|
||||
} finally {
|
||||
n = o = 0;
|
||||
}
|
||||
if (s[0] & 5) throw s[1];
|
||||
return {
|
||||
value: s[0] ? s[1] : void 0,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var __read = this && this._ || function(t, r) {
|
||||
var e = typeof Symbol === "function" && t[Symbol.iterator];
|
||||
if (!e) return t;
|
||||
var n = e.call(t), i, o = [], s;
|
||||
try {
|
||||
while ((r === void 0 || r-- > 0) && !(i = n.next()).done) o.push(i.value);
|
||||
} catch (t) {
|
||||
s = {
|
||||
error: t
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (i && !i.done && (e = n["return"])) e.call(n);
|
||||
} finally {
|
||||
if (s) throw s.error;
|
||||
}
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
var __spreadArray = this && this.P || function(t, r, e) {
|
||||
if (e || arguments.length === 2) for (var n = 0, i = r.length, o; n < i; n++) {
|
||||
if (o || !(n in r)) {
|
||||
if (!o) o = Array.prototype.slice.call(r, 0, n);
|
||||
o[n] = r[n];
|
||||
}
|
||||
}
|
||||
return t.concat(o || Array.prototype.slice.call(r));
|
||||
};
|
||||
|
||||
var __values = this && this.u || function(t) {
|
||||
var r = typeof Symbol === "function" && Symbol.iterator, e = r && t[r], n = 0;
|
||||
if (e) return e.call(t);
|
||||
if (t && typeof t.length === "number") return {
|
||||
next: function() {
|
||||
if (t && n >= t.length) t = void 0;
|
||||
return {
|
||||
value: t && t[n++],
|
||||
done: !t
|
||||
};
|
||||
}
|
||||
};
|
||||
throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
|
||||
import SequentialContainer from "./Base";
|
||||
|
||||
import { RandomIterator } from "./Base/RandomIterator";
|
||||
|
||||
var VectorIterator = function(t) {
|
||||
__extends(VectorIterator, t);
|
||||
function VectorIterator() {
|
||||
return t !== null && t.apply(this, arguments) || this;
|
||||
}
|
||||
VectorIterator.prototype.copy = function() {
|
||||
return new VectorIterator(this.D, this.I, this.g, this.R, this.iteratorType);
|
||||
};
|
||||
return VectorIterator;
|
||||
}(RandomIterator);
|
||||
|
||||
export { VectorIterator };
|
||||
|
||||
var Vector = function(t) {
|
||||
__extends(Vector, t);
|
||||
function Vector(r, e) {
|
||||
if (r === void 0) {
|
||||
r = [];
|
||||
}
|
||||
if (e === void 0) {
|
||||
e = true;
|
||||
}
|
||||
var n = t.call(this) || this;
|
||||
if (Array.isArray(r)) {
|
||||
n.V = e ? __spreadArray([], __read(r), false) : r;
|
||||
n.o = r.length;
|
||||
} else {
|
||||
n.V = [];
|
||||
r.forEach((function(t) {
|
||||
return n.pushBack(t);
|
||||
}));
|
||||
}
|
||||
n.size = n.size.bind(n);
|
||||
n.getElementByPos = n.getElementByPos.bind(n);
|
||||
n.setElementByPos = n.setElementByPos.bind(n);
|
||||
return n;
|
||||
}
|
||||
Vector.prototype.clear = function() {
|
||||
this.o = 0;
|
||||
this.V.length = 0;
|
||||
};
|
||||
Vector.prototype.begin = function() {
|
||||
return new VectorIterator(0, this.size, this.getElementByPos, this.setElementByPos);
|
||||
};
|
||||
Vector.prototype.end = function() {
|
||||
return new VectorIterator(this.o, this.size, this.getElementByPos, this.setElementByPos);
|
||||
};
|
||||
Vector.prototype.rBegin = function() {
|
||||
return new VectorIterator(this.o - 1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
};
|
||||
Vector.prototype.rEnd = function() {
|
||||
return new VectorIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1);
|
||||
};
|
||||
Vector.prototype.front = function() {
|
||||
return this.V[0];
|
||||
};
|
||||
Vector.prototype.back = function() {
|
||||
return this.V[this.o - 1];
|
||||
};
|
||||
Vector.prototype.forEach = function(t) {
|
||||
for (var r = 0; r < this.o; ++r) {
|
||||
t(this.V[r], r);
|
||||
}
|
||||
};
|
||||
Vector.prototype.getElementByPos = function(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
return this.V[t];
|
||||
};
|
||||
Vector.prototype.eraseElementByPos = function(t) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.V.splice(t, 1);
|
||||
this.o -= 1;
|
||||
};
|
||||
Vector.prototype.eraseElementByValue = function(t) {
|
||||
var r = 0;
|
||||
for (var e = 0; e < this.o; ++e) {
|
||||
if (this.V[e] !== t) {
|
||||
this.V[r++] = this.V[e];
|
||||
}
|
||||
}
|
||||
this.o = this.V.length = r;
|
||||
};
|
||||
Vector.prototype.eraseElementByIterator = function(t) {
|
||||
var r = t.D;
|
||||
t = t.next();
|
||||
this.eraseElementByPos(r);
|
||||
return t;
|
||||
};
|
||||
Vector.prototype.pushBack = function(t) {
|
||||
this.V.push(t);
|
||||
this.o += 1;
|
||||
};
|
||||
Vector.prototype.popBack = function() {
|
||||
if (!this.o) return;
|
||||
this.V.pop();
|
||||
this.o -= 1;
|
||||
};
|
||||
Vector.prototype.setElementByPos = function(t, r) {
|
||||
if (t < 0 || t > this.o - 1) {
|
||||
throw new RangeError;
|
||||
}
|
||||
this.V[t] = r;
|
||||
};
|
||||
Vector.prototype.insert = function(t, r, e) {
|
||||
var n;
|
||||
if (e === void 0) {
|
||||
e = 1;
|
||||
}
|
||||
if (t < 0 || t > this.o) {
|
||||
throw new RangeError;
|
||||
}
|
||||
(n = this.V).splice.apply(n, __spreadArray([ t, 0 ], __read(new Array(e).fill(r)), false));
|
||||
this.o += e;
|
||||
};
|
||||
Vector.prototype.find = function(t) {
|
||||
for (var r = 0; r < this.o; ++r) {
|
||||
if (this.V[r] === t) {
|
||||
return new VectorIterator(r, this.size, this.getElementByPos, this.getElementByPos);
|
||||
}
|
||||
}
|
||||
return this.end();
|
||||
};
|
||||
Vector.prototype.reverse = function() {
|
||||
this.V.reverse();
|
||||
};
|
||||
Vector.prototype.unique = function() {
|
||||
var t = 1;
|
||||
for (var r = 1; r < this.o; ++r) {
|
||||
if (this.V[r] !== this.V[r - 1]) {
|
||||
this.V[t++] = this.V[r];
|
||||
}
|
||||
}
|
||||
this.o = this.V.length = t;
|
||||
};
|
||||
Vector.prototype.sort = function(t) {
|
||||
this.V.sort(t);
|
||||
};
|
||||
Vector.prototype[Symbol.iterator] = function() {
|
||||
return function() {
|
||||
return __generator(this, (function(t) {
|
||||
switch (t.label) {
|
||||
case 0:
|
||||
return [ 5, __values(this.V) ];
|
||||
|
||||
case 1:
|
||||
return [ 2, t.sent() ];
|
||||
}
|
||||
}));
|
||||
}.bind(this)();
|
||||
};
|
||||
return Vector;
|
||||
}(SequentialContainer);
|
||||
|
||||
export default Vector;
|
||||
Reference in New Issue
Block a user