public class Interval
extends java.lang.Object
This class allows to perform simple interval operations like point inclusion tests and intersection operations.
There is no distinction between open and closed intervals because real numbers cannot be represented exactly.
IntervalsList| Constructor and Description |
|---|
Interval()
Build the [0, 0] interval.
|
Interval(double a,
double b)
Build an interval with the given bounds.
|
Interval(Interval i)
Copy-constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static Interval |
add(Interval i1,
Interval i2)
Add two intervals.
|
void |
addToSelf(Interval i)
Add an interval to the instance.
|
boolean |
contains(double x)
Check if the interval contains a point.
|
boolean |
contains(Interval i)
Check if the interval contains another interval.
|
double |
getInf()
Get the lower bound of the interval.
|
double |
getLength()
Get the length of the interval.
|
double |
getSup()
Get the upper bound of the interval.
|
static Interval |
intersection(Interval i1,
Interval i2)
Intersect two intervals.
|
boolean |
intersects(Interval i)
Check if an interval intersects the instance.
|
void |
intersectSelf(Interval i)
Intersects the instance with an interval.
|
public Interval()
public Interval(double a,
double b)
The given bounds do not need to be ordered, they will be reordered by the constructor.
a - first boundb - second boundpublic Interval(Interval i)
i - interval to copypublic double getInf()
public double getSup()
public double getLength()
public boolean contains(double x)
x - point to checkpublic boolean contains(Interval i)
i - interval to checkpublic boolean intersects(Interval i)
i - interval to checkpublic void addToSelf(Interval i)
This method expands the instance.
This operation is not a union operation. If
the instance and the interval are disjoints (i.e. if intersects(i) would return false), then
the hole between the intervals is filled in.
i - interval to add to the instancepublic static Interval add(Interval i1, Interval i2)
This operation is not a union operation. If
the intervals are disjoints (i.e. if i1.intersects(i2) would return false), then
the hole between the intervals is filled in.
i1 - first intervali2 - second intervalpublic void intersectSelf(Interval i)
This method reduces the instance, it could even become empty if the interval does not intersects the instance.
i - interval with which the instance should be intersectedCopyright © 2001-2007 Luc Maisonobe. All Rights Reserved.