Class TreeCounterNode<K, V>

RB-tree node with an extra 'count' field; keeps parent/child links.

Time O(1), Space O(1)

Type Parameters

  • K = any
  • V = any

Constructors

  • Create a tree counter node.

    Type Parameters

    • K = any
    • V = any

    Parameters

    • key: K

      Key of the node.

    • Optionalvalue: V

      Value associated with the key (ignored in map mode).

    • Optionalcount: number = 1

      Initial count for this node (default 1).

    • color: RBTNColor = 'BLACK'

      Initial color ('RED' or 'BLACK').

    Returns TreeCounterNode<K, V>

    New TreeCounterNode instance.

    Time O(1), Space O(1)

Accessors

  • get familyPosition(): FamilyPosition
  • Gets the position of the node relative to its parent.

    Returns FamilyPosition

    The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').

    Time O(1), Space O(1)