Class CommonInterval

java.lang.Object
edu.udel.cis.vsl.sarl.number.real.CommonInterval
All Implemented Interfaces:
Interval

public class CommonInterval extends Object implements Interval
Immutable implementation of Interval.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CommonInterval(boolean isIntegral, Number lower, boolean strictLower, Number upper, boolean strictUpper)
    Construct a new instance of CommonInterval, which is the general implementation of Interval.
  • 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
    equals(Object object)
     
    int
     
    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.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CommonInterval

      public CommonInterval(boolean isIntegral, Number lower, boolean strictLower, Number upper, boolean strictUpper)

      Construct a new instance of CommonInterval, which is the general implementation of Interval.

      Preconditions:
      • 1. Both upper and lower must be non-null instance.
      • 2. If the isIntegral is true, then both upper and lower must be instances of IntegerNumber; else they have to be instances of RationalNumber.
      • 3. If this is a non-empty integer interval, the strict of it must be false when the corresponding bound is finite.
      • 4. If this is an empty interval, which is represented as (0,0), then both its bounds should be true; or if this interval's bound is infinite, the corresponding strict must be true
      • 5. The lower bound must be less than or equal to the upper bound. (1) Thus, if the lower bound is infinite, it must be the negative infinity, and if the upper bound is infinite, it must be the positive infinity; (2) if both bounds are the same number and this interval is not empty, both strict must be false; (3) if both bounds are zero and both stricts are true, then this interval is an empty interval
      Parameters:
      isIntegral - the type (int/real) of this interval.
      lower - the lower bound of this interval.
      strictLower - the lower strict of this interval.
      upper - the upper bound of this interval.
      strictUpper - the upper strict of this interval.
  • Method Details

    • clone

      public CommonInterval clone()
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • lower

      public Number lower()
      Description copied from interface: Interval
      The lower bound of this interval. If unbounded (i.e., negative infinity) on the left, this method returns null.
      Specified by:
      lower in interface Interval
      Returns:
      the lower bound or RealInfinity
    • upper

      public Number upper()
      Description copied from interface: Interval
      The upper bound of this interval. If unbounded (i.e., positive infinity) on the right, this method returns null.
      Specified by:
      upper in interface Interval
      Returns:
      the upper bound or RealInfinity
    • strictLower

      public boolean strictLower()
      Description copied from interface: Interval
      Is the lower bound strict, i.e., does the interval consist of all x strictly greater than the lower bound and ...?
      Specified by:
      strictLower in interface Interval
      Returns:
      true iff the lower bound is strict
    • strictUpper

      public boolean strictUpper()
      Description copied from interface: Interval
      Is the upper bound strict, i.e., does the interval consist of all x strictly less than the upper bound and ...?
      Specified by:
      strictUpper in interface Interval
      Returns:
      true iff the upper bound is strict
    • isIntegral

      public boolean isIntegral()
      Description copied from interface: Interval
      Does this interval have integer type? If so, then both the upper and lower bounds will have integer type.
      Specified by:
      isIntegral in interface Interval
      Returns:
      true iff the type is integer
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Interval
      Is the interval empty? The empty interval should be (0, 0).
      Specified by:
      isEmpty in interface Interval
      Returns:
    • isUniversal

      public boolean isUniversal()
      Description copied from interface: Interval
      Is the interval an universal set?
      Specified by:
      isUniversal in interface Interval
      Returns:
    • contains

      public boolean contains(Number number)
      Description copied from interface: Interval
      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.
      Specified by:
      contains in interface Interval
      Parameters:
      number - a number of the same type as this interval
      Returns:
      true iff this interval contains that number
    • compare

      public int compare(Number number)
      Description copied from interface: Interval
      Determines when the given number lies to the left, inside, or to the right of this interval.
      Specified by:
      compare in interface 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
    • isZero

      public boolean isZero()
      Description copied from interface: Interval
      Does the interval represent exactly the single number of 0?
      Specified by:
      isZero in interface Interval
      Returns: