@Test public void shouldIntersectTwoSetsWhenEmptySets() { SortedRangeSet<Asn, AsnRange> other = new SortedRangeSet<Asn, AsnRange>(); SortedRangeSet<Asn, AsnRange> expected = new SortedRangeSet<Asn, AsnRange>(); assertEquals(expected, subject.intersection(other)); }
public SortedRangeSet<C, R> intersection(SortedRangeSet<C, R> other) { SortedRangeSet<C, R> result = new SortedRangeSet<C, R>(); for (R thisRange : set) { R leftSide = other.set.floor(thisRange); R rightSide = other.set.ceiling(thisRange); if (thisRange.overlaps(leftSide)) { result.add(thisRange.intersection(leftSide)); } if (thisRange.overlaps(rightSide)) { result.add(thisRange.intersection(rightSide)); } } return result; }
SortedRangeSet implements Iterable<R> { public SortedRangeSet<C, R> intersection(SortedRangeSet<C, R> other) { SortedRangeSet<C, R> result = new SortedRangeSet<C, R>(); for (R thisRange : set) { R leftSide = other.set.floor(thisRange); R rightSide = other.set.ceiling(thisRange); if (thisRange.overlaps(leftSide)) { result.add(thisRange.intersection(leftSide)); } if (thisRange.overlaps(rightSide)) { result.add(thisRange.intersection(rightSide)); } } return result; } }
SortedRangeSet implements Iterable<R> { public SortedRangeSet<C, R> intersection(SortedRangeSet<C, R> other) { SortedRangeSet<C, R> result = new SortedRangeSet<C, R>(); for (R thisRange : set) { R leftSide = other.set.floor(thisRange); R rightSide = other.set.ceiling(thisRange); if (thisRange.overlaps(leftSide)) { result.add(thisRange.intersection(leftSide)); } if (thisRange.overlaps(rightSide)) { result.add(thisRange.intersection(rightSide)); } } return result; } SortedRangeSet(); }
SortedRangeSet implements Iterable<R> { public SortedRangeSet<C, R> intersection(SortedRangeSet<C, R> other) { SortedRangeSet<C, R> result = new SortedRangeSet<C, R>(); for (R thisRange : set) { R leftSide = other.set.floor(thisRange); R rightSide = other.set.ceiling(thisRange); if (thisRange.overlaps(leftSide)) { result.add(thisRange.intersection(leftSide)); } if (thisRange.overlaps(rightSide)) { result.add(thisRange.intersection(rightSide)); } } return result; } SortedRangeSet(); void addAll(SortedRangeSet<C, R> ranges); void addAll(Collection<R> ranges); void add(R range); void removeAll(SortedRangeSet<C, R> ranges); void removeAll(Collection<R> ranges); boolean remove(R range); SortedRangeSet<C, R> intersection(SortedRangeSet<C, R> other); @Override final boolean equals(Object o); @Override final int hashCode(); boolean contains(R range); void clear(); boolean isEmpty(); int size(); Set<R> unmodifiableSet(); Set<R> modifiableSet(); R getSingleRange(); R floor(R range); R ceiling(R range); @Override Iterator<R> iterator(); @Override String toString(); }
SortedRangeSet implements Iterable<R> { public SortedRangeSet<C, R> intersection(SortedRangeSet<C, R> other) { SortedRangeSet<C, R> result = new SortedRangeSet<C, R>(); for (R thisRange : set) { R leftSide = other.set.floor(thisRange); R rightSide = other.set.ceiling(thisRange); if (thisRange.overlaps(leftSide)) { result.add(thisRange.intersection(leftSide)); } if (thisRange.overlaps(rightSide)) { result.add(thisRange.intersection(rightSide)); } } return result; } SortedRangeSet(); void addAll(SortedRangeSet<C, R> ranges); void addAll(Collection<R> ranges); void add(R range); void removeAll(SortedRangeSet<C, R> ranges); void removeAll(Collection<R> ranges); boolean remove(R range); SortedRangeSet<C, R> intersection(SortedRangeSet<C, R> other); @Override final boolean equals(Object o); @Override final int hashCode(); boolean contains(R range); void clear(); boolean isEmpty(); int size(); Set<R> unmodifiableSet(); Set<R> modifiableSet(); R getSingleRange(); R floor(R range); R ceiling(R range); @Override Iterator<R> iterator(); @Override String toString();  }