func (s *Set) Extent() Interval {
	if len(s.intervals) == 0 {
		return s.factory.makeZero()
	}
	return s.intervals[0].Encompass(s.intervals[len(s.intervals)-1])
}
Extent returns the Interval defined by the minimum and maximum values of the
set.
package intervalset
import (
	"fmt"
	"sort"
	"strings"
)
type Interval interface {
	Intersect(Interval) Interval
	Before(Interval) bool
	IsZero() bool
	Bisect(x Interval) (Interval, Interval)
	Adjoin(Interval) Interval
	Encompass(Interval) Interval
}
type Set struct {
	intervals []Interval
	factory intervalFactory
}
type SetInput interface {
	Extent() Interval
	IntervalsBetween(extents Interval, f IntervalReceiver)
}
func NewSet(intervals []Interval) *Set {
	return NewSetV1(intervals, oldBehaviorFactory.makeZero)
}
func NewSetV1(intervals []Interval, makeZero func() Interval) *Set {
	if err := CheckSorted(intervals); err != nil {
		panic(err)
	}
	return &Set{intervals, makeIntervalFactor(makeZero)}
}
func CheckSorted(intervals []Interval) error {
	for i := 0; i < len(intervals)-1; i++ {
		if !intervals[i].Before(intervals[i+1]) {
			return fmt.Errorf("!intervals[%d].Before(intervals[%d]) for %s, %s", i, i+1, intervals[i], intervals[i+1])
		}
	}
	return nil
}
func Empty() *Set {
	return EmptyV1(oldBehaviorFactory.makeZero)
}
func EmptyV1(makeZero func() Interval) *Set {
	return &Set{nil, makeIntervalFactor(makeZero)}
}
func (s *Set) Copy() *Set {
	return &Set{append([]Interval(nil), s.intervals...), s.factory}
}
func (s *Set) String() string {
	var strs []string
	for _, x := range s.intervals {
		strs = append(strs, fmt.Sprintf("%s", x))
	}
	return fmt.Sprintf("{%s}", strings.Join(strs, ", "))
}