@Override public String toString() { return format("%s%s,%s%s", inclusiveLower() ? "[" : "(", boundLower() ? getLower() : "-Inf", boundUpper() ? getUpper() : "+Inf", inclusiveUpper() ? "]" : ")"); }
@Override public String toString() { return format("%s%s,%s%s", inclusiveLower() ? "[" : "(", boundLower() ? getLower() : "-Inf", boundUpper() ? getUpper() : "+Inf", inclusiveUpper() ? "]" : ")"); }
/** * 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 ContinuousRealInterval less(final Number n) { if (boundUpper() && OWLRealUtils.compare(n, getUpper()) > 0) return this; else if (boundLower() && OWLRealUtils.compare(n, getLower()) <= 0) return null; return new ContinuousRealInterval(getLower(), n, inclusiveLower(), false); }
@Deprecated @Override public int size() { if (!_finite) throw new IllegalStateException(); Number sum = 0; for (final IntegerInterval i : _intIntervals) { sum = OWLRealUtils.integerSum(sum, i.size()); if (OWLRealUtils.compare(Integer.MAX_VALUE, sum) <= 0) return Integer.MAX_VALUE; } for (final ContinuousRealInterval i : _decimalIntervals) if (!OWLRealUtils.isInteger(i.getLower())) { sum = OWLRealUtils.integerIncrement(sum); if (OWLRealUtils.compare(Integer.MAX_VALUE, sum) <= 0) return Integer.MAX_VALUE; } for (final ContinuousRealInterval i : _rationalIntervals) if (!OWLRealUtils.isInteger(i.getLower()) && !OWLRealUtils.isRational(i.getLower())) { sum = OWLRealUtils.integerIncrement(sum); if (OWLRealUtils.compare(Integer.MAX_VALUE, sum) <= 0) return Integer.MAX_VALUE; } return sum.intValue(); }
public List<ContinuousRealInterval> union(final ContinuousRealInterval other) { switch (compare(other)) { case CONTAINS: case EQUALS: case FINISHED_BY: case STARTED_BY: return Collections.singletonList(this); case DURING: case FINISHES: case STARTS: return Collections.singletonList(other); case MEETS: return Collections.singletonList(new ContinuousRealInterval(getLower(), other.getUpper(), inclusiveLower(), other.inclusiveUpper())); case MET_BY: return Collections.singletonList(new ContinuousRealInterval(other.getLower(), getUpper(), other.inclusiveLower(), inclusiveUpper())); case OVERLAPPED_BY: return Collections.singletonList(new ContinuousRealInterval(other.getLower(), getUpper(), other.inclusiveLower(), inclusiveUpper())); case OVERLAPS: return Collections.singletonList(new ContinuousRealInterval(getLower(), other.getUpper(), inclusiveLower(), other.inclusiveUpper())); case PRECEDED_BY: case PRECEDES: return Arrays.asList(this, other); default: throw new IllegalStateException(); } }
/** * 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 ContinuousRealInterval less(final Number n) { if (boundUpper() && OWLRealUtils.compare(n, getUpper()) > 0) return this; else if (boundLower() && OWLRealUtils.compare(n, getLower()) <= 0) return null; return new ContinuousRealInterval(getLower(), n, inclusiveLower(), false); }
private static int compareUpperLower(final ContinuousRealInterval a, final ContinuousRealInterval b) { int ul; if (!a.boundUpper()) ul = 1; else if (!b.boundLower()) ul = 1; else ul = OWLRealUtils.compare(a.getUpper(), b.getLower()); return ul; }
private static int compareUpperLower(final ContinuousRealInterval a, final ContinuousRealInterval b) { int ul; if (!a.boundUpper()) ul = 1; else if (!b.boundLower()) ul = 1; else ul = OWLRealUtils.compare(a.getUpper(), b.getLower()); return ul; }
@Deprecated @Override public int size() { if (!_finite) throw new IllegalStateException(); Number sum = 0; for (final IntegerInterval i : _intIntervals) { sum = OWLRealUtils.integerSum(sum, i.size()); if (OWLRealUtils.compare(Integer.MAX_VALUE, sum) <= 0) return Integer.MAX_VALUE; } for (final ContinuousRealInterval i : _decimalIntervals) if (!OWLRealUtils.isInteger(i.getLower())) { sum = OWLRealUtils.integerIncrement(sum); if (OWLRealUtils.compare(Integer.MAX_VALUE, sum) <= 0) return Integer.MAX_VALUE; } for (final ContinuousRealInterval i : _rationalIntervals) if (!OWLRealUtils.isInteger(i.getLower()) && !OWLRealUtils.isRational(i.getLower())) { sum = OWLRealUtils.integerIncrement(sum); if (OWLRealUtils.compare(Integer.MAX_VALUE, sum) <= 0) return Integer.MAX_VALUE; } return sum.intValue(); }
public List<ContinuousRealInterval> union(final ContinuousRealInterval other) { switch (compare(other)) { case CONTAINS: case EQUALS: case FINISHED_BY: case STARTED_BY: return Collections.singletonList(this); case DURING: case FINISHES: case STARTS: return Collections.singletonList(other); case MEETS: return Collections.singletonList(new ContinuousRealInterval(getLower(), other.getUpper(), inclusiveLower(), other.inclusiveUpper())); case MET_BY: return Collections.singletonList(new ContinuousRealInterval(other.getLower(), getUpper(), other.inclusiveLower(), inclusiveUpper())); case OVERLAPPED_BY: return Collections.singletonList(new ContinuousRealInterval(other.getLower(), getUpper(), other.inclusiveLower(), inclusiveUpper())); case OVERLAPS: return Collections.singletonList(new ContinuousRealInterval(getLower(), other.getUpper(), inclusiveLower(), other.inclusiveUpper())); case PRECEDED_BY: case PRECEDES: return Arrays.asList(this, other); default: throw new IllegalStateException(); } }
@Override public boolean containsAtLeast(final int n) { if (!_finite || n <= 0) return true; Number sum = 0; for (final IntegerInterval i : _intIntervals) { sum = OWLRealUtils.integerSum(sum, i.size()); if (OWLRealUtils.compare(n, sum) <= 0) return true; } for (final ContinuousRealInterval i : _decimalIntervals) if (!OWLRealUtils.isInteger(i.getLower())) { sum = OWLRealUtils.integerIncrement(sum); if (OWLRealUtils.compare(n, sum) <= 0) return true; } for (final ContinuousRealInterval i : _rationalIntervals) if (!OWLRealUtils.isInteger(i.getLower()) && !OWLRealUtils.isRational(i.getLower())) { sum = OWLRealUtils.integerIncrement(sum); if (OWLRealUtils.compare(n, sum) <= 0) return true; } return false; }
@Override public boolean containsAtLeast(final int n) { if (!_finite || n <= 0) return true; Number sum = 0; for (final IntegerInterval i : _intIntervals) { sum = OWLRealUtils.integerSum(sum, i.size()); if (OWLRealUtils.compare(n, sum) <= 0) return true; } for (final ContinuousRealInterval i : _decimalIntervals) if (!OWLRealUtils.isInteger(i.getLower())) { sum = OWLRealUtils.integerIncrement(sum); if (OWLRealUtils.compare(n, sum) <= 0) return true; } for (final ContinuousRealInterval i : _rationalIntervals) if (!OWLRealUtils.isInteger(i.getLower()) && !OWLRealUtils.isRational(i.getLower())) { sum = OWLRealUtils.integerIncrement(sum); if (OWLRealUtils.compare(n, sum) <= 0) return true; } return false; }
private static int compareLowerLower(final ContinuousRealInterval a, final ContinuousRealInterval other) { int ll; if (!a.boundLower()) { if (!other.boundLower()) ll = 0; else ll = -1; } else if (!other.boundLower()) ll = 1; else { ll = OWLRealUtils.compare(a.getLower(), other.getLower()); if (ll == 0) if (a.inclusiveLower()) { if (!other.inclusiveLower()) ll = -1; } else if (other.inclusiveLower()) ll = 1; } return ll; }
private static int compareLowerLower(final ContinuousRealInterval a, final ContinuousRealInterval other) { int ll; if (!a.boundLower()) { if (!other.boundLower()) ll = 0; else ll = -1; } else if (!other.boundLower()) ll = 1; else { ll = OWLRealUtils.compare(a.getLower(), other.getLower()); if (ll == 0) if (a.inclusiveLower()) { if (!other.inclusiveLower()) ll = -1; } else if (other.inclusiveLower()) ll = 1; } return ll; }
public boolean contains(final Number n) { int comp; if (boundLower()) { comp = OWLRealUtils.compare(getLower(), n); if (comp > 0) return false; if (comp == 0 && !inclusiveLower()) return false; } if (boundUpper()) { comp = OWLRealUtils.compare(getUpper(), n); if (comp < 0) return false; if (comp == 0 && !inclusiveUpper()) return false; } return true; }
public boolean contains(final Number n) { int comp; if (boundLower()) { comp = OWLRealUtils.compare(getLower(), n); if (comp > 0) return false; if (comp == 0 && !inclusiveLower()) return false; } if (boundUpper()) { comp = OWLRealUtils.compare(getUpper(), n); if (comp < 0) return false; if (comp == 0 && !inclusiveUpper()) return false; } return true; }
/** * 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 ContinuousRealInterval greater(final Number n) { if (boundLower() && OWLRealUtils.compare(n, getLower()) < 0) return this; else if (boundUpper() && OWLRealUtils.compare(n, getUpper()) >= 0) return null; return new ContinuousRealInterval(n, getUpper(), false, inclusiveUpper()); }
/** * 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 ContinuousRealInterval greater(final Number n) { if (boundLower() && OWLRealUtils.compare(n, getLower()) < 0) return this; else if (boundUpper() && OWLRealUtils.compare(n, getUpper()) >= 0) return null; return new ContinuousRealInterval(n, getUpper(), false, inclusiveUpper()); }
private static ContinuousRealInterval zoneShrink(final ContinuousRealInterval i) { final Number lower = i.boundLower() ? OWLRealUtils.sum(i.getLower(), TZ_SHIFT) : null; final Number upper = i.boundUpper() ? OWLRealUtils.sum(i.getUpper(), -TZ_SHIFT) : null; if (lower != null && upper != null) { final int cmp = OWLRealUtils.compare(lower, upper); if (cmp > 0) return null; else if (cmp == 0) if (!i.inclusiveLower() && !i.inclusiveUpper()) return null; else return new ContinuousRealInterval(lower); } return new ContinuousRealInterval(lower, upper, i.inclusiveLower(), i.inclusiveUpper()); }
private static ContinuousRealInterval zoneShrink(final ContinuousRealInterval i) { final Number lower = i.boundLower() ? OWLRealUtils.sum(i.getLower(), TZ_SHIFT) : null; final Number upper = i.boundUpper() ? OWLRealUtils.sum(i.getUpper(), -TZ_SHIFT) : null; if (lower != null && upper != null) { final int cmp = OWLRealUtils.compare(lower, upper); if (cmp > 0) return null; else if (cmp == 0) if (!i.inclusiveLower() && !i.inclusiveUpper()) return null; else return new ContinuousRealInterval(lower); } return new ContinuousRealInterval(lower, upper, i.inclusiveLower(), i.inclusiveUpper()); }