Interface Interval

All Known Implementing Classes:
CommonInterval

public interface Interval
An instance of Interval represents a numeric interval. It can have either real or integer type. It can be open or closed on the left, open or closed on right. It can be unbounded on either side.
Definitions:
  • if the the type of this is integral, then the upper and lower bounds must be instances of IntegerNumber, else they must be instances of RationalNumber
  • if the bound is exclusive/open/strict, the corresponding strictLower (or strictUpper) must be true.
  • the lower bound must be less than or equal to the upper bound (Otherwise, this method will return an empty interval.)
  • if the bounds are finite and equal: either (1) both strictLower and strictUpper will be false, or (2) strictLower and strictUpper will be true and the upper and lower bounds will be 0. The first case represents an interval consisting of a single point; the second case represents the empty interval.
  • if the lower bound lower is infinite, it must be a negative infinity. And if the upper bound upper is infinite, it must be a positive infinity.
  • if isIntegral is true: if the lower bound is finite then strictLower must be false; if the upper bound is finite then strictUpper must be false.
  • if the bound is RealInfinity, then the corresponding strict must be true.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compare(Number number)
    Determines when the given number lies to the left, inside, or to the right of this interval.
    boolean
    contains(Number number)
    Does this interval contain the given number? The behavior is unspecified if this method is given a number which has a different type from that of this interval.
    boolean
    Is the interval empty? The empty interval should be (0, 0).
    boolean
    Does this interval have integer type? If so, then both the upper and lower bounds will have integer type.
    boolean
    Is the interval an universal set?
    boolean
    Does the interval represent exactly the single number of 0?
    The lower bound of this interval.
    boolean
    Is the lower bound strict, i.e., does the interval consist of all x strictly greater than the lower bound and ...?
    boolean
    Is the upper bound strict, i.e., does the interval consist of all x strictly less than the upper bound and ...?
    The upper bound of this interval.
  • Method Details

    • isIntegral

      boolean isIntegral()
      Does this interval have integer type? If so, then both the upper and lower bounds will have integer type.
      Returns:
      true iff the type is integer
    • lower

      Number lower()
      The lower bound of this interval. If unbounded (i.e., negative infinity) on the left, this method returns null.
      Returns:
      the lower bound or RealInfinity
    • upper

      Number upper()
      The upper bound of this interval. If unbounded (i.e., positive infinity) on the right, this method returns null.
      Returns:
      the upper bound or RealInfinity
    • strictLower

      boolean strictLower()
      Is the lower bound strict, i.e., does the interval consist of all x strictly greater than the lower bound and ...?
      Returns:
      true iff the lower bound is strict
    • strictUpper

      boolean strictUpper()
      Is the upper bound strict, i.e., does the interval consist of all x strictly less than the upper bound and ...?
      Returns:
      true iff the upper bound is strict
    • isEmpty

      boolean isEmpty()
      Is the interval empty? The empty interval should be (0, 0).
      Returns:
    • isZero

      boolean isZero()
      Does the interval represent exactly the single number of 0?
      Returns:
    • contains

      boolean contains(Number number)
      Does this interval contain the given number? The behavior is unspecified if this method is given a number which has a different type from that of this interval. I.e., integer intervals should only be given integers; real intervals should only be given reals.
      Parameters:
      number - a number of the same type as this interval
      Returns:
      true iff this interval contains that number
    • compare

      int compare(Number number)
      Determines when the given number lies to the left, inside, or to the right of this interval.
      Parameters:
      number - a number of the same type as this interval
      Returns:
      a negative integer if the number is greater than the entire interval, 0 if the number is contained in the interval, or a positive integer if the number is less than the entire interval
    • isUniversal

      boolean isUniversal()
      Is the interval an universal set?
      Returns: