/** * Creates the complement of a {@code Range}. This is equivalent to subtracting the * input from the infinite interval. * <p> * If the input is a finite interval or point, the result will be a list of * two {@code Ranges}. For example: the complement of [-5, 5) is made up of * (-Inf, -5) and [5, Inf). * <p> * If the input is an interval open at one end, the result list will contain * a single {@code Range}. For example: the complement of (-Inf, 5) is [5, Inf). * <p> * If the input is a point at positive or negative infinity its complement is, * by convention, (-Inf, Inf). * <p> * If the input is the infinite interval (-Inf, Inf) the result list will be * empty. * * @param <T> the value type * @param range input range * * @return a list of 0, 1 or 2 {@code Ranges} which form the complement * * @see #createComplement(java.util.Collection) */ public static <T extends Number & Comparable> List<Range<T>> createComplement(Range<T> range) { return subtract(range, new Range<T>(null, false, null, false)); }
case EXCLUDE: inclRanges = CollectionFactory.list(); List<Range<Double>> incRanges = RangeUtils.createComplement(RangeUtils.sort(ranges)); inclRanges.addAll(incRanges); break;
List sortedRanges = RangeUtils.sort(coll); final int elements = sortedRanges.size(); if (elements > 1) {
Range<T> common = intersection(r1, r2);
List<Range<T>> diffs = RangeUtils.subtract(item.getRange(), srcRange); for (Range<T> diff : diffs) { add(diff, resultValue);
switch (rangesType) { case EXCLUDE: List<Range<Double>> inRanges = RangeUtils.createComplement(RangeUtils.sort(ranges)); localRanges = CollectionFactory.list(); localRanges.addAll(inRanges);