Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a single element of a tree. Carrying a given value, it is linked to maximum two child nodes via left and right fields.

Type parameters

  • T

Hierarchy

  • BinarySearchTreeNode

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Optional left

Optional right

value

value: T

Methods

getChild

  • Returns the current node's child in the given direction (can be undefined).

    Values -1 (left) or 1 (right) for the direction input are used for convenience, as it is the direct result of the CompareFunction. Case 0 is not treated as it is considered already checked.

    Parameters

    • direction: -1 | 1

      -1 (left) / 1 (right).

    Returns undefined | BinarySearchTreeNode<T>

    a child BinarySearchTreeNode or undefined.

hasChild

  • hasChild(direction: -1 | 1): boolean
  • Whether the current node has a child in the given direction.

    Values -1 (left) or 1 (right) for the direction input are used for convenience, as it is the direct result of the CompareFunction. Case 0 is not treated as it is considered already checked.

    Parameters

    • direction: -1 | 1

      -1 (left) / 1 (right).

    Returns boolean

    true / false.

setChild

  • Sets the current node's child in the given direction.

    Parameters

    Returns void

Generated using TypeDoc