/** Return the interval in common between this and o */ public Interval intersection(Interval other) { return Interval.create(Math.max(a,other.a), Math.min(b,other.b)); }
/** Return the interval in common between this and o */ public Interval intersection(Interval other) { return Interval.create(Math.max(a,other.a), Math.min(b,other.b)); }
/** Return the interval computed from combining this and other */ public Interval union(Interval other) { return Interval.create(Math.min(a,other.a), Math.max(b,other.b)); }
/** Return the interval computed from combining this and other */ public Interval union(Interval other) { return Interval.create(Math.min(a,other.a), Math.max(b,other.b)); }
/** Return the interval computed from combining this and other */ public Interval union(Interval other) { return Interval.create(Math.min(a,other.a), Math.max(b,other.b)); }
/** Return the interval in common between this and o */ public Interval intersection(Interval other) { return Interval.create(Math.max(a,other.a), Math.min(b,other.b)); }
/** Return the interval computed from combining this and other */ public Interval union(Interval other) { return Interval.create(Math.min(a,other.a), Math.max(b,other.b)); }
/** Return the interval in common between this and o */ public Interval intersection(Interval other) { return Interval.create(Math.max(a,other.a), Math.min(b,other.b)); }
/** Add interval; i.e., add all integers from a to b to set. * If b<a, do nothing. * Keep list in sorted order (by left range value). * If overlap, combine ranges. For example, * If this is {1..5, 10..20}, adding 6..7 yields * {1..5, 6..7, 10..20}. Adding 4..8 yields {1..8, 10..20}. */ public void add(int a, int b) { add(Interval.create(a,b)); }
/** Add interval; i.e., add all integers from a to b to set. * If b<a, do nothing. * Keep list in sorted order (by left range value). * If overlap, combine ranges. For example, * If this is {1..5, 10..20}, adding 6..7 yields * {1..5, 6..7, 10..20}. Adding 4..8 yields {1..8, 10..20}. */ public void add(int a, int b) { add(Interval.create(a,b)); }
/** Add interval; i.e., add all integers from a to b to set. * If b<a, do nothing. * Keep list in sorted order (by left range value). * If overlap, combine ranges. For example, * If this is {1..5, 10..20}, adding 6..7 yields * {1..5, 6..7, 10..20}. Adding 4..8 yields {1..8, 10..20}. */ public void add(int a, int b) { add(Interval.create(a,b)); }
/** Add interval; i.e., add all integers from a to b to set. * If b<a, do nothing. * Keep list in sorted order (by left range value). * If overlap, combine ranges. For example, * If this is {1..5, 10..20}, adding 6..7 yields * {1..5, 6..7, 10..20}. Adding 4..8 yields {1..8, 10..20}. */ public void add(int a, int b) { add(Interval.create(a,b)); }
/** 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.create(Math.max(this.a,other.b+1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.create(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.create(Math.max(this.a,other.b+1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.create(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.create(Math.max(this.a,other.b+1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.create(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.create(Math.max(this.a,other.b+1), this.b); } // other.a to right of this.a else if ( other.startsAfterNonDisjoint(this) ) { diff = Interval.create(this.a, other.a-1); } return diff; }