Tracking de l'application VApp (IHM du jeu)

This commit is contained in:
2025-05-11 18:04:12 +02:00
commit 89e9db9b62
17763 changed files with 3718499 additions and 0 deletions

View 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;

View File

@ -0,0 +1,118 @@
"use strict";
Object.defineProperty(exports, "t", {
value: true
});
exports.default = void 0;
var _ContainerBase = require("../ContainerBase");
class PriorityQueue extends _ContainerBase.Base {
constructor(t = [], s = function(t, s) {
if (t > s) return -1;
if (t < s) return 1;
return 0;
}, i = true) {
super();
this.v = s;
if (Array.isArray(t)) {
this.C = i ? [ ...t ] : t;
} else {
this.C = [];
const s = this;
t.forEach((function(t) {
s.C.push(t);
}));
}
this.i = this.C.length;
const e = this.i >> 1;
for (let t = this.i - 1 >> 1; t >= 0; --t) {
this.k(t, e);
}
}
m(t) {
const s = this.C[t];
while (t > 0) {
const i = t - 1 >> 1;
const e = this.C[i];
if (this.v(e, s) <= 0) break;
this.C[t] = e;
t = i;
}
this.C[t] = s;
}
k(t, s) {
const i = this.C[t];
while (t < s) {
let s = t << 1 | 1;
const e = s + 1;
let h = this.C[s];
if (e < this.i && this.v(h, this.C[e]) > 0) {
s = e;
h = this.C[e];
}
if (this.v(h, i) >= 0) break;
this.C[t] = h;
t = s;
}
this.C[t] = i;
}
clear() {
this.i = 0;
this.C.length = 0;
}
push(t) {
this.C.push(t);
this.m(this.i);
this.i += 1;
}
pop() {
if (this.i === 0) return;
const t = this.C[0];
const s = this.C.pop();
this.i -= 1;
if (this.i) {
this.C[0] = s;
this.k(0, this.i >> 1);
}
return t;
}
top() {
return this.C[0];
}
find(t) {
return this.C.indexOf(t) >= 0;
}
remove(t) {
const s = this.C.indexOf(t);
if (s < 0) return false;
if (s === 0) {
this.pop();
} else if (s === this.i - 1) {
this.C.pop();
this.i -= 1;
} else {
this.C.splice(s, 1, this.C.pop());
this.i -= 1;
this.m(s);
this.k(s, this.i >> 1);
}
return true;
}
updateItem(t) {
const s = this.C.indexOf(t);
if (s < 0) return false;
this.m(s);
this.k(s, this.i >> 1);
return true;
}
toArray() {
return [ ...this.C ];
}
}
var _default = PriorityQueue;
exports.default = _default;
//# sourceMappingURL=PriorityQueue.js.map

File diff suppressed because one or more lines are too long

View 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;

View File

@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "t", {
value: true
});
exports.default = void 0;
var _ContainerBase = require("../ContainerBase");
class Queue extends _ContainerBase.Base {
constructor(t = []) {
super();
this.j = 0;
this.q = [];
const s = this;
t.forEach((function(t) {
s.push(t);
}));
}
clear() {
this.q = [];
this.i = this.j = 0;
}
push(t) {
const s = this.q.length;
if (this.j / s > .5 && this.j + this.i >= s && s > 4096) {
const s = this.i;
for (let t = 0; t < s; ++t) {
this.q[t] = this.q[this.j + t];
}
this.j = 0;
this.q[this.i] = t;
} else this.q[this.j + this.i] = t;
return ++this.i;
}
pop() {
if (this.i === 0) return;
const t = this.q[this.j++];
this.i -= 1;
return t;
}
front() {
if (this.i === 0) return;
return this.q[this.j];
}
}
var _default = Queue;
exports.default = _default;
//# sourceMappingURL=Queue.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["container/OtherContainer/Queue.js","../../src/container/OtherContainer/Queue.ts"],"names":["Object","defineProperty","exports","value","default","_ContainerBase","require","Queue","Base","constructor","container","super","this","_first","_queue","self","forEach","el","push","clear","_length","element","capacity","length","i","pop","front","_default"],"mappings":"AAAA;;AAEAA,OAAOC,eAAeC,SAAS,KAAc;IAC3CC,OAAO;;;AAETD,QAAQE,eAAe;;ACLvB,IAAAC,iBAAAC,QAAA;;AAOA,MAAMC,cAAiBC,eAAAA;IASrBC,YAAYC,IAA8B;QACxCC;QANMC,KAAAC,IAAS;QAITD,KAAAE,IAAc;QAGpB,MAAMC,IAAOH;QACbF,EAAUM,SAAQ,SAAUC;YAC1BF,EAAKG,KAAKD;ADLR;AACJ;ICOFE;QACEP,KAAKE,IAAS;QACdF,KAAKQ,IAAUR,KAAKC,IAAS;ADL7B;ICYFK,KAAKG;QACH,MAAMC,IAAWV,KAAKE,EAAOS;QAC7B,IACGX,KAAKC,IAASS,IAAS,MACvBV,KAAKC,IAASD,KAAKQ,KAAYE,KAChCA,IAAQ,MACR;YACA,MAAMC,IAASX,KAAKQ;YACpB,KAAK,IAAII,IAAI,GAAGA,IAAID,KAAUC,GAAG;gBAC/BZ,KAAKE,EAAOU,KAAKZ,KAAKE,EAAOF,KAAKC,IAASW;ADPvC;YCSNZ,KAAKC,IAAS;YACdD,KAAKE,EAAOF,KAAKQ,KAAWC;ADP1B,eCQGT,KAAKE,EAAOF,KAAKC,IAASD,KAAKQ,KAAWC;QACjD,SAAST,KAAKQ;ADLd;ICWFK;QACE,IAAIb,KAAKQ,MAAY,GAAG;QACxB,MAAMH,IAAKL,KAAKE,EAAOF,KAAKC;QAC5BD,KAAKQ,KAAW;QAChB,OAAOH;ADJP;ICUFS;QACE,IAAId,KAAKQ,MAAY,GAAG;QACxB,OAAOR,KAAKE,EAAOF,KAAKC;ADHxB;;;ACKH,IAAAc,WAEcpB;;AAAKL,QAAAE,UAAAuB","file":"Queue.js","sourcesContent":["import { Base } from \"../ContainerBase\";\nclass Queue extends Base {\n constructor(container = []) {\n super();\n /**\n * @internal\n */\n this._first = 0;\n /**\n * @internal\n */\n this._queue = [];\n const self = this;\n container.forEach(function (el) {\n self.push(el);\n });\n }\n clear() {\n this._queue = [];\n this._length = this._first = 0;\n }\n /**\n * @description Inserts element to queue's end.\n * @param element - The element you want to push to the front.\n * @returns The container length after pushing.\n */\n push(element) {\n const capacity = this._queue.length;\n if ((this._first / capacity) > 0.5 /* QUEUE_CONSTANT.ALLOCATE_SIGMA */ &&\n (this._first + this._length) >= capacity &&\n capacity > 4096 /* QUEUE_CONSTANT.MIN_ALLOCATE_SIZE */) {\n const length = this._length;\n for (let i = 0; i < length; ++i) {\n this._queue[i] = this._queue[this._first + i];\n }\n this._first = 0;\n this._queue[this._length] = element;\n }\n else\n this._queue[this._first + this._length] = element;\n return ++this._length;\n }\n /**\n * @description Removes the first element.\n * @returns The element you popped.\n */\n pop() {\n if (this._length === 0)\n return;\n const el = this._queue[this._first++];\n this._length -= 1;\n return el;\n }\n /**\n * @description Access the first element.\n * @returns The first element.\n */\n front() {\n if (this._length === 0)\n return;\n return this._queue[this._first];\n }\n}\nexport default Queue;\n","import { Base, initContainer } from '@/container/ContainerBase';\n\nconst enum QUEUE_CONSTANT {\n ALLOCATE_SIGMA = 0.5,\n MIN_ALLOCATE_SIZE = (1 << 12)\n}\n\nclass Queue<T> extends Base {\n /**\n * @internal\n */\n private _first = 0;\n /**\n * @internal\n */\n private _queue: 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._queue = [];\n this._length = this._first = 0;\n }\n /**\n * @description Inserts element to queue's end.\n * @param element - The element you want to push to the front.\n * @returns The container length after pushing.\n */\n push(element: T) {\n const capacity = this._queue.length;\n if (\n (this._first / capacity) > QUEUE_CONSTANT.ALLOCATE_SIGMA &&\n (this._first + this._length) >= capacity &&\n capacity > QUEUE_CONSTANT.MIN_ALLOCATE_SIZE\n ) {\n const length = this._length;\n for (let i = 0; i < length; ++i) {\n this._queue[i] = this._queue[this._first + i];\n }\n this._first = 0;\n this._queue[this._length] = element;\n } else this._queue[this._first + this._length] = element;\n return ++this._length;\n }\n /**\n * @description Removes the first element.\n * @returns The element you popped.\n */\n pop() {\n if (this._length === 0) return;\n const el = this._queue[this._first++];\n this._length -= 1;\n return el;\n }\n /**\n * @description Access the first element.\n * @returns The first element.\n */\n front(): T | undefined {\n if (this._length === 0) return;\n return this._queue[this._first];\n }\n}\n\nexport default Queue;\n"]}

View 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;

View File

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "t", {
value: true
});
exports.default = void 0;
var _ContainerBase = require("../ContainerBase");
class Stack extends _ContainerBase.Base {
constructor(t = []) {
super();
this.S = [];
const s = this;
t.forEach((function(t) {
s.push(t);
}));
}
clear() {
this.i = 0;
this.S = [];
}
push(t) {
this.S.push(t);
this.i += 1;
return this.i;
}
pop() {
if (this.i === 0) return;
this.i -= 1;
return this.S.pop();
}
top() {
return this.S[this.i - 1];
}
}
var _default = Stack;
exports.default = _default;
//# sourceMappingURL=Stack.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["container/OtherContainer/Stack.js","../../src/container/OtherContainer/Stack.ts"],"names":["Object","defineProperty","exports","value","default","_ContainerBase","require","Stack","Base","constructor","container","super","this","_stack","self","forEach","el","push","clear","_length","element","pop","top","_default"],"mappings":"AAAA;;AAEAA,OAAOC,eAAeC,SAAS,KAAc;IAC3CC,OAAO;;;AAETD,QAAQE,eAAe;;ACLvB,IAAAC,iBAAAC,QAAA;;AAEA,MAAMC,cAAiBC,eAAAA;IAKrBC,YAAYC,IAA8B;QACxCC;QAFMC,KAAAC,IAAc;QAGpB,MAAMC,IAAOF;QACbF,EAAUK,SAAQ,SAAUC;YAC1BF,EAAKG,KAAKD;ADAR;AACJ;ICEFE;QACEN,KAAKO,IAAU;QACfP,KAAKC,IAAS;ADAd;ICOFI,KAAKG;QACHR,KAAKC,EAAOI,KAAKG;QACjBR,KAAKO,KAAW;QAChB,OAAOP,KAAKO;ADAZ;ICMFE;QACE,IAAIT,KAAKO,MAAY,GAAG;QACxBP,KAAKO,KAAW;QAChB,OAAOP,KAAKC,EAAOQ;ADCnB;ICKFC;QACE,OAAOV,KAAKC,EAAOD,KAAKO,IAAU;ADClC;;;ACCH,IAAAI,WAEchB;;AAAKL,QAAAE,UAAAmB","file":"Stack.js","sourcesContent":["import { Base } from \"../ContainerBase\";\nclass Stack extends Base {\n constructor(container = []) {\n super();\n /**\n * @internal\n */\n this._stack = [];\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) {\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)\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 top() {\n return this._stack[this._length - 1];\n }\n}\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"]}