Skip to content
Tone.js

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

new IntervalNode(low: number, high: number, event: IntervalTimelineEvent)

Parameters

height: number

Default: 0

high: number
low: number
max: number
parent: IntervalNode | null

Default: null

left: IntervalNode | null

get/set the left node

right: IntervalNode | null

get/set the right node

dispose(): void

null out references.

getBalance(): number

The balance is how the leafs are distributed on the node

Returns number Negative numbers are balanced to the right

insert(node: IntervalNode): void

Insert a node into the correct spot in the tree

Parameters

isLeftChild(): boolean

Returns boolean true if this node is the left child of its parent

search(point: number, results: IntervalNode[]): void

Search the tree for nodes which overlap with the given point

Parameters

  • point number

    The point to query

  • results IntervalNode[]

    The array to put the results

searchAfter(point: number, results: IntervalNode[]): void

Search the tree for nodes which are less than the given point

Parameters

  • point number

    The point to query

  • results IntervalNode[]

    The array to put the results

traverse(callback: (self: IntervalNode) => void): void

Invoke the callback on this element and both it’s branches

Parameters

updateHeight(): void

Update the height of the node

updateMax(): void

Update the height of the node