Class Container<T>Abstract

Type Parameters

  • T

Hierarchy

Constructors

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

    Iterate over all elements in the container.

    Example

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

    Parameters

    • callback: ((element: T, index: number, container: Container<T>) => void)

      Callback function like Array.forEach.

        • (element: T, index: number, container: Container<T>): void
        • Parameters

          • element: T
          • index: number
          • container: Container<T>

          Returns void

    Returns void

  • Description

    Gets the value of the element at the specified position.

    Example

    const val = container.getElementByPos(-1); // throw a RangeError
    

    Parameters

    • pos: number

    Returns T

  • 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

Generated using TypeDoc