update method
void
update()
Recalculates height and maxEnd of this node based on its children.
Implementation
void update() {
final leftNode = left;
final rightNode = right;
final leftHeight = leftNode?.height ?? 0;
final rightHeight = rightNode?.height ?? 0;
height = 1 + (leftHeight > rightHeight ? leftHeight : rightHeight);
var max = interval.end;
if (leftNode != null && leftNode.maxEnd.compareTo(max) > 0) {
max = leftNode.maxEnd;
}
if (rightNode != null && rightNode.maxEnd.compareTo(max) > 0) {
max = rightNode.maxEnd;
}
maxEnd = max;
}