Interval.Bounded, Interval.Builder, Interval.UnboundedsweepLeftToRight, sweepRightToLeft| Constructor and Description |
|---|
IntegerInterval()
Instantiates an interval extending from positive infinity to negative
infinity and thus containing all Integers.
|
IntegerInterval(Integer start,
Integer end,
Interval.Bounded type)
Instantiates a new bounded interval.
|
IntegerInterval(Integer 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 IntegerInterval |
create()
Used to create new instances of a specific
Interval subclass. |
Integer |
getMidpoint()
Determines the center of the interval.
|
boolean |
isEmpty()
Determines if the interval is empty, meaning it contains no Integers.
|
builder, compareSpecialization, contains, contains, create, equals, getEnd, getIntersection, getStart, hashCode, intersects, isEndInclusive, isLeftOf, isLeftOf, isLeftOf, isPoint, isRightOf, isRightOf, isRightOf, isStartInclusivepublic IntegerInterval()
public IntegerInterval(Integer start, Integer 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 IntegerInterval(Integer 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 IntegerInterval 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 Integer getMidpoint()
For the purposes of this method, if the interval is defined unbounded, it is assumed to be bounded by Integer.MIN_VALUE, if it extends to negative infinity, and/or Integer.MAX_VALUE, if it extends to positive infinity.
getMidpoint in class Interval<Integer>public boolean isEmpty()
true for the open interval
(4, 5), since there is no Integer within this interval, even though the
start and end points are different.Copyright © 2016. All rights reserved.