public FloatingPointInterval<T> intersection(final FloatingPointInterval<T> that) { final int ll = _lower.compareTo(that._lower); final int uu = _upper.compareTo(that._upper); if (ll <= 0) { if (uu < 0) { if (_upper.compareTo(that._lower) < 0) return null; else return create(that._lower, _upper); } else return that; } else if (uu > 0) { if (_lower.compareTo(that._upper) > 0) return null; else return create(_lower, that._upper); } else return this; }
public FloatingPointInterval<T> intersection(final FloatingPointInterval<T> that) { final int ll = _lower.compareTo(that._lower); final int uu = _upper.compareTo(that._upper); if (ll <= 0) { if (uu < 0) { if (_upper.compareTo(that._lower) < 0) return null; else return create(that._lower, _upper); } else return that; } else if (uu > 0) { if (_lower.compareTo(that._upper) > 0) return null; else return create(_lower, that._upper); } else return this; }
/** * Get the subinterval greater than n * * @param n * @return a new interval, formed by intersecting this interval with (n,+inf) or <code>null</code> if that intersection is empty */ public FloatingPointInterval<T> greater(final T n) { if (n == null) throw new NullPointerException(); if (_type.isNaN(n)) throw new IllegalArgumentException(); if (getLower().compareTo(n) >= 0) return this; else if (getUpper().compareTo(n) <= 0) return null; else return create(_type.increment(n), getUpper()); }
/** * Get the subinterval less than n * * @param n * @return a new interval, formed by intersecting this interval with (-inf,n) or <code>null</code> if that intersection is empty */ public FloatingPointInterval<T> less(final T n) { if (n == null) throw new NullPointerException(); if (_type.isNaN(n)) throw new IllegalArgumentException(); if (getUpper().compareTo(n) <= 0) return this; else if (getLower().compareTo(n) >= 0) return null; else return create(getLower(), _type.decrement(n)); }
/** * Get the subinterval greater than n * * @param n * @return a new interval, formed by intersecting this interval with (n,+inf) or <code>null</code> if that intersection is empty */ public FloatingPointInterval<T> greater(final T n) { if (n == null) throw new NullPointerException(); if (_type.isNaN(n)) throw new IllegalArgumentException(); if (getLower().compareTo(n) >= 0) return this; else if (getUpper().compareTo(n) <= 0) return null; else return create(_type.increment(n), getUpper()); }
/** * Get the subinterval less than n * * @param n * @return a new interval, formed by intersecting this interval with (-inf,n) or <code>null</code> if that intersection is empty */ public FloatingPointInterval<T> less(final T n) { if (n == null) throw new NullPointerException(); if (_type.isNaN(n)) throw new IllegalArgumentException(); if (getUpper().compareTo(n) <= 0) return this; else if (getLower().compareTo(n) >= 0) return null; else return create(getLower(), _type.decrement(n)); }