Interval extends PartiallyOrdered<Interval<C>> implements Comparable<Interval<C>> { public Interval<C> gap(final Interval<C> that) { if(this.before(that)) { return this.ahead().intersect(that.behind()); } if(this.after(that)) { return this.behind().intersect(that.ahead()); } return NULL; } private  Interval(); private  Interval(int dimension); private  Interval(final Range<C> range);  Interval(int dimension, final Range<C> range); @Override Interval<C> intersect(final Interval<C> that); @Override Interval<C> union(final Interval<C> that); Interval<C> coalesce(final Interval<C> that); @Override double measure(); boolean isConnected(final Interval<C> that); boolean hasAll(); boolean hasNone(); boolean isDimensionless(); int getDimension(); @Beta Difference<C> minus(final Interval<C> that); @Beta Difference<C> complement(); Interval<C> ahead(); Interval<C> behind(); Interval<C> gap(final Interval<C> that); boolean before(final Interval<C> that); boolean after(final Interval<C> that); boolean between(final Interval<C> that, final Interval<C> other); boolean overlaps(final Interval<C> that); boolean then(final Interval<C> that); boolean starts(final Interval<C> that); boolean ends(final Interval<C> that); @Override boolean equals(final Object that); @Override String toString(); @Override int hashCode(); Range<C> toRange(); @Override int compareTo(Interval<C> that); final static Interval NULL; final static Interval MAGIC; }
@Test public void testGap() { assertEquals(a.gap(b), y); assertEquals(b.gap(a), y); assertEquals(a.gap(a), Interval.NULL); assertEquals(a.gap(Interval.MAGIC), Interval.NULL); }