private FloatingPointInterval<T> create(final T lower, final T upper) { return new FloatingPointInterval<>(_type, lower, upper); }
/** * 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()); }
if (negated) intersectWith = Collections.singletonList(FloatingPointInterval.unconstrained(_type)); for (final FloatingPointInterval<T> i : otherRRD._intervals) tmp.addAll(j.remove(i)); intersectWith = tmp; for (final FloatingPointInterval<T> j : intersectWith) final FloatingPointInterval<T> k = i.intersection(j); if (k != i)
if (i.canUnionWith(j)) tmp.addAll(i.union(j)); revisedIntervals.addAll(tmp);
throw new IllegalStateException(); final FloatingPointInterval<T> restriction = new FloatingPointInterval<>(_type, lower, upper); final FloatingPointInterval<T> j = i.intersection(restriction); if (j != null)
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; }
@Override public boolean contains(final Object value) { if (_type.isInstance(value)) { final T n = _type.cast(value); if (_type.isNaN(n)) return _containsNaN; else { for (final FloatingPointInterval<T> i : _intervals) if (i.contains(n)) return true; return false; } } else return false; }
if (negated) intersectWith = Collections.singletonList(FloatingPointInterval.unconstrained(_type)); for (final FloatingPointInterval<T> i : otherRRD._intervals) tmp.addAll(j.remove(i)); intersectWith = tmp; for (final FloatingPointInterval<T> j : intersectWith) final FloatingPointInterval<T> k = i.intersection(j); if (k != i)
if (i.canUnionWith(j)) tmp.addAll(i.union(j)); revisedIntervals.addAll(tmp);
throw new IllegalStateException(); final FloatingPointInterval<T> restriction = new FloatingPointInterval<>(_type, lower, upper); final FloatingPointInterval<T> j = i.intersection(restriction); if (j != null)
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; }
@Override public boolean contains(final Object value) { if (_type.isInstance(value)) { final T n = _type.cast(value); if (_type.isNaN(n)) return _containsNaN; else { for (final FloatingPointInterval<T> i : _intervals) if (i.contains(n)) return true; return false; } } else return false; }
/** * 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)); }
private FloatingPointInterval<T> create(final T lower, final T upper) { return new FloatingPointInterval<>(_type, lower, upper); }
/** * 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()); }