Class TreeContainer<K, V>Abstract

Type Parameters

  • K

  • V

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

    Iterate over all elements in the container.

    Example

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

    Parameters

    • callback: ((element: K | [K, V], index: number, container: Container<K | [K, V]>) => void)

      Callback function like Array.forEach.

        • (element: K | [K, V], index: number, container: Container<K | [K, V]>): void
        • Parameters

          • element: K | [K, V]
          • index: number
          • container: Container<K | [K, V]>

          Returns void

    Returns void

  • Description

    Update node's key by iterator.

    Returns

    Whether the modification is successful.

    Example

    const st = new orderedSet([1, 2, 5]);
    const iter = st.find(2);
    st.updateKeyByIterator(iter, 3); // then st will become [1, 3, 5]

    Parameters

    • iter: TreeIterator<K, V>

      The iterator you want to change.

    • key: K

      The key you want to update.

    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

    Remove the element of the specified key.

    Returns

    Whether erase successfully.

    Parameters

    • key: K

      The key you want to remove.

    Returns boolean

Properties

enableIndex: boolean

Generated using TypeDoc