diff --git a/intervalset.go b/intervalset.go index be36c4d..27e5a71 100644 --- a/intervalset.go +++ b/intervalset.go @@ -246,19 +246,8 @@ func deleteRange[E Elem[E]](x Set[E], lo, hi E) Set[E] { // Contains reports whether x contains every element in range [r.Low, r.High). func (x Set[E]) Contains(r Interval[E]) bool { - return x.ContainsRange(r.Low, r.High) -} - -// ContainsOne reports whether x contains a single element v. -func (x Set[E]) ContainsOne(v E) bool { - i := sort.Search(len(x), func(i int) bool { return x[i].High.Compare(v) > 0 }) - return i < len(x) && x[i].Low.Compare(v) <= 0 -} - -// ContainsRange reports whether x contains every element in range [lo, hi). -func (x Set[E]) ContainsRange(lo, hi E) bool { - i := sort.Search(len(x), func(i int) bool { return x[i].High.Compare(lo) > 0 }) - return i < len(x) && x[i].Low.Compare(lo) <= 0 && x[i].High.Compare(hi) >= 0 && lo.Compare(hi) < 0 + i := sort.Search(len(x), func(i int) bool { return x[i].High.Compare(r.Low) > 0 }) + return i < len(x) && x[i].Low.Compare(r.Low) <= 0 && x[i].High.Compare(r.High) >= 0 && r.Low.Compare(r.High) < 0 } // Equal reports whether x is identical to y. diff --git a/intervalset_test.go b/intervalset_test.go index e1c7dec..f79c21e 100644 --- a/intervalset_test.go +++ b/intervalset_test.go @@ -141,14 +141,14 @@ func TestContains(t *testing.T) { s := Set[E]{{1, 3}, {5, 7}} assertions := []bool{ - s.ContainsOne(0) == false, - s.ContainsOne(1) == true, - s.ContainsOne(2) == true, - s.ContainsOne(3) == false, - s.ContainsOne(4) == false, - s.ContainsOne(5) == true, - s.ContainsOne(6) == true, - s.ContainsOne(7) == false, + s.Contains(One[E](0)) == false, + s.Contains(One[E](1)) == true, + s.Contains(One[E](2)) == true, + s.Contains(One[E](3)) == false, + s.Contains(One[E](4)) == false, + s.Contains(One[E](5)) == true, + s.Contains(One[E](6)) == true, + s.Contains(One[E](7)) == false, s.Contains(Range[E](1, 3)) == true, s.Contains(Range[E](3, 5)) == false, s.Contains(Range[E](5, 7)) == true,