Insane number of adds to setup env and packages

This commit is contained in:
2022-11-07 17:45:54 -05:00
parent 62c2bb73a9
commit 55ecf095a9
3127 changed files with 485223 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
import { Base, initContainer } from "../ContainerBase";
declare class PriorityQueue<T> extends Base {
/**
* @description PriorityQueue's constructor.
* @param container Initialize container, must have a forEach function.
* @param cmp Compare function.
* @param copy When the container is an array, you can choose to directly operate on the original object of
* the array or perform a shallow copy. The default is shallow copy.
*/
constructor(container?: initContainer<T>, cmp?: (x: T, y: T) => number, copy?: boolean);
clear(): void;
/**
* @description Push element into a container in order.
* @param item The element you want to push.
*/
push(item: T): void;
/**
* @description Removes the top element.
*/
pop(): void;
/**
* @description Accesses the top element.
*/
top(): T | undefined;
/**
* @description Check if element is in heap.
* @param item The item want to find.
* @return Boolean about if element is in heap.
*/
find(item: T): boolean;
/**
* @description Remove specified item from heap.
* @param item The item want to remove.
* @return Boolean about if remove success.
*/
remove(item: T): boolean;
/**
* @description Update item and it's pos in the heap.
* @param item The item want to update.
* @return Boolean about if update success.
*/
updateItem(item: T): boolean;
/**
* @return Return a copy array of heap.
*/
toArray(): T[];
}
export default PriorityQueue;

View File

@@ -0,0 +1,167 @@
var __extends = this && this.t || function() {
var extendStatics = function(i, t) {
extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(i, t) {
i.__proto__ = t;
} || function(i, t) {
for (var r in t) if (Object.prototype.hasOwnProperty.call(t, r)) i[r] = t[r];
};
return extendStatics(i, t);
};
return function(i, t) {
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
extendStatics(i, t);
function __() {
this.constructor = i;
}
i.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
};
}();
var __read = this && this._ || function(i, t) {
var r = typeof Symbol === "function" && i[Symbol.iterator];
if (!r) return i;
var e = r.call(i), n, u = [], s;
try {
while ((t === void 0 || t-- > 0) && !(n = e.next()).done) u.push(n.value);
} catch (i) {
s = {
error: i
};
} finally {
try {
if (n && !n.done && (r = e["return"])) r.call(e);
} finally {
if (s) throw s.error;
}
}
return u;
};
var __spreadArray = this && this.P || function(i, t, r) {
if (r || arguments.length === 2) for (var e = 0, n = t.length, u; e < n; e++) {
if (u || !(e in t)) {
if (!u) u = Array.prototype.slice.call(t, 0, e);
u[e] = t[e];
}
}
return i.concat(u || Array.prototype.slice.call(t));
};
import { Base } from "../ContainerBase";
var PriorityQueue = function(i) {
__extends(PriorityQueue, i);
function PriorityQueue(t, r, e) {
if (t === void 0) {
t = [];
}
if (r === void 0) {
r = function(i, t) {
if (i > t) return -1;
if (i < t) return 1;
return 0;
};
}
if (e === void 0) {
e = true;
}
var n = i.call(this) || this;
n.A = r;
if (Array.isArray(t)) {
n.m = e ? __spreadArray([], __read(t), false) : t;
} else {
n.m = [];
t.forEach((function(i) {
return n.m.push(i);
}));
}
n.o = n.m.length;
var u = n.o >> 1;
for (var s = n.o - 1 >> 1; s >= 0; --s) {
n.j(s, u);
}
return n;
}
PriorityQueue.prototype.B = function(i) {
var t = this.m[i];
while (i > 0) {
var r = i - 1 >> 1;
var e = this.m[r];
if (this.A(e, t) <= 0) break;
this.m[i] = e;
i = r;
}
this.m[i] = t;
};
PriorityQueue.prototype.j = function(i, t) {
var r = this.m[i];
while (i < t) {
var e = i << 1 | 1;
var n = e + 1;
var u = this.m[e];
if (n < this.o && this.A(u, this.m[n]) > 0) {
e = n;
u = this.m[n];
}
if (this.A(u, r) >= 0) break;
this.m[i] = u;
i = e;
}
this.m[i] = r;
};
PriorityQueue.prototype.clear = function() {
this.o = 0;
this.m.length = 0;
};
PriorityQueue.prototype.push = function(i) {
this.m.push(i);
this.B(this.o);
this.o += 1;
};
PriorityQueue.prototype.pop = function() {
if (!this.o) return;
var i = this.m.pop();
this.o -= 1;
if (this.o) {
this.m[0] = i;
this.j(0, this.o >> 1);
}
};
PriorityQueue.prototype.top = function() {
return this.m[0];
};
PriorityQueue.prototype.find = function(i) {
return this.m.indexOf(i) >= 0;
};
PriorityQueue.prototype.remove = function(i) {
var t = this.m.indexOf(i);
if (t < 0) return false;
if (t === 0) {
this.pop();
} else if (t === this.o - 1) {
this.m.pop();
this.o -= 1;
} else {
this.m.splice(t, 1, this.m.pop());
this.o -= 1;
this.B(t);
this.j(t, this.o >> 1);
}
return true;
};
PriorityQueue.prototype.updateItem = function(i) {
var t = this.m.indexOf(i);
if (t < 0) return false;
this.B(t);
this.j(t, this.o >> 1);
return true;
};
PriorityQueue.prototype.toArray = function() {
return __spreadArray([], __read(this.m), false);
};
return PriorityQueue;
}(Base);
export default PriorityQueue;

View File

@@ -0,0 +1,18 @@
import { Base, initContainer } from "../ContainerBase";
declare class Queue<T> extends Base {
constructor(container?: initContainer<T>);
clear(): void;
/**
* @description Inserts element to queue's end.
*/
push(element: T): void;
/**
* @description Removes the first element.
*/
pop(): void;
/**
* @description Access the first element.
*/
front(): T | undefined;
}
export default Queue;

View File

@@ -0,0 +1,55 @@
var __extends = this && this.t || function() {
var extendStatics = function(e, t) {
extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) if (Object.prototype.hasOwnProperty.call(t, n)) e[n] = t[n];
};
return extendStatics(e, t);
};
return function(e, t) {
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
extendStatics(e, t);
function __() {
this.constructor = e;
}
e.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __);
};
}();
import Deque from "../SequentialContainer/Deque";
import { Base } from "../ContainerBase";
var Queue = function(e) {
__extends(Queue, e);
function Queue(t) {
if (t === void 0) {
t = [];
}
var n = e.call(this) || this;
n.q = new Deque(t);
n.o = n.q.size();
return n;
}
Queue.prototype.clear = function() {
this.q.clear();
this.o = 0;
};
Queue.prototype.push = function(e) {
this.q.pushBack(e);
this.o += 1;
};
Queue.prototype.pop = function() {
this.q.popFront();
if (this.o) this.o -= 1;
};
Queue.prototype.front = function() {
return this.q.front();
};
return Queue;
}(Base);
export default Queue;

View File

@@ -0,0 +1,18 @@
import { Base, initContainer } from "../ContainerBase";
declare class Stack<T> extends Base {
constructor(container?: initContainer<T>);
clear(): void;
/**
* @description Insert element to stack's end.
*/
push(element: T): void;
/**
* @description Removes the end element.
*/
pop(): void;
/**
* @description Accesses the end element.
*/
top(): T | undefined;
}
export default Stack;

View File

@@ -0,0 +1,55 @@
var __extends = this && this.t || function() {
var extendStatics = function(t, n) {
extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function(t, n) {
t.__proto__ = n;
} || function(t, n) {
for (var i in n) if (Object.prototype.hasOwnProperty.call(n, i)) t[i] = n[i];
};
return extendStatics(t, n);
};
return function(t, n) {
if (typeof n !== "function" && n !== null) throw new TypeError("Class extends value " + String(n) + " is not a constructor or null");
extendStatics(t, n);
function __() {
this.constructor = t;
}
t.prototype = n === null ? Object.create(n) : (__.prototype = n.prototype, new __);
};
}();
import { Base } from "../ContainerBase";
var Stack = function(t) {
__extends(Stack, t);
function Stack(n) {
if (n === void 0) {
n = [];
}
var i = t.call(this) || this;
i.S = [];
n.forEach((function(t) {
return i.push(t);
}));
return i;
}
Stack.prototype.clear = function() {
this.o = 0;
this.S.length = 0;
};
Stack.prototype.push = function(t) {
this.S.push(t);
this.o += 1;
};
Stack.prototype.pop = function() {
this.S.pop();
if (this.o > 0) this.o -= 1;
};
Stack.prototype.top = function() {
return this.S[this.o - 1];
};
return Stack;
}(Base);
export default Stack;