@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Set)) return false;

        if (o instanceof RangeSet) {
            RangeSet other = (RangeSet) o;
            return this.from == other.from && this.to == other.to;
        }

        Set<?> otherSet = (Set<?>) o;
        if (otherSet.size() != this.size()) return false;

        for (int i = from; i < to; i++) {
            if (!otherSet.contains(i)) return false;
        }
        return true;
    }
@Test
    void testEquals() {
        RangeSet rangeSet1 = new RangeSet(5, 10);
        RangeSet rangeSet2 = new RangeSet(5, 10);
        RangeSet rangeSet3 = new RangeSet(6, 10);
        Set<Integer> set = mkSet(5, 6, 7, 8, 9);
        HashSet<Integer> hashSet = new HashSet<>(mkSet(6, 7, 8, 9));

        assertEquals(rangeSet1, rangeSet2);
        assertNotEquals(rangeSet1, rangeSet3);
        assertEquals(rangeSet1, set);
        assertEquals(rangeSet3, hashSet);
        assertNotEquals(rangeSet1, new Object());
    }