|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mhhe.clrs2e.Interval
Implements an interval whose endpoints are real numbers.
Field Summary | |
protected double |
high
High endpoint of the interval. |
protected double |
low
Low endpoint of the interval. |
Constructor Summary | |
Interval(double low,
double high)
Initializes the endpoints of the interval. |
Method Summary | |
int |
compareTo(java.lang.Object o)
Compares this interval to another, based on their low endpoints. |
double |
getHigh()
Returns the high endpoint of the interval. |
double |
getLow()
Returns the low endpoint of the interval. |
boolean |
overlaps(com.mhhe.clrs2e.Interval i)
Returns whether this interval overlaps another interval. |
java.lang.String |
toString()
Returns the String representation of this interval in
the form [low, high]. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected final double low
protected final double high
Constructor Detail |
public Interval(double low, double high)
low
- The low endpoint.high
- The high endpoint.Method Detail |
public double getLow()
public double getHigh()
public boolean overlaps(com.mhhe.clrs2e.Interval i)
i
- The other interval.
true
if this interval overlaps
i
, false
otherwise.public java.lang.String toString()
String
representation of this interval in
the form [low, high].
toString
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
- The other Interval
object.
Interval
is
less; 0 if the objects are equal; a positive integer if this
Interval
is greater.
java.lang.ClassCastException
- if o
is not an
Interval
object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |