Class TreeLeaf<T>

Represents a leaf in a tree data structure.

Type Parameters

  • T

    The type of data stored in the leaf.

Hierarchy

  • TreeLeaf

Constructors

Properties

Accessors

Methods

Constructors

  • Creates a new TreeLeaf instance.

    Type Parameters

    • T

    Parameters

    • data: T

      The data to store in the leaf.

    • Optional leaves: TreeLeaf<T>[]

      Optional child leaves to add to the leaf.

    Returns TreeLeaf<T>

Properties

data: T

The data to store in the leaf.

leaves: TreeLeaf<T>[] = []

The child leaves of this leaf.

Accessors

  • get children(): T[]
  • Returns an array of the data stored in the child leaves of this leaf.

    Returns T[]

  • get height(): number
  • Returns the height of the tree rooted at this leaf.

    Returns number

Methods

  • Adds one or more child leaves to this leaf.

    Parameters

    • data: T

      The data to store in the new leaves.

    • Rest ...datas: T[]

      Additional data to store in new leaves.

    Returns TreeLeaf<T>

    The last leaf that was added.