Options
All
  • Public
  • Public/Protected
  • All
Menu

Used to create an AVL tree with a binary search tree as the root of each Node

Hierarchy

Implements

Index

Constructors

constructor

Properties

checkKeyEquality

checkKeyEquality: checkKeyEquality

Default function only checks key validity of number, string, and Date. This function also only uses '===' for the comparison. Supply a custom function in the constructor to use properly with your data types.

checkValueEquality

checkValueEquality: checkValueEquality

Default function only checks value equality of number, string, and Date. THis function also only uses '===' for the comparison. Supply a custom function in the constructor to use properly with your data types.

compareKeys

compareKeys: compareKeys

Default function compares only number and string other wise the user will need to supply a custom key comparison function to use this Node Tree model properly.

compareValues

compareValues: compareValues

Default function compares only number and string otherwise the use will need to supply a custom value comparison function to use this Node Tree model properly.

height

height: number = 0

Used to hold the depth of the tree at this point.

type

{number}

key

key: ASNDBS

The key used to find this Node

left

left: AVLNode | null

Holds a child of this type Node as a Node in this type tree.

options

parent

parent: AVLNode | null

Holds the parent of this type Node as a Node in this type tree.

right

right: AVLNode | null

Holds a child of this type Node as a Node in this type tree.

unique

unique: boolean

set in the constructor to have only unique keys

value

value: SNDBSA

The value this Node holds

Methods

Private _delete

Private _insert

Private _updateKey

Protected balanceFactor

  • balanceFactor(): number

checkAllNodesFullfillCondition

Protected checkBalanceFactors

  • checkBalanceFactors(): void
  • Check that the balance factors are between -1 and 1. Otherwise throw an error.

    Returns void

Protected checkHeightCorrect

  • checkHeightCorrect(): void
  • Check the recorded height for this AVL Node and all children. Throws an error if one height does not match.

    Returns void

checkInternalPointers

  • checkInternalPointers(): void

checkIsNode

  • checkIsNode(): void

checkNodeOrdering

  • checkNodeOrdering(): void

checkisAVLT

  • checkisAVLT(): void
  • Calls upon super to check that all basic Node validation is met, along with also checking the balance and height correctness of the AVL Node.

    Returns void

createLeftChild

createRightChild

createSimilar

executeOnEveryNode

  • executeOnEveryNode(fn: any): any

getAVLNodeFromKey

getEqualityBounds

  • getEqualityBounds(query: INEQuery): boolean

getLowerBoundMatcher

getMaxKey

getMaxKeyDescendant

  • getMaxKeyDescendant<T>(): Node<T>

getMinKey

getMinKeyDescendant

  • getMinKeyDescendant<T>(): Node<T>

getNumberOfKeys

  • getNumberOfKeys(): number

getTreeAsArrayOfArrays

  • getTreeAsArrayOfArrays<T>(): any[]
  • Returns binary tree as an array of arrays. Example: Inserting 0 - 4 keys in AVL tree would return this example with this method. inserts them as they would be seen in the binary tree 1 / \ 0 3 / \ / \ null null 2 4

    [ [ { key: 1, value: [Object] }], [{key: 0, value: [Object]},{key: 3, value: [Object]}], [ null, null, {key: 2, value: [Object]}, {key: 4, value: [Object]}] ]

    Type parameters

    • T

    Returns any[]

getTreeHeight

  • getTreeHeight<T>(tree: Node<T>): number

getUpperBoundMatcher

Protected leftRotation

  • Perform a left rotation of the tree if possible and return the root of the resulting tree The resulting tree's nodes' heights are also updated

    Returns AVLNode

Protected leftTooSmall

  • Modify the tree if its left subtree is too small compared to the right. Return the new root if any.

    Returns AVLNode

query

Protected rebalanceAlongPath

  • Re-balance the tree along the given path. The path is given reversed Returns the new root of the tree Of course, the first element of the path must be the root of the tree

    Parameters

    Returns AVLNode

returnThisAVL

  • returnThisAVL(): this

returnThisNode

  • returnThisNode(): this

Protected rightRotation

  • Perform a right rotation of the tree if possible and return the root of the resulting tree The resulting tree's nodes' heights are also updated

    Returns AVLNode

Protected rightTooSmall

  • Modify the tree if its right subtree is too small compared to the left. Return the new root if any.

    Returns AVLNode

search

toJSON

  • toJSON<T>(): any
  • Turn tree into JSON with an array of objects holding the key and value Requires that key and value can be turned into JSON

    Type parameters

    • T

    Returns any

Generated using TypeDoc