Class RedBlackTreeNode<K, V, NODE>

Represents a node in a binary tree.

Type Parameters

  • K = any
  • V = any

    The type of data stored in the node.

  • NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>

    The type of the family relationship in the binary tree.

Hierarchy (view full)

Constructors

Accessors

Constructors

  • The constructor function initializes a Red-Black Tree Node with a key, an optional value, and a color.

    Type Parameters

    Parameters

    • key: K

      The key parameter is of type K and represents the key of the node in the Red-Black Tree.

    • Optionalvalue: V

      The value parameter is an optional parameter that represents the value associated with the key in the Red-Black Tree Node. It is not required and can be omitted when creating a new instance of the Red-Black Tree Node.

    • color: RBTNColor = 'BLACK'

      The color parameter is used to specify the color of the Red-Black Tree Node. It is an optional parameter with a default value of 'BLACK'.

    Returns RedBlackTreeNode<K, V, NODE>

Accessors

  • get color(): RBTNColor
  • The function returns the color value of a variable.

    Returns RBTNColor

    The color value stored in the private variable _color.

  • set color(value): void
  • The function sets the color property to the specified value.

    Parameters

    • value: RBTNColor

      The value parameter is of type RBTNColor.

    Returns void

  • get left(): OptNode<NODE>
  • The function returns the value of the _left property.

    Returns OptNode<NODE>

    The _left property of the current object is being returned.

  • set left(v): void
  • The function sets the left child of a node and updates the parent reference of the child.

    Parameters

    • v: OptNode<NODE>

      The parameter v is of type OptNode<NODE>. It can either be an instance of the NODE class or undefined.

    Returns void

  • get right(): OptNode<NODE>
  • The function returns the right node of a binary tree or undefined if there is no right node.

    Returns OptNode<NODE>

    The method is returning the value of the _right property, which is of type NODE or undefined.

  • set right(v): void
  • The function sets the right child of a node and updates the parent reference of the child.

    Parameters

    • v: OptNode<NODE>

      The parameter v is of type OptNode<NODE>. It can either be a NODE object or undefined.

    Returns void