Class HashSet<K>

Type Parameters

  • K

Hierarchy

Accessors

  • get length(): number
  • Returns

    The size of the container.

    Example

    const container = new Vector([1, 2]);
    console.log(container.length); // 2

    Returns number

Methods

  • Description

    Remove the element of the specified key.

    Returns

    Whether erase successfully.

    Parameters

    • key: K

      The key you want to remove.

    • Optional isObject: boolean

      Tell us if the type of inserted key is object to improve efficiency.
      If a undefined value is passed in, the type will be automatically judged.

    Returns boolean

  • Description

    Removes the element at the specified position.

    Returns

    The container length after erasing.

    Example

    container.eraseElementByPos(-1); // throw a RangeError
    

    Parameters

    • pos: number

      The element's position you want to remove.

    Returns number

  • Description

    Insert element to set.

    Returns

    The size of container after inserting.

    Parameters

    • key: K

      The key want to insert.

    • Optional isObject: boolean

      Tell us if the type of inserted key is object to improve efficiency.
      If a undefined value is passed in, the type will be automatically judged.

    Returns number

  • Description

    Check key if exist in container.

    Returns

    An iterator pointing to the element if found, or super end if not found.

    Parameters

    • key: K

      The element you want to search.

    • Optional isObject: boolean

      Tell us if the type of inserted key is object to improve efficiency.
      If a undefined value is passed in, the type will be automatically judged.

    Returns HashSetIterator<K>

  • Description

    Iterate over all elements in the container.

    Example

    container.forEach((element, index) => console.log(element, index));
    

    Parameters

    • callback: ((element: K, index: number, container: HashSet<K>) => void)

      Callback function like Array.forEach.

        • (element: K, index: number, container: HashSet<K>): void
        • Parameters

          • element: K
          • index: number
          • container: HashSet<K>

          Returns void

    Returns void

Properties

HASH_TAG: symbol = ...

Description

Unique symbol used to tag object.

Constructors

Generated using TypeDoc