All files / src/data-structures/hash coordinate-set.ts

10% Statements 1/10
0% Branches 0/1
0% Functions 0/6
11.11% Lines 1/9

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              19x                                                                                                  
/**
 * data-structure-typed
 *
 * @author Tyler Zeng
 * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
 * @license MIT License
 */
export class CoordinateSet extends Set<any> {
  constructor(joint?: string) {
    super();
    Iif (joint !== undefined) this._joint = joint;
  }
 
  protected _joint = '_';
 
  get joint(): string {
    return this._joint;
  }
 
  /**
   * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
   * joining its elements with a specified separator.
   * @param {number[]} value - The parameter "value" is an array of numbers.
   * @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
   * in the joined value as an argument.
   */
  override has(value: number[]) {
    return super.has(value.join(this._joint));
  }
 
  /**
   * The "add" function overrides the parent class's "add" function by joining the elements of the input array with a
   * specified delimiter before calling the parent class's "add" function.
   * @param {number[]} value - An array of numbers
   * @returns The overridden `add` method is returning the result of calling the `add` method of the superclass
   * (`super.add`) with the joined string representation of the `value` array (`value.join(this._joint)`).
   */
  override add(value: number[]) {
    return super.add(value.join(this._joint));
  }
 
  /**
   * The function overrides the delete method and deletes an element from a Set by joining the elements of the input
   * array with a specified joint and then calling the delete method of the parent class.
   * @param {number[]} value - An array of numbers
   * @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
   * `value` array joined together using the `_joint` property.
   */
  override delete(value: number[]) {
    return super.delete(value.join(this._joint));
  }
 
  protected _setJoint(v: string) {
    this._joint = v;
  }
}