Class CommonInterval
java.lang.Object
edu.udel.cis.vsl.sarl.number.real.CommonInterval
- All Implemented Interfaces:
Interval
Immutable implementation of
Interval.-
Constructor Summary
ConstructorsConstructorDescriptionCommonInterval(boolean isIntegral, Number lower, boolean strictLower, Number upper, boolean strictUpper) Construct a new instance ofCommonInterval, which is the general implementation ofInterval. -
Method Summary
Modifier and TypeMethodDescriptionclone()intDetermines when the given number lies to the left, inside, or to the right of this interval.booleanDoes 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.booleaninthashCode()booleanisEmpty()Is the interval empty? The empty interval should be (0, 0).booleanDoes this interval have integer type? If so, then both the upper and lower bounds will have integer type.booleanIs the interval an universal set?booleanisZero()Does the interval represent exactly the single number of 0?lower()The lower bound of this interval.booleanIs the lower bound strict, i.e., does the interval consist of all x strictly greater than the lower bound and ...?booleanIs the upper bound strict, i.e., does the interval consist of all x strictly less than the upper bound and ...?toString()upper()The upper bound of this interval.
-
Constructor Details
-
CommonInterval
public CommonInterval(boolean isIntegral, Number lower, boolean strictLower, Number upper, boolean strictUpper) Construct a new instance of
Preconditions:CommonInterval, which is the general implementation ofInterval.- 1. Both
upperandlowermust be non-null instance. - 2. If the
isIntegralistrue, then bothupperandlowermust be instances ofIntegerNumber; else they have to be instances ofRationalNumber. - 3. If
thisis a non-empty integer interval, the strict of it must befalsewhen the corresponding bound is finite. - 4. If
thisis an empty interval, which is represented as (0,0), then both its bounds should betrue; or ifthisinterval's bound is infinite, the corresponding strict must betrue - 5. The
lowerbound must be less than or equal to theupperbound. (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 andthisinterval is not empty, both strict must befalse; (3) if both bounds are zero and both stricts aretrue, thenthisinterval is an empty interval
- Parameters:
isIntegral- the type (int/real) ofthisinterval.lower- the lower bound ofthisinterval.strictLower- the lower strict ofthisinterval.upper- the upper bound ofthisinterval.strictUpper- the upper strict ofthisinterval.
- 1. Both
-
-
Method Details
-
clone
-
equals
-
hashCode
public int hashCode() -
toString
-
lower
Description copied from interface:IntervalThe lower bound of this interval. If unbounded (i.e., negative infinity) on the left, this method returns null. -
upper
Description copied from interface:IntervalThe upper bound of this interval. If unbounded (i.e., positive infinity) on the right, this method returns null. -
strictLower
public boolean strictLower()Description copied from interface:IntervalIs the lower bound strict, i.e., does the interval consist of all x strictly greater than the lower bound and ...?- Specified by:
strictLowerin interfaceInterval- Returns:
- true iff the lower bound is strict
-
strictUpper
public boolean strictUpper()Description copied from interface:IntervalIs the upper bound strict, i.e., does the interval consist of all x strictly less than the upper bound and ...?- Specified by:
strictUpperin interfaceInterval- Returns:
- true iff the upper bound is strict
-
isIntegral
public boolean isIntegral()Description copied from interface:IntervalDoes this interval have integer type? If so, then both the upper and lower bounds will have integer type.- Specified by:
isIntegralin interfaceInterval- Returns:
- true iff the type is integer
-
isEmpty
public boolean isEmpty()Description copied from interface:IntervalIs the interval empty? The empty interval should be (0, 0). -
isUniversal
public boolean isUniversal()Description copied from interface:IntervalIs the interval an universal set?- Specified by:
isUniversalin interfaceInterval- Returns:
-
contains
Description copied from interface:IntervalDoes 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. -
compare
Description copied from interface:IntervalDetermines when the given number lies to the left, inside, or to the right of this interval.- Specified by:
comparein interfaceInterval- 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:IntervalDoes the interval represent exactly the single number of 0?
-