@Test public void intersects() { Interval a = new Interval(13, 14); Interval b = new Interval(9, 10); assertEquals("a.intersects(b)", false, a.intersects(b)); assertEquals("b.intersects(a)", false, b.intersects(a)); }
public boolean intersects(Interval other) { if (this.startIndex <= other.startIndex && other.startIndex <= this.endIndex) { return true; } if (this.startIndex <= other.endIndex && other.endIndex <= this.endIndex) { return true; } if (other.startIndex <= this.startIndex && this.startIndex <= other.endIndex) { return true; } if (other.startIndex <= this.endIndex && this.endIndex <= other.endIndex) { return true; } return false; }
Interval { public boolean intersects(Interval other) { if (this.startIndex <= other.startIndex && other.startIndex <= this.endIndex) { return true; } if (this.startIndex <= other.endIndex && other.endIndex <= this.endIndex) { return true; } if (other.startIndex <= this.startIndex && this.startIndex <= other.endIndex) { return true; } if (other.startIndex <= this.endIndex && this.endIndex <= other.endIndex) { return true; } return false; } }
Interval { public boolean intersects(Interval other) { if (this.startIndex <= other.startIndex && other.startIndex <= this.endIndex) { return true; } if (this.startIndex <= other.endIndex && other.endIndex <= this.endIndex) { return true; } if (other.startIndex <= this.startIndex && this.startIndex <= other.endIndex) { return true; } if (other.startIndex <= this.endIndex && this.endIndex <= other.endIndex) { return true; } return false; } Interval(final int startIndex, final int endIndex); }
Interval { public boolean intersects(Interval other) { if (this.startIndex <= other.startIndex && other.startIndex <= this.endIndex) { return true; } if (this.startIndex <= other.endIndex && other.endIndex <= this.endIndex) { return true; } if (other.startIndex <= this.startIndex && this.startIndex <= other.endIndex) { return true; } if (other.startIndex <= this.endIndex && this.endIndex <= other.endIndex) { return true; } return false; } Interval(final int startIndex, final int endIndex); boolean intersects(Interval other); boolean intersects(Collection<Interval> col); static Interval[] createIntervals(Collection<Integer> indices); static Interval[] createIntervals(int[] indices); String toString(); }
Interval { public boolean intersects(Interval other) { if (this.startIndex <= other.startIndex && other.startIndex <= this.endIndex) { return true; } if (this.startIndex <= other.endIndex && other.endIndex <= this.endIndex) { return true; } if (other.startIndex <= this.startIndex && this.startIndex <= other.endIndex) { return true; } if (other.startIndex <= this.endIndex && this.endIndex <= other.endIndex) { return true; } return false; } Interval(final int startIndex, final int endIndex); boolean intersects(Interval other); boolean intersects(Collection<Interval> col); static Interval[] createIntervals(Collection<Integer> indices); static Interval[] createIntervals(int[] indices); String toString(); final int startIndex; final int endIndex; }