public class DoubleInterval extends Interval<Double>
This class doesn't differentiate between -0.0 and 0.0 and treats them as the same value. In particular, the difference between these two Doubles is disregarded in the equals method.
If an intervals has a Double.NaN as a start or an end point, the interval is considered to be empty.
Interval.Bounded, Interval.Builder, Interval.UnboundedsweepLeftToRight, sweepRightToLeft| Constructor and Description |
|---|
DoubleInterval()
Instantiates an interval extending from positive infinity to negative
infinity and thus containing all Doubles.
|
DoubleInterval(Double start,
Double end,
Interval.Bounded type)
Instantiates a new bounded interval.
|
DoubleInterval(Double value,
Interval.Unbounded type)
Instantiates a new unbounded interval - an interval that extends to positive or
negative infinity.
|
| Modifier and Type | Method and Description |
|---|---|
protected Interval<Double> |
create()
Used to create new instances of a specific
Interval subclass. |
Double |
getMidpoint()
Determines the center of the interval.
|
boolean |
isEmpty()
Determines if the interval is empty, meaning it contains no Doubles.
|
builder, compareSpecialization, contains, contains, create, equals, getEnd, getIntersection, getStart, hashCode, intersects, isEndInclusive, isLeftOf, isLeftOf, isLeftOf, isPoint, isRightOf, isRightOf, isRightOf, isStartInclusivepublic DoubleInterval()
public DoubleInterval(Double start, Double end, Interval.Bounded type)
start - The start point of the intervalend - The end point of the interval.type - Description of whether the interval is open/closed at one or both
of its ends. See the documentation of the Bounded enum
for more information on the different possibilities.public DoubleInterval(Double value, Interval.Unbounded type)
value - The bounding value for either the start or the end point.type - Describes whether the interval extends to positive or negative infinity,
as well as if it is open or closed at the bounding point. See the Unbounded enum for description of the different possibilities.protected Interval<Double> create()
IntervalInterval subclass.
The Interval class aims to avoid reflexion. On several occasions, however, the class
needs to create new instances of the Interval class. To be able to guarantee that they
will have the desired runtime type, the Interval.create() method of a specific reference object
is called.
Generally, the only thing you need to do in your implementation of this abstract method is to call the default constructor of your subclass and return the new interval.
public boolean isEmpty()
IntegerInterval, the interval (4.0, 5.0), for example, will not
be considered empty, because there are Double values in this interval.
If the start or end point of the interval is Double.NaN, the interval will be considered empty.
public Double getMidpoint()
This is done in a best-effort basis, because in unbounded intervals the center doesn't exist.
This is different from the class IntegerInterval, where even unbounded intervals
are bounded by Integer.MAX_VALUE and/or Integer.MIN_VALUE. In case the DoubleInterval is
unbounded, the method returns an arbitrary Double, which is within the interval, but makes
no guarantees as to what value it will have exactly. This ensures that unbounded intervals
will still work properly with TreeNodes. The current implementation returns a value,
which is at a particular OFFSET to the bounded point of the interval. However, this
behaviour may change in the future, so don't rely on it.
getMidpoint in class Interval<Double>Copyright © 2016. All rights reserved.