Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 19x | /**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
export class CoordinateMap<V> extends Map<any, V> {
constructor(joint?: string) {
super();
Iif (joint !== undefined) this._joint = joint;
}
protected _joint = '_';
get joint(): string {
return this._joint;
}
/**
* The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
* key array with a specified delimiter.
* @param {number[]} key - The parameter "key" is an array of numbers.
* @returns The `has` method is being overridden to return the result of calling the `has` method of the superclass
* (`super.has`) with the `key` array joined together using the `_joint` property.
*/
override has(key: number[]) {
return super.has(key.join(this._joint));
}
/**
* The function overrides the set method of a Map object to convert the key from an array to a string using a specified
* delimiter before calling the original set method.
* @param {number[]} key - The key parameter is an array of numbers.
* @param {V} value - The value parameter is the value that you want to associate with the specified key.
* @returns The `set` method is returning the result of calling the `set` method of the superclass
* (`super.set(key.join(this._joint), value)`).
*/
override set(key: number[], value: V) {
return super.set(key.join(this._joint), value);
}
/**
* The function overrides the get method to join the key array with a specified joint and then calls the super get
* method.
* @param {number[]} key - An array of numbers
* @returns The code is returning the value associated with the specified key in the map.
*/
override get(key: number[]) {
return super.get(key.join(this._joint));
}
/**
* The function overrides the delete method and joins the key array using a specified joint character before calling
* the super delete method.
* @param {number[]} key - An array of numbers that represents the key to be deleted.
* @returns The `delete` method is returning the result of calling the `delete` method on the superclass, with the
* `key` array joined together using the `_joint` property.
*/
override delete(key: number[]) {
return super.delete(key.join(this._joint));
}
protected _setJoint(v: string) {
this._joint = v;
}
}
|