public class Range extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private double |
lower |
private double |
upper |
static Range |
ZERO_TO_INFINITY
The full scale range from zero to infinity
|
Constructor and Description |
---|
Range(double lower,
double upper)
Constructs a new
Range . |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(double x)
Check if a number is contained in this range
|
static Range |
cut(Range a,
Range b)
provides the intersection of 2 overlapping ranges
|
boolean |
equals(java.lang.Object o) |
double |
getLower()
Gets the lower bound
|
double |
getUpper()
Gets the upper bound
|
int |
hashCode() |
Range |
reduceAround(double x,
Range other)
under the premise, that x is within this range,
and not within the other range, it shrinks this range in a way
to exclude the other range, but still contain x.
|
java.lang.String |
toString() |
private final double lower
private final double upper
public static final Range ZERO_TO_INFINITY
public Range(double lower, double upper)
Range
.lower
- Lower bound. Must be positive or zeroupper
- Upper boundjava.lang.IllegalArgumentException
- if the range is invalid (lower < 0 || lower >= upper
)public boolean contains(double x)
x
- The number to testtrue
if it is in this rangepublic static Range cut(Range a, Range b)
a
- first rangeb
- second rangea
and b
public Range reduceAround(double x, Range other)
x
- valueother
- other rangepublic double getLower()
public double getUpper()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object