// Delete removes the node with the given interval from the tree, returning
// true if a node is in fact removed.
Delete removes the node with the given interval from the tree, returning
true if a node is in fact removed.
// Delete removes the node with the given interval from the tree returning // true if a node is in fact removed .
func (ivt *intervalTree) Delete(ivl Interval) bool {
	z := ivt.find(ivl)
	if z == ivt.nilNode {
		return false
	}
	y := z
	if z.left != ivt.nilNode && z.right != ivt.nilNode {
		y = z.successor(ivt.nilNode)
	}
	x := ivt.nilNode
	if y.left != ivt.nilNode {
		x = y.left
	} else if y.right != ivt.nilNode {
		x = y.right
	}
	x.parent = y.parent
	if y.parent == ivt.nilNode {
		ivt.root = x
	} else {
		if y == y.parent.left {
			y.parent.left = x
		} else {
			y.parent.right = x
		}
		y.parent.updateMax(ivt.nilNode)
	}
	if y != z {
		z.iv = y.iv
		z.updateMax(ivt.nilNode)
	}
	if y.color(ivt.nilNode) == black {
		ivt.deleteFixup(x)
	}
	ivt.count--
	return true
}
func ( ivt * intervalTree ) Delete ( ivl Interval ) bool { z := ivt . find ( ivl ) if z == ivt . nilNode { return false } y := z if z . left != ivt . nilNode && z . right != ivt . nilNode { y = z . successor ( ivt . nilNode ) } x := ivt . nilNode if y . left != ivt . nilNode { x = y . left } else if y . right != ivt . nilNode { x = y . right } x . parent = y . parent if y . parent == ivt . nilNode { ivt . root = x } else { if y == y . parent . left { y . parent . left = x } else { y . parent . right = x } y . parent . updateMax ( ivt . nilNode ) } if y != z { z . iv = y . iv z . updateMax ( ivt . nilNode ) } if y . color ( ivt . nilNode ) == black { ivt . deleteFixup ( x ) } ivt . count -- return true }
Delete removes the node with the given interval from the tree, returning
true if a node is in fact removed.
Delete removes the node with the given interval from the tree returning true if a node is in fact removed .