first commit

This commit is contained in:
Daniel Gil
2018-05-24 14:14:10 +02:00
commit 21187ac4df
5 changed files with 337 additions and 0 deletions

20
interval.go Normal file
View File

@@ -0,0 +1,20 @@
package interval
import "fmt"
type Interval struct {
Low int
High int
Object interface{}
}
func (itvl Interval) String() string {
return fmt.Sprintf("(%v, %v) -> [%v]", itvl.Low, itvl.High, itvl.Object)
}
// ByLow implements sort.Interface for []Interval based on the Low field.
type ByLow []*Interval
func (itvls ByLow) Len() int { return len(itvls) }
func (itvls ByLow) Swap(i, j int) { itvls[i], itvls[j] = itvls[j], itvls[i] }
func (itvls ByLow) Less(i, j int) bool { return itvls[i].Low < itvls[j].Low }