Package edu.udel.cis.vsl.sarl.IF.number
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:
Definitions:
- if the the type of
thisis integral, then the upper and lower bounds must be instances ofIntegerNumber, else they must be instances ofRationalNumber - if the bound is exclusive/open/strict, the corresponding
strictLower(orstrictUpper) must betrue. - 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
strictLowerandstrictUpperwill befalse, or (2)strictLowerandstrictUpperwill betrueand 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
loweris infinite, it must be a negative infinity. And if the upper boundupperis infinite, it must be a positive infinity. - if
isIntegralistrue: if the lower bound is finite thenstrictLowermust befalse; if the upper bound is finite thenstrictUppermust befalse. - if the bound is
RealInfinity, then the corresponding strict must betrue.
-
Method Summary
Modifier and TypeMethodDescriptionintDetermines 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.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 ...?upper()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
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:
trueiff this interval contains that number
-
compare
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:
-