|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jaitools.numeric.RangeUtils
public class RangeUtils
Provides static helper methods to transform, sort and merge Range objects.
| Constructor Summary | |
|---|---|
RangeUtils()
|
|
| Method Summary | ||
|---|---|---|
static
|
createComplement(Collection<Range<T>> ranges)
Creates the complement of the given list of Ranges. |
|
static
|
createComplement(Range<T> range)
Creates the complement of a Range. |
|
static
|
intersection(Range<T> r1,
Range<T> r2)
Gets the intersection of two ranges. |
|
static
|
simplify(Collection<Range<T>> ranges)
Simplifies a collection of ranges by merging those which overlap. |
|
static
|
sort(Collection<Range<T>> ranges)
Sorts a collection of ranges into ascending order of min value, then max value. |
|
static
|
sortInPlace(List<Range<T>> ranges)
Sorts a list of ranges into ascending order of min value, then max value. |
|
static
|
subtract(Range<T> r1,
Range<T> r2)
Subtracts the first range from the second. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RangeUtils()
| Method Detail |
|---|
public static <T extends Number & Comparable> List<Range<T>> createComplement(Range<T> range)
Range. This is equivalent to subtracting the
input from the infinite interval.
If the input is a finite interval or point, the result will be a list of
two Ranges. For example: the complement of [-5, 5) is made up of
(-Inf, -5) and [5, Inf).
If the input is an interval open at one end, the result list will contain
a single Range. For example: the complement of (-Inf, 5) is [5, Inf).
If the input is a point at positive or negative infinity its complement is, by convention, (-Inf, Inf).
If the input is the infinite interval (-Inf, Inf) the result list will be empty.
T - the value typerange - input range
Ranges which form the complementcreateComplement(java.util.Collection)public static <T extends Number & Comparable> List<Range<T>> createComplement(Collection<Range<T>> ranges)
Ranges. This method first
calls simplify(java.util.CollectionRanges from the whole number line.
T - value typeranges - input ranges
Ranges which form the complement (may be empty)createComplement(Range)public static <T extends Number & Comparable> List<Range<T>> sort(Collection<Range<T>> ranges)
T - the value typeranges - the ranges to sort
Listpublic static <T extends Number & Comparable> void sortInPlace(List<Range<T>> ranges)
T - the value typeranges - the ranges to sortpublic static <T extends Number & Comparable> List<Range<T>> simplify(Collection<Range<T>> ranges)
T - value typeranges - input ranges to simplify
public static <T extends Number & Comparable> Range<T> intersection(Range<T> r1,
Range<T> r2)
T - value typer1 - first ranger2 - second range
null if there was no intersection
public static <T extends Number & Comparable> List<Range<T>> subtract(Range<T> r1,
Range<T> r2)
T - value typer1 - the first ranger2 - the second range
r2 - r1
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||