D - Interval domain.public final class Interval<D extends Comparable<D>> extends Object implements Serializable
a and b be real numbers where with a < b:
(a, a) = (a, a] = [a, a) = {} = empty.
[b, a] is considered as an empty interval in the literature, but
this class do not support it
[a, a] = {a}
(a, b) = {x | a < x < b}
[a, b] = {x | a <= x <= b}
[a, b) = {x | a <= x < b}
(a, b] = {x | a < x <= b}
(a, infinite) = {x | x > a}
[a, infinite) = {x | x >= a}
(infinite, b) = {x | x < b}
(infinite, b] = {x | x <= b}
(infinite, infinite) = {x | x is a real number}
| Modifier and Type | Class and Description |
|---|---|
static class |
Interval.Type |
| Modifier | Constructor and Description |
|---|---|
protected |
Interval(D leftEndpoint,
D rightEndpoint,
Interval.Type type)
Constructs an interval.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(D element)
Verifies whether the given element belongs to the interval.
|
static <T extends Comparable<T>> |
createClosed(T leftEndpoint,
T rightEndpoint)
Creates a closed-type interval based on the nullability of
leftEndpoint and
rightEndpoint:
Closed: if neither leftEndpoint and rightEndpoint are null
Left unbounded right closed: if leftEndpoint is null but
rightEndpoint isn't
Left closed right unbounded: if leftEndpoint is not null but
rightEndpoint is
Unbounded: if both leftEndpoint and rightEndpoint are null
|
static <T extends Comparable<T>> |
createOpen(T leftEndpoint,
T rightEndpoint)
Creates an open-type interval based on the nullability of
leftEndpoint and
rightEndpoint:
Open: if neither leftEndpoint and rightEndpoint are null
Left unbounded right open: if leftEndpoint is null but
rightEndpoint isn't
Left open right unbounded: if leftEndpoint is not null but
rightEndpoint is
Unbounded: if both leftEndpoint and rightEndpoint are null
|
boolean |
equals(Object obj) |
D |
getLeftEndpoint()
Gets the interval left end point.
|
D |
getRightEndpoint()
Gets the interval right end point.
|
Interval.Type |
getType()
Gets the interval type.
|
int |
hashCode() |
boolean |
isEmpty()
Returns whether this interval is empty or not:
|
String |
toString() |
static <T extends Comparable<T>> |
valueOfClosed(T leftEndpoint,
T rightEndpoint)
Creates a closed interval:
[a, b] = {x | a <= x <= b} |
static <T extends Comparable<T>> |
valueOfLeftClosedRightOpen(T leftEndpoint,
T rightEndpoint)
Creates a left-closed right-open interval:
(a, b] = {x | a < x <= b} |
static <T extends Comparable<T>> |
valueOfLeftClosedRightUnbounded(T leftEndpoint)
Creates a Left closed right unbounded interval:
[a, infinite) = {x | x >= a} |
static <T extends Comparable<T>> |
valueOfLeftOpenRightClosed(T leftEndpoint,
T rightEndpoint)
Creates a left-open right-closed interval:
(a, b] = {x | a <= x < b} |
static <T extends Comparable<T>> |
valueOfLeftOpenRightUnbounded(T leftEndpoint)
Creates a left open right unbounded interval:
(a, infinite) = {x | x > a} |
static <T extends Comparable<T>> |
valueOfLeftUnboundedRightClosed(T rightEndpoint)
Creates a left unbounded right closed interval:
(infinite, b] = {x | x <= b} |
static <T extends Comparable<T>> |
valueOfLeftUnboundedRightOpen(T rightEndpoint)
Creates a left unbounded right open interval:
(infinite, b) = {x | x < b} |
static <T extends Comparable<T>> |
valueOfOpen(T leftEndpoint,
T rightEndpoint)
Creates a open interval:
(a, b) = {x | a < x < b} |
static <T extends Comparable<T>> |
valueOfUnbounded()
Creates an unbounded interval:
(infinite, infinite) = {x | x is a real number} |
protected Interval(D leftEndpoint, D rightEndpoint, Interval.Type type) throws NullPointerException, IllegalArgumentException
leftEndpoint - Left end point.rightEndpoint - Right end point.type - Interval type.NullPointerException - If interval type is null.IllegalArgumentException - If interval validation fails based on
the interval type.public static <T extends Comparable<T>> Interval<T> valueOfOpen(T leftEndpoint, T rightEndpoint)
(a, b) = {x | a < x < b}leftEndpoint - Left end point.rightEndpoint - Right end point.public static <T extends Comparable<T>> Interval<T> valueOfClosed(T leftEndpoint, T rightEndpoint)
[a, b] = {x | a <= x <= b}leftEndpoint - Left end point.rightEndpoint - Right end point.public static <T extends Comparable<T>> Interval<T> valueOfLeftClosedRightOpen(T leftEndpoint, T rightEndpoint)
(a, b] = {x | a < x <= b}leftEndpoint - Left end point.rightEndpoint - Right end point.public static <T extends Comparable<T>> Interval<T> valueOfLeftOpenRightClosed(T leftEndpoint, T rightEndpoint)
(a, b] = {x | a <= x < b}leftEndpoint - Left end point.rightEndpoint - Right end point.public static <T extends Comparable<T>> Interval<T> valueOfLeftOpenRightUnbounded(T leftEndpoint)
(a, infinite) = {x | x > a}leftEndpoint - Left end point.public static <T extends Comparable<T>> Interval<T> valueOfLeftClosedRightUnbounded(T leftEndpoint)
[a, infinite) = {x | x >= a}leftEndpoint - Left end point.public static <T extends Comparable<T>> Interval<T> valueOfLeftUnboundedRightOpen(T rightEndpoint)
(infinite, b) = {x | x < b}rightEndpoint - Right end point.public static <T extends Comparable<T>> Interval<T> valueOfLeftUnboundedRightClosed(T rightEndpoint)
(infinite, b] = {x | x <= b}rightEndpoint - Right end point.public static <T extends Comparable<T>> Interval<T> valueOfUnbounded()
(infinite, infinite) = {x | x is a real number}public static <T extends Comparable<T>> Interval<T> createOpen(T leftEndpoint, T rightEndpoint) throws IllegalArgumentException
leftEndpoint and
rightEndpoint:
leftEndpoint and rightEndpoint are nullleftEndpoint is null but
rightEndpoint isn'tleftEndpoint is not null but
rightEndpoint isleftEndpoint and rightEndpoint are nullleftEndpoint - left endpointrightEndpoint - right endpointIllegalArgumentException - if neither leftEndpoint and rightEndpoint
are null and leftEndpoint is be greater than
rightEndpointpublic static <T extends Comparable<T>> Interval<T> createClosed(T leftEndpoint, T rightEndpoint) throws IllegalArgumentException
leftEndpoint and
rightEndpoint:
leftEndpoint and rightEndpoint are nullleftEndpoint is null but
rightEndpoint isn'tleftEndpoint is not null but
rightEndpoint isleftEndpoint and rightEndpoint are nullleftEndpoint - left endpointrightEndpoint - right endpointIllegalArgumentException - if neither leftEndpoint and rightEndpoint
are null and leftEndpoint is be greater than
rightEndpointpublic D getLeftEndpoint()
public D getRightEndpoint()
public Interval.Type getType()
public boolean contains(D element)
element - Element to verify.true if element belongs is inside the interval,
false otherwise.public boolean isEmpty()
a, b are real numbers with a < b
empty: [b, a] = (a, a) = [a, a) = (a, a] = {}
Copyright © 2014. All Rights Reserved.