diff --git a/pkg/intervals/interval.go b/pkg/intervals/interval.go index 9570b0d..4834b3a 100644 --- a/pkg/intervals/interval.go +++ b/pkg/intervals/interval.go @@ -27,16 +27,6 @@ func (i *Interval) overlaps(other Interval) bool { return other.End >= i.Start && other.Start <= i.End } -func (i *Interval) touches(other Interval) bool { - if i.Start > other.End { - return i.Start == other.End+1 - } - if other.Start > i.End { - return other.Start == i.End+1 - } - return false -} - func (i *Interval) isSubset(other Interval) bool { return other.Start <= i.Start && other.End >= i.End } diff --git a/pkg/intervals/intervalset.go b/pkg/intervals/intervalset.go index bccef84..708bba5 100644 --- a/pkg/intervals/intervalset.go +++ b/pkg/intervals/intervalset.go @@ -36,8 +36,8 @@ func (c *CanonicalIntervalSet) Equal(other CanonicalIntervalSet) bool { } // Insert updates the current Set with a new Interval to add -func (s *CanonicalIntervalSet) AddInterval(v Interval) { - set := s.IntervalSet +func (c *CanonicalIntervalSet) AddInterval(v Interval) { + set := c.IntervalSet left := sort.Search(len(set), func(i int) bool { return set[i].End >= v.Start-1 }) @@ -50,7 +50,7 @@ func (s *CanonicalIntervalSet) AddInterval(v Interval) { if right > 0 && set[right-1].End >= v.Start { v.End = max(v.End, set[right-1].End) } - s.IntervalSet = slices.Replace(s.IntervalSet, left, right, v) + c.IntervalSet = slices.Replace(c.IntervalSet, left, right, v) } // AddHole updates the current CanonicalIntervalSet object by removing the input Interval from the set