public class RangeUtils extends Object
Range objects.| Constructor and Description |
|---|
RangeUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends Number & Comparable> |
createComplement(Collection<Range<T>> ranges)
Creates the complement of the given list of
Ranges. |
static <T extends Number & Comparable> |
createComplement(Range<T> range)
Creates the complement of a
Range. |
static <T extends Number & Comparable> |
intersection(Range<T> r1,
Range<T> r2)
Gets the intersection of two ranges.
|
static <T extends Number & Comparable> |
simplify(Collection<Range<T>> ranges)
Simplifies a collection of ranges by merging those which overlap.
|
static <T extends Number & Comparable> |
sort(Collection<Range<T>> ranges)
Sorts a collection of ranges into ascending order of min value, then max value.
|
static <T extends Number & Comparable> |
sortInPlace(List<Range<T>> ranges)
Sorts a list of ranges into ascending order of min value, then max value.
|
static <T extends Number & Comparable> |
subtract(Range<T> r1,
Range<T> r2)
Subtracts the first range from the second.
|
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 rangeRanges 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.Collection<org.jaitools.numeric.Range<T>>) on the inputs and then subtracts each of the
resulting Ranges from the whole number line.T - value typeranges - input rangesRanges 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 sortListpublic 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 simplifypublic static <T extends Number & Comparable> Range<T> intersection(Range<T> r1, Range<T> r2)
T - value typer1 - first ranger2 - second rangenull if there was no intersectionpublic static <T extends Number & Comparable> List<Range<T>> subtract(Range<T> r1, Range<T> r2)
T - value typer1 - the first ranger2 - the second ranger2 - r1Copyright © 2009–2018. All rights reserved.