T - public class Range<T extends Number & Comparable> extends Object
RangeLookup operator but
is also available for general use and does not depend on JAI classes.
Range is a generic class that can be used all Number types. A range
is defined by its endpoints. If the min (lower bound) end-point is the same as the
max (upper-bound) end-point then the range represents a point, also referred to as
a degenerate interval.
An end-point can be positioned at a finite value, in which case it is said to be closed, or at positive or negative infinity, in which case it is said to be open. For finite end-points, a range can include or exclude the end-point. Included end-points correspond to square-brackets in interval notation, while excluded end-points correspond to round brackets.
The following rules apply to Float and Double NaN values...
RangeComparator,
org.jaitools.media.jai.rangelookup.RangeLookupDescriptor| Modifier and Type | Class and Description |
|---|---|
static class |
Range.Type
Constants to specify whether a
Range parameter defines
included or excluded values. |
| Modifier and Type | Field and Description |
|---|---|
static int |
INF
Integer flag value for positive infinity.
|
static int |
NEG_INF
Integer flag value for negative infinity.
|
| Constructor and Description |
|---|
Range(Range<T> other)
Creates a copy of another Range instance.
|
Range(T minValue,
boolean minIncluded,
T maxValue,
boolean maxIncluded)
Creates a new Range with non-zero width (may be infinite).
|
Range(T value,
int... inf)
Creates a new point (degenerate) range.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(T value)
Tests if this range contains the specified, non-null value.
|
static <T extends Number & Comparable> |
create(T minValue,
boolean minIncluded,
T maxValue,
boolean maxIncluded)
Static create method.
|
static <T extends Number & Comparable> |
create(T value,
int... inf)
Creates a Range instance that is a point (degenerate) interval.
|
boolean |
equals(Object obj)
Tests for equality with another range.
|
T |
getMax()
Gets the maximum value of this range.
|
T |
getMin()
Gets the minimum value for this range.
|
int |
hashCode() |
boolean |
intersects(Range<T> other)
Tests if this range intersects another range.
|
boolean |
isMaxClosed()
Tests if this range has a bounded (closed) maximum value.
|
boolean |
isMaxIncluded()
Tests if the maximum range value is included in the range.
|
boolean |
isMaxInf()
Tests if the maximum value is positive infinity.
|
boolean |
isMaxNegInf()
Tests if the maximum value is negative infinity.
|
boolean |
isMaxOpen()
Tests if this range has unbounded (open) upper end, ie the
range extends to positive infinity.
|
boolean |
isMinClosed()
Tests if this range has a bounded (closed) minimum.
|
boolean |
isMinIncluded()
Tests if the minimum value is included in the range.
|
boolean |
isMinInf()
Tests if the minimum value is positive infinity.
|
boolean |
isMinNegInf()
Tests if the minimum value is negative infinity.
|
boolean |
isMinOpen()
Tests if this range has an unbounded (open) minimum, ie.
|
boolean |
isPoint()
Checks if this range is a point (degenerate) interval
|
String |
toString()
Returns a string representation of this range.
|
public static final int NEG_INF
public static final int INF
public Range(T minValue, boolean minIncluded, T maxValue, boolean maxIncluded)
minValue - the lower bound; passing null for this parameter
means an open lower bound; for Float or Double types, the
relevant NEGATIVE_INFINITY value can also be used.minIncluded - true if the lower bound is to be included in the
range; false to exclude the lower bound; overridden to be false if the
lower bound is openmaxValue - the upper bound; passing null for this parameter
means an open upper bound; for Float or Double types, the
relevant NEGATIVE_INFINITY value can also be used.maxIncluded - true if the upper bound is to be included in the
range; false to exclude the upper bound; overridden to be false if the
upper bound is openpublic Range(T value, int... inf)
Where value is finite the following apply:
Range<Integer> rInf = new Range<Integer>(null, Range.INF);
Range<Integer> rNegInf = new Range<Integer>(null, Range.NEG_INF);
// or with the static create method...
Range<Integer> rInf2 = Range.create(null, Range.INF);
For a point interval at positive or negative infinity the following apply:
value - the value to set for both min and max end-pointsinf - either Range.INF or Range.NEG_INF (ignored if present when value is non-null)public static <T extends Number & Comparable> Range<T> create(T minValue, boolean minIncluded, T maxValue, boolean maxIncluded)
Range<Integer> r = new Range<Integer>(10, false, 20, true);
you can do this...
Range<Integer> r = Range.create(10, false, 20, true);
T - value typeminValue - the lower bound; passing null for this parameter
means an open lower bound; for Float or Double types, the
relevant NEGATIVE_INFINITY value can also be used.minIncluded - true if the lower bound is to be included in the
range; false to exclude the lower bound; overridden to be false if the
lower bound is openmaxValue - the upper bound; passing null for this parameter
means an open upper bound; for Float or Double types, the
relevant NEGATIVE_INFINITY value can also be used.maxIncluded - true if the upper bound is to be included in the
range; false to exclude the upper bound; overridden to be false if the
upper bound is openpublic static <T extends Number & Comparable> Range<T> create(T value, int... inf)
T - value typevalue - the value to set for both min and max end-pointsinf - either Range.INF or Range.NEG_INF (ignored if value is non-null)public boolean isPoint()
true if this is a point; false otherwisepublic T getMin()
Caution: If the range is lower-open (ie. isMinOpen() returns true) this method will return null.
public boolean isMinInf()
true if positive infinity; false otherwisepublic boolean isMinNegInf()
true if negative infinity; false otherwisepublic T getMax()
Caution: If the range is upper-open (ie. isMaxOpen() returns true) this method will return null.
public boolean isMaxInf()
true if positive infinity; false otherwisepublic boolean isMaxNegInf()
true if negative infinity; false otherwisepublic boolean isMinIncluded()
true if minimum value is included; false otherwiseisMinOpen(),
isMinClosed()public boolean isMaxIncluded()
true if maximum value is included; false otherwiseisMaxOpen(),
isMaxClosed()public boolean isMinOpen()
true if unbounded; false otherwiseisMinIncluded()public boolean isMinClosed()
true if bounded; false otherwiseisMinIncluded()public boolean isMaxOpen()
true if unbounded; false otherwiseisMaxIncluded()public boolean isMaxClosed()
true if bounded; false otherwiseisMaxIncluded()public boolean contains(T value)
value - the valuetrue if the value is within this range; false otherwisepublic boolean intersects(Range<T> other)
other - the range to check for intersectiontrue if the ranges intersect; false otherwisepublic boolean equals(Object obj)
Copyright © 2009–2018. All rights reserved.