@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; }
public static <U extends Number & Comparable<U>> FloatingPointInterval<U> unconstrained(final FloatingPointType<U> type) { return new FloatingPointInterval<>(type, type.getNegativeInfinity(), type.getPositiveInfinity()); }
public boolean canUnionWith(final FloatingPointInterval<T> other) { final int ll = _lower.compareTo(other._lower); final int uu = _upper.compareTo(other._upper); if (ll <= 0) { if (uu < 0) { if (_upper.compareTo(other._lower) < 0) return _type.increment(_upper).equals(other._lower); else return true; } else return true; } else if (uu > 0) { if (_lower.compareTo(other._upper) > 0) return _type.increment(other._upper).equals(_lower); else return true; } else return true; }
if (_type.isInstance(value)) n = _type.cast(value); else if (_type.isNaN(n)) return _empty; lower = _type.getNegativeInfinity(); if (n.equals(_type.getNegativeInfinity())) return _empty; else upper = _type.decrement(n); lower = _type.getNegativeInfinity(); upper = n; if (XSD.MIN_EXCLUSIVE.equals(f)) if (n.equals(_type.getPositiveInfinity())) return _empty; else lower = n; upper = _type.getPositiveInfinity(); upper = _type.getPositiveInfinity();
final T f = _type.decrement(other._lower); if (f.equals(_type.getNegativeInfinity())) before = null; else else final T f = _type.increment(other._upper); if (f.equals(_type.getPositiveInfinity())) after = null; else after = create(_type.increment(other._upper), _upper); final T f = _type.increment(other._upper); if (f.equals(_type.getPositiveInfinity())) after = create(_type.increment(other._upper), _upper); else after = null;
/** * 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)); }
if (_type.isInstance(o)) final T n = _type.cast(o); for (final Iterator<FloatingPointInterval<T>> it = revisedIntervals.iterator(); it.hasNext();)
/** * Create a point interval. This is equivalent to IEEEFloatInterval(Float, Float) with arguments <code>point,point,true,true</code> * * @param type * @param point Value of point interval */ public FloatingPointInterval(final FloatingPointType<T> type, final T point) { if (type == null) throw new NullPointerException(); if (point == null) throw new NullPointerException(); if (type.isNaN(point)) throw new IllegalArgumentException(); _type = type; _lower = point; _upper = point; }
public Number size() { return _type.intervalSize(_lower, _upper); }
if (_type.isInstance(value)) n = _type.cast(value); else if (_type.isNaN(n)) return _empty; lower = _type.getNegativeInfinity(); if (n.equals(_type.getNegativeInfinity())) return _empty; else upper = _type.decrement(n); lower = _type.getNegativeInfinity(); upper = n; if (XSD.MIN_EXCLUSIVE.equals(f)) if (n.equals(_type.getPositiveInfinity())) return _empty; else lower = n; upper = _type.getPositiveInfinity(); upper = _type.getPositiveInfinity();
final T f = _type.decrement(other._lower); if (f.equals(_type.getNegativeInfinity())) before = null; else else final T f = _type.increment(other._upper); if (f.equals(_type.getPositiveInfinity())) after = null; else after = create(_type.increment(other._upper), _upper); final T f = _type.increment(other._upper); if (f.equals(_type.getPositiveInfinity())) after = create(_type.increment(other._upper), _upper); else after = null;
/** * 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)); }
if (_type.isInstance(o)) final T n = _type.cast(o); for (final Iterator<FloatingPointInterval<T>> it = revisedIntervals.iterator(); it.hasNext();)
/** * Create a point interval. This is equivalent to IEEEFloatInterval(Float, Float) with arguments <code>point,point,true,true</code> * * @param type * @param point Value of point interval */ public FloatingPointInterval(final FloatingPointType<T> type, final T point) { if (type == null) throw new NullPointerException(); if (point == null) throw new NullPointerException(); if (type.isNaN(point)) throw new IllegalArgumentException(); _type = type; _lower = point; _upper = point; }
public Number size() { return _type.intervalSize(_lower, _upper); }
@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; }
public static <U extends Number & Comparable<U>> FloatingPointInterval<U> unconstrained(final FloatingPointType<U> type) { return new FloatingPointInterval<>(type, type.getNegativeInfinity(), type.getPositiveInfinity()); }
public boolean contains(final T n) { if (_type.isNaN(n)) return false; final int lcmp = getLower().compareTo(n); if (lcmp > 0) return false; if (lcmp == 0) return true; final int ucmp = getUpper().compareTo(n); return ucmp >= 0; }