pkg/adt/interval_tree.go
func (ivt *IntervalTree) Contains(ivl Interval) bool {
	var maxEnd, minBegin Comparable

	isContiguous := true
	ivt.Visit(ivl, func(n *IntervalValue) bool {
		if minBegin == nil {
			minBegin = n.Ivl.Begin
			maxEnd = n.Ivl.End
			return true
		}
		if maxEnd.Compare(n.Ivl.Begin) < 0 {
			isContiguous = false
			return false
		}
		if n.Ivl.End.Compare(maxEnd) > 0 {
			maxEnd = n.Ivl.End
		}
		return true
	})

	return isContiguous && minBegin != nil && maxEnd.Compare(ivl.End) >= 0 && minBegin.Compare(ivl.Begin) <= 0
}
func (ivt *IntervalTree) Contains(ivl Interval) bool {
	var maxEnd, minBegin Comparable

	isContiguous := true
	ivt.Visit(ivl, func(n *IntervalValue) bool {
		if minBegin == nil {
			minBegin = n.Ivl.Begin
			maxEnd = n.Ivl.End
			return true
		}
		if maxEnd.Compare(n.Ivl.Begin) < 0 {
			isContiguous = false
			return false
		}
		if n.Ivl.End.Compare(maxEnd) > 0 {
			maxEnd = n.Ivl.End
		}
		return true
	})

	return isContiguous && minBegin != nil && maxEnd.Compare(ivl.End) >= 0 && minBegin.Compare(ivl.Begin) <= 0
}
func ( ivt * IntervalTree ) Contains ( ivl Interval ) bool { var maxEnd , minBegin Comparable isContiguous := true ivt . Visit ( ivl , func ( n * IntervalValue ) bool { if minBegin == nil { minBegin = n . Ivl . Begin maxEnd = n . Ivl . End return true } if maxEnd . Compare ( n . Ivl . Begin ) < 0 { isContiguous = false return false } if n . Ivl . End . Compare ( maxEnd ) > 0 { maxEnd = n . Ivl . End } return true } ) return isContiguous && minBegin != nil && maxEnd . Compare ( ivl . End ) >= 0 && minBegin . Compare ( ivl . Begin ) <= 0 }
// Contains returns true if the interval tree's keys cover the entire given interval.
Contains returns true if the interval tree s keys cover the entire given interval .