Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Node<K, V>

Type parameters

Hierarchy

  • Node

Index

Constructors

constructor

  • new Node(k?: K, v?: V): Node

Properties

Private h

h: number = 1

k

k: K

Private l

l: Node<K, V>

Private r

r: Node<K, V>

v

v: V

Accessors

height

  • get height(): number

key

  • get key(): K

value

  • get value(): V

Methods

__@iterator

  • __@iterator(): IterableIterator<V>
  • Generator function that returns all the values of the nodes below and this in an ascending order

    Returns IterableIterator<V>

first

  • first(): Node<K, V>

invert

  • invert(): void

last

  • last(): Node<K, V>

lower

  • lower(node: Node<K, V>, comparator: function): void
  • Parameters

    • node: Node<K, V>
    • comparator: function
        • (a: K, b: K): number
        • Parameters

          • a: K
          • b: K

          Returns number

    Returns void

Private lrotate

  • lrotate(): Node<K, V>

Private lrrotate

  • lrrotate(): Node<K, V>

nodes

  • nodes(): IterableIterator<Node<K, V>>

Private rebalance

  • rebalance(): Node<K, V>
  • Rebalances the tree below the node if the height differences are too big

    Returns Node<K, V>

remove

  • remove(k: K, reporter: object, comparator: function): Node<K, V>
  • Removes a node from the tree. Reports the removed value in the reporter object

    Parameters

    • k: K
    • reporter: object
      • removed: V
    • comparator: function
        • (a: K, b: K): number
        • Parameters

          • a: K
          • b: K

          Returns number

    Returns Node<K, V>

    the new root

reverse

  • reverse(): IterableIterator<V>
  • Generator function that returns all the values of the nodes below and this in an descending order

    Returns IterableIterator<V>

reverseNodes

  • reverseNodes(): IterableIterator<Node<K, V>>

Private rlrotate

  • rlrotate(): Node<K, V>

Private rrotate

  • rrotate(): Node<K, V>

search

  • search(k: K, comparator: function, treeRefForNearestSearch?: Tree<K, V>): Node<K, V>
  • Searches for a Node containing a key

    Parameters

    • k: K
    • comparator: function
        • (a: K, b: K): number
        • Parameters

          • a: K
          • b: K

          Returns number

    • Optional treeRefForNearestSearch: Tree<K, V>

    Returns Node<K, V>

    the value or undefined if its not found

set

  • set(k: K, v: V, reporter: object, comparator: function, existing?: Node<K, V>): Node<K, V>
  • Sets the key to a specific value. Inserts the node in a key-order respecting manner

    Parameters

    • k: K
    • v: V
    • reporter: object
      • success: boolean
    • comparator: function
        • (a: K, b: K): number
        • Parameters

          • a: K
          • b: K

          Returns number

    • Optional existing: Node<K, V>

    Returns Node<K, V>

    the new root

toString

  • toString(): string

Private updateHeight

  • updateHeight(): void
  • Calculates the height of the node. A leafs (node without either a left or a right node) height is

    Returns void

Generated using TypeDoc