/** Return the interval with elements from this not in other; * other must not be totally enclosed (properly contained) * within this, which would result in two disjoint intervals * instead of the single one returned by this method. */ public Interval differenceNotProperlyContained(Interval other) { Interval diff = null; // other.a to left of this.a (or same) if ( other.startsBeforeNonDisjoint(this) ) { diff = Interval.of(Math.max(this.a, other.b + 1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.of(this.a, other.a - 1); } return diff; }
/** Return the interval with elements from this not in other; * other must not be totally enclosed (properly contained) * within this, which would result in two disjoint intervals * instead of the single one returned by this method. */ public Interval differenceNotProperlyContained(Interval other) { Interval diff = null; // other.a to left of this.a (or same) if ( other.startsBeforeNonDisjoint(this) ) { diff = Interval.of(Math.max(this.a, other.b + 1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.of(this.a, other.a - 1); } return diff; }
/** Return the interval with elements from this not in other; * other must not be totally enclosed (properly contained) * within this, which would result in two disjoint intervals * instead of the single one returned by this method. */ public Interval differenceNotProperlyContained(Interval other) { Interval diff = null; // other.a to left of this.a (or same) if ( other.startsBeforeNonDisjoint(this) ) { diff = Interval.of(Math.max(this.a, other.b + 1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.of(this.a, other.a - 1); } return diff; }
/** Return the interval with elements from {@code this} not in {@code other}; * {@code other} must not be totally enclosed (properly contained) * within {@code this}, which would result in two disjoint intervals * instead of the single one returned by this method. */ public Interval differenceNotProperlyContained(Interval other) { Interval diff = null; // other.a to left of this.a (or same) if ( other.startsBeforeNonDisjoint(this) ) { diff = Interval.of(Math.max(this.a, other.b + 1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.of(this.a, other.a - 1); } return diff; }
/** Return the interval with elements from this not in other; * other must not be totally enclosed (properly contained) * within this, which would result in two disjoint intervals * instead of the single one returned by this method. */ public Interval differenceNotProperlyContained(Interval other) { Interval diff = null; // other.a to left of this.a (or same) if ( other.startsBeforeNonDisjoint(this) ) { diff = Interval.of(Math.max(this.a, other.b + 1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.of(this.a, other.a - 1); } return diff; }