Constructor of the AVLTree class
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.
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.
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.
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.
Used to hold the depth of the tree at this point.
The key used to find this Node
Holds a child of this type Node as a Node in this type tree.
Holds the parent of this type Node as a Node in this type tree.
Holds a child of this type Node as a Node in this type tree.
The AVL Tree, accumulation of AVL Nodes.
set in the constructor to have only unique keys
The value this Node holds
Returns the balance factor.
Compare all keys, if there is no key then node fails then tree fails validation check. keys have to be of the same type.
Check that the balance factors are between -1 and 1. Otherwise throw an error.
Check the recorded height for this AVL Node and all children. Throws an error if one height does not match.
Make sure this Node is referenced in children correctly and check all sub Nodes.
Used to check entire tree structure and individual branches to validate pointers.
Check all nodes and use compare keys function to validate Node and children of this Node.
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.
Create a left child AVL Node with a reference to this parent AVL Node
Create a right child AVL Node with a reference to this parent AVL Node
Create a new AVL Node similar to this one except without the key and value
Execute a function on every node of the tree, in key order
Check if this.key passes the equality check. A positive match will return false and a negative match will return true.
Base method used in high method to compare keys of two Nodes.
Example query: { $gt: 3 } or { $gte: 5 }
Returns the key of the max descendant
Recursively call for right child till there is none then return this.
Returns the key of the min descendant
Recursively call for left child till there is none then return this.
Count every key in branch or entire tree.
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]}] ]
Retrieve the height at this current Node location
Base method used in high method to compare keys of two Nodes.
Example usage: { $lt: 3 } or { $lte: 4 }
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
Modify the tree if its left subtree is too small compared to the right. Return the new root if any.
Method for retrieving values based on key comparison of gt & lt & ne
Example: { $gt: 1 , $lte: 3, $ne: 2 }
To return this class if this class were to be extended.
To return this class and not the extended version use this method.
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
Modify the tree if its right subtree is too small compared to the left. Return the new root if 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
Generated using TypeDoc
Tree class for the AVL Nodes