IntervalNode
internal class
Represents a node in the binary search tree, with the addition of a “high” value which keeps track of the highest value of its children. References: https://brooknovak.wordpress.com/2013/12/07/augmented-interval-tree-in-c/ http://www.mif.vu.lt/~valdas/ALGORITMAI/LITERATURA/Cormen/Cormen.pdf
Constructor
Section titled “Constructor”new IntervalNode(low: number, high: number, event: IntervalTimelineEvent)Parameters
- low
number - high
number - event
IntervalTimelineEvent
Properties
Section titled “Properties”event: IntervalTimelineEvent | nullhigh: numberlow: numbermax: numberMethods
Section titled “Methods”getBalance()
Section titled “getBalance()”getBalance(): numberThe balance is how the leafs are distributed on the node
Returns number Negative numbers are balanced to the right
insert()
Section titled “insert()”insert(node: IntervalNode): voidInsert a node into the correct spot in the tree
Parameters
- node
IntervalNode
isLeftChild()
Section titled “isLeftChild()”isLeftChild(): booleanReturns boolean true if this node is the left child of its parent
search()
Section titled “search()”search(point: number, results: IntervalNode[]): voidSearch the tree for nodes which overlap with the given point
Parameters
-
point
numberThe point to query
-
results
IntervalNode[]The array to put the results
searchAfter()
Section titled “searchAfter()”searchAfter(point: number, results: IntervalNode[]): voidSearch the tree for nodes which are less than the given point
Parameters
-
point
numberThe point to query
-
results
IntervalNode[]The array to put the results
traverse()
Section titled “traverse()”traverse(callback: (self: IntervalNode) => void): voidInvoke the callback on this element and both its branches
Parameters
- callback
(self: IntervalNode) => void