// Insert adds a node with the given interval into the tree.
Insert adds a node with the given interval into the tree.
// Insert adds a node with the given interval into the tree .
func (ivt *intervalTree) Insert(ivl Interval, val interface{}) {
	y := ivt.nilNode
	z := ivt.createIntervalNode(ivl, val)
	x := ivt.root
	for x != ivt.nilNode {
		y = x
		if z.iv.Ivl.Begin.Compare(x.iv.Ivl.Begin) < 0 {
			x = x.left
		} else {
			x = x.right
		}
	}
	z.parent = y
	if y == ivt.nilNode {
		ivt.root = z
	} else {
		if z.iv.Ivl.Begin.Compare(y.iv.Ivl.Begin) < 0 {
			y.left = z
		} else {
			y.right = z
		}
		y.updateMax(ivt.nilNode)
	}
	z.c = red
	ivt.insertFixup(z)
	ivt.count++
}
func ( ivt * intervalTree ) Insert ( ivl Interval , val interface { } ) { y := ivt . nilNode z := ivt . createIntervalNode ( ivl , val ) x := ivt . root for x != ivt . nilNode { y = x if z . iv . Ivl . Begin . Compare ( x . iv . Ivl . Begin ) < 0 { x = x . left } else { x = x . right } } z . parent = y if y == ivt . nilNode { ivt . root = z } else { if z . iv . Ivl . Begin . Compare ( y . iv . Ivl . Begin ) < 0 { y . left = z } else { y . right = z } y . updateMax ( ivt . nilNode ) } z . c = red ivt . insertFixup ( z ) ivt . count ++ }
Insert adds a node with the given interval into the tree.
Insert adds a node with the given interval into the tree .