/** * 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; }
/** * 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 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; }
/** * Create an interval. * * @param type * @param lower Interval _lower bound * @param upper Interval _upper bound */ public FloatingPointInterval(final FloatingPointType<T> type, final T lower, final T upper) { if (type == null) throw new NullPointerException(); if (lower == null) throw new NullPointerException(); if (upper == null) throw new NullPointerException(); if (type.isNaN(lower)) throw new IllegalArgumentException(); if (type.isNaN(upper)) throw new IllegalArgumentException(); final int cmp = lower.compareTo(upper); if (cmp > 0) { final String msg = format("Lower bound of interval (%s) should not be greater than _upper bound of interval (%s)", lower, upper); _logger.severe(msg); throw new IllegalArgumentException(msg); } _type = type; _lower = lower; _upper = upper; }
/** * Create an interval. * * @param type * @param lower Interval _lower bound * @param upper Interval _upper bound */ public FloatingPointInterval(final FloatingPointType<T> type, final T lower, final T upper) { if (type == null) throw new NullPointerException(); if (lower == null) throw new NullPointerException(); if (upper == null) throw new NullPointerException(); if (type.isNaN(lower)) throw new IllegalArgumentException(); if (type.isNaN(upper)) throw new IllegalArgumentException(); final int cmp = lower.compareTo(upper); if (cmp > 0) { final String msg = format("Lower bound of interval (%s) should not be greater than _upper bound of interval (%s)", lower, upper); _logger.severe(msg); throw new IllegalArgumentException(msg); } _type = type; _lower = lower; _upper = upper; }
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; }
/** * 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)); }
@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; }
@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 (_type.isNaN(n)) return _empty;
if (_type.isNaN(n)) return _empty;