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,29 @@
import { Container, ContainerIterator } from "../../ContainerBase";
export declare type HashLinkNode<K, V> = {
_key: K;
_value: V;
_pre: HashLinkNode<K, V>;
_next: HashLinkNode<K, V>;
};
export declare abstract class HashContainerIterator<K, V> extends ContainerIterator<K | [K, V]> {
abstract readonly container: HashContainer<K, V>;
pre(): this;
next(): this;
}
export declare abstract class HashContainer<K, V> extends Container<K | [K, V]> {
/**
* @description Unique symbol used to tag object.
*/
readonly HASH_TAG: symbol;
clear(): void;
/**
* @description Remove the element of the specified key.
* @param key - The key you want to remove.
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
* If a `undefined` value is passed in, the type will be automatically judged.
* @returns Whether erase successfully.
*/
eraseElementByKey(key: K, isObject?: boolean): boolean;
eraseElementByIterator(iter: HashContainerIterator<K, V>): HashContainerIterator<K, V>;
eraseElementByPos(pos: number): number;
}

View File

@ -0,0 +1,188 @@
"use strict";
Object.defineProperty(exports, "t", {
value: true
});
exports.HashContainerIterator = exports.HashContainer = void 0;
var _ContainerBase = require("../../ContainerBase");
var _checkObject = _interopRequireDefault(require("../../../utils/checkObject"));
var _throwError = require("../../../utils/throwError");
function _interopRequireDefault(t) {
return t && t.t ? t : {
default: t
};
}
class HashContainerIterator extends _ContainerBase.ContainerIterator {
constructor(t, e, i) {
super(i);
this.o = t;
this.h = e;
if (this.iteratorType === 0) {
this.pre = function() {
if (this.o.L === this.h) {
(0, _throwError.throwIteratorAccessError)();
}
this.o = this.o.L;
return this;
};
this.next = function() {
if (this.o === this.h) {
(0, _throwError.throwIteratorAccessError)();
}
this.o = this.o.B;
return this;
};
} else {
this.pre = function() {
if (this.o.B === this.h) {
(0, _throwError.throwIteratorAccessError)();
}
this.o = this.o.B;
return this;
};
this.next = function() {
if (this.o === this.h) {
(0, _throwError.throwIteratorAccessError)();
}
this.o = this.o.L;
return this;
};
}
}
}
exports.HashContainerIterator = HashContainerIterator;
class HashContainer extends _ContainerBase.Container {
constructor() {
super();
this.H = [];
this.g = {};
this.HASH_TAG = Symbol("@@HASH_TAG");
Object.setPrototypeOf(this.g, null);
this.h = {};
this.h.L = this.h.B = this.p = this._ = this.h;
}
V(t) {
const {L: e, B: i} = t;
e.B = i;
i.L = e;
if (t === this.p) {
this.p = i;
}
if (t === this._) {
this._ = e;
}
this.i -= 1;
}
M(t, e, i) {
if (i === undefined) i = (0, _checkObject.default)(t);
let s;
if (i) {
const i = t[this.HASH_TAG];
if (i !== undefined) {
this.H[i].l = e;
return this.i;
}
Object.defineProperty(t, this.HASH_TAG, {
value: this.H.length,
configurable: true
});
s = {
u: t,
l: e,
L: this._,
B: this.h
};
this.H.push(s);
} else {
const i = this.g[t];
if (i) {
i.l = e;
return this.i;
}
s = {
u: t,
l: e,
L: this._,
B: this.h
};
this.g[t] = s;
}
if (this.i === 0) {
this.p = s;
this.h.B = s;
} else {
this._.B = s;
}
this._ = s;
this.h.L = s;
return ++this.i;
}
I(t, e) {
if (e === undefined) e = (0, _checkObject.default)(t);
if (e) {
const e = t[this.HASH_TAG];
if (e === undefined) return this.h;
return this.H[e];
} else {
return this.g[t] || this.h;
}
}
clear() {
const t = this.HASH_TAG;
this.H.forEach((function(e) {
delete e.u[t];
}));
this.H = [];
this.g = {};
Object.setPrototypeOf(this.g, null);
this.i = 0;
this.p = this._ = this.h.L = this.h.B = this.h;
}
eraseElementByKey(t, e) {
let i;
if (e === undefined) e = (0, _checkObject.default)(t);
if (e) {
const e = t[this.HASH_TAG];
if (e === undefined) return false;
delete t[this.HASH_TAG];
i = this.H[e];
delete this.H[e];
} else {
i = this.g[t];
if (i === undefined) return false;
delete this.g[t];
}
this.V(i);
return true;
}
eraseElementByIterator(t) {
const e = t.o;
if (e === this.h) {
(0, _throwError.throwIteratorAccessError)();
}
this.V(e);
return t.next();
}
eraseElementByPos(t) {
if (t < 0 || t > this.i - 1) {
throw new RangeError;
}
let e = this.p;
while (t--) {
e = e.B;
}
this.V(e);
return this.i;
}
}
exports.HashContainer = HashContainer;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,49 @@
import { initContainer, IteratorType } from "../ContainerBase";
import { HashContainer, HashContainerIterator, HashLinkNode } from "./Base";
declare class HashMapIterator<K, V> extends HashContainerIterator<K, V> {
readonly container: HashMap<K, V>;
constructor(node: HashLinkNode<K, V>, header: HashLinkNode<K, V>, container: HashMap<K, V>, iteratorType?: IteratorType);
get pointer(): [K, V];
copy(): HashMapIterator<K, V>;
equals(iter: HashMapIterator<K, V>): boolean;
}
export type { HashMapIterator };
declare class HashMap<K, V> extends HashContainer<K, V> {
constructor(container?: initContainer<[K, V]>);
begin(): HashMapIterator<K, V>;
end(): HashMapIterator<K, V>;
rBegin(): HashMapIterator<K, V>;
rEnd(): HashMapIterator<K, V>;
front(): [K, V] | undefined;
back(): [K, V] | undefined;
/**
* @description Insert a key-value pair or set value by the given key.
* @param key - The key want to insert.
* @param value - The value want to set.
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
* If a `undefined` value is passed in, the type will be automatically judged.
* @returns The size of container after setting.
*/
setElement(key: K, value: V, isObject?: boolean): number;
/**
* @description Get the value of the element of the specified key.
* @param key - The key want to search.
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
* If a `undefined` value is passed in, the type will be automatically judged.
* @example
* const val = container.getElementByKey(1);
*/
getElementByKey(key: K, isObject?: boolean): V | undefined;
getElementByPos(pos: number): [K, V];
/**
* @description Check key if exist in container.
* @param key - The element you want to search.
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
* If a `undefined` value is passed in, the type will be automatically judged.
* @returns An iterator pointing to the element if found, or super end if not found.
*/
find(key: K, isObject?: boolean): HashMapIterator<K, V>;
forEach(callback: (element: [K, V], index: number, hashMap: HashMap<K, V>) => void): void;
[Symbol.iterator](): Generator<[K, V], void, unknown>;
}
export default HashMap;

View File

@ -0,0 +1,125 @@
"use strict";
Object.defineProperty(exports, "t", {
value: true
});
exports.default = void 0;
var _Base = require("./Base");
var _checkObject = _interopRequireDefault(require("../../utils/checkObject"));
var _throwError = require("../../utils/throwError");
function _interopRequireDefault(t) {
return t && t.t ? t : {
default: t
};
}
class HashMapIterator extends _Base.HashContainerIterator {
constructor(t, e, r, s) {
super(t, e, s);
this.container = r;
}
get pointer() {
if (this.o === this.h) {
(0, _throwError.throwIteratorAccessError)();
}
const t = this;
return new Proxy([], {
get(e, r) {
if (r === "0") return t.o.u; else if (r === "1") return t.o.l;
},
set(e, r, s) {
if (r !== "1") {
throw new TypeError("props must be 1");
}
t.o.l = s;
return true;
}
});
}
copy() {
return new HashMapIterator(this.o, this.h, this.container, this.iteratorType);
}
}
class HashMap extends _Base.HashContainer {
constructor(t = []) {
super();
const e = this;
t.forEach((function(t) {
e.setElement(t[0], t[1]);
}));
}
begin() {
return new HashMapIterator(this.p, this.h, this);
}
end() {
return new HashMapIterator(this.h, this.h, this);
}
rBegin() {
return new HashMapIterator(this._, this.h, this, 1);
}
rEnd() {
return new HashMapIterator(this.h, this.h, this, 1);
}
front() {
if (this.i === 0) return;
return [ this.p.u, this.p.l ];
}
back() {
if (this.i === 0) return;
return [ this._.u, this._.l ];
}
setElement(t, e, r) {
return this.M(t, e, r);
}
getElementByKey(t, e) {
if (e === undefined) e = (0, _checkObject.default)(t);
if (e) {
const e = t[this.HASH_TAG];
return e !== undefined ? this.H[e].l : undefined;
}
const r = this.g[t];
return r ? r.l : undefined;
}
getElementByPos(t) {
if (t < 0 || t > this.i - 1) {
throw new RangeError;
}
let e = this.p;
while (t--) {
e = e.B;
}
return [ e.u, e.l ];
}
find(t, e) {
const r = this.I(t, e);
return new HashMapIterator(r, this.h, this);
}
forEach(t) {
let e = 0;
let r = this.p;
while (r !== this.h) {
t([ r.u, r.l ], e++, this);
r = r.B;
}
}
[Symbol.iterator]() {
return function*() {
let t = this.p;
while (t !== this.h) {
yield [ t.u, t.l ];
t = t.B;
}
}.bind(this)();
}
}
var _default = HashMap;
exports.default = _default;
//# sourceMappingURL=HashMap.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,39 @@
import { initContainer, IteratorType } from "../ContainerBase";
import { HashContainer, HashContainerIterator, HashLinkNode } from "./Base";
declare class HashSetIterator<K> extends HashContainerIterator<K, undefined> {
readonly container: HashSet<K>;
constructor(node: HashLinkNode<K, undefined>, header: HashLinkNode<K, undefined>, container: HashSet<K>, iteratorType?: IteratorType);
get pointer(): K;
copy(): HashSetIterator<K>;
equals(iter: HashSetIterator<K>): boolean;
}
export type { HashSetIterator };
declare class HashSet<K> extends HashContainer<K, undefined> {
constructor(container?: initContainer<K>);
begin(): HashSetIterator<K>;
end(): HashSetIterator<K>;
rBegin(): HashSetIterator<K>;
rEnd(): HashSetIterator<K>;
front(): K | undefined;
back(): K | undefined;
/**
* @description Insert element to set.
* @param key - The key want to insert.
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
* If a `undefined` value is passed in, the type will be automatically judged.
* @returns The size of container after inserting.
*/
insert(key: K, isObject?: boolean): number;
getElementByPos(pos: number): K;
/**
* @description Check key if exist in container.
* @param key - The element you want to search.
* @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>
* If a `undefined` value is passed in, the type will be automatically judged.
* @returns An iterator pointing to the element if found, or super end if not found.
*/
find(key: K, isObject?: boolean): HashSetIterator<K>;
forEach(callback: (element: K, index: number, container: HashSet<K>) => void): void;
[Symbol.iterator](): Generator<K, void, unknown>;
}
export default HashSet;

View File

@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "t", {
value: true
});
exports.default = void 0;
var _Base = require("./Base");
var _throwError = require("../../utils/throwError");
class HashSetIterator extends _Base.HashContainerIterator {
constructor(t, e, r, s) {
super(t, e, s);
this.container = r;
}
get pointer() {
if (this.o === this.h) {
(0, _throwError.throwIteratorAccessError)();
}
return this.o.u;
}
copy() {
return new HashSetIterator(this.o, this.h, this.container, this.iteratorType);
}
}
class HashSet extends _Base.HashContainer {
constructor(t = []) {
super();
const e = this;
t.forEach((function(t) {
e.insert(t);
}));
}
begin() {
return new HashSetIterator(this.p, this.h, this);
}
end() {
return new HashSetIterator(this.h, this.h, this);
}
rBegin() {
return new HashSetIterator(this._, this.h, this, 1);
}
rEnd() {
return new HashSetIterator(this.h, this.h, this, 1);
}
front() {
return this.p.u;
}
back() {
return this._.u;
}
insert(t, e) {
return this.M(t, undefined, e);
}
getElementByPos(t) {
if (t < 0 || t > this.i - 1) {
throw new RangeError;
}
let e = this.p;
while (t--) {
e = e.B;
}
return e.u;
}
find(t, e) {
const r = this.I(t, e);
return new HashSetIterator(r, this.h, this);
}
forEach(t) {
let e = 0;
let r = this.p;
while (r !== this.h) {
t(r.u, e++, this);
r = r.B;
}
}
[Symbol.iterator]() {
return function*() {
let t = this.p;
while (t !== this.h) {
yield t.u;
t = t.B;
}
}.bind(this)();
}
}
var _default = HashSet;
exports.default = _default;
//# sourceMappingURL=HashSet.js.map

File diff suppressed because one or more lines are too long