/** * Returns a view of the portion of this sorted set whose elements are * greater than or equal to {@code lower}. * The default implementation is equivalent to the same pseudo-code than the one * documented in the {@link #subSet(Range, Range)} method, except that the upper * endpoint is {@code null}. * * @param lower low endpoint (inclusive) of the tailSet. * @return a view of the specified final range of this sorted set. * * @see #intersect(Range) */ @Override public SortedSet<Range<E>> tailSet(final Range<E> lower) { ArgumentChecks.ensureNonNull("lower", lower); return intersect(new Range<>(elementType, lower.getMinValue(), lower.isMinIncluded(), null, false)); }
/** * Returns a view of the portion of this sorted set whose elements are * strictly less than {@code upper}. * The default implementation is equivalent to the same pseudo-code than the one * documented in the {@link #subSet(Range, Range)} method, except that the lower * endpoint is {@code null}. * * @param upper high endpoint (exclusive) of the headSet. * @return a view of the specified initial range of this sorted set. * * @see #intersect(Range) */ @Override public SortedSet<Range<E>> headSet(final Range<E> upper) { ArgumentChecks.ensureNonNull("upper", upper); final E maxValue = upper.getMinValue(); if (maxValue == null) { throw new IllegalArgumentException(Errors.format( Errors.Keys.IllegalArgumentValue_2, "upper", upper)); } return intersect(new Range<>(elementType, null, false, maxValue, !upper.isMinIncluded())); }
/** * Returns a view of the portion of this sorted set whose elements are * greater than or equal to {@code lower}. * The default implementation is equivalent to the same pseudo-code than the one * documented in the {@link #subSet(Range, Range)} method, except that the upper * endpoint is {@code null}. * * @param lower low endpoint (inclusive) of the tailSet. * @return a view of the specified final range of this sorted set. * * @see #intersect(Range) */ @Override public SortedSet<Range<E>> tailSet(final Range<E> lower) { ArgumentChecks.ensureNonNull("lower", lower); return intersect(new Range<>(elementType, lower.getMinValue(), lower.isMinIncluded(), null, false)); }
/** * Returns a view of the portion of this sorted set whose elements are * strictly less than {@code upper}. * The default implementation is equivalent to the same pseudo-code than the one * documented in the {@link #subSet(Range, Range)} method, except that the lower * endpoint is {@code null}. * * @param upper high endpoint (exclusive) of the headSet. * @return a view of the specified initial range of this sorted set. * * @see #intersect(Range) */ @Override public SortedSet<Range<E>> headSet(final Range<E> upper) { ArgumentChecks.ensureNonNull("upper", upper); final E maxValue = upper.getMinValue(); if (maxValue == null) { throw new IllegalArgumentException(Errors.format( Errors.Keys.IllegalArgumentValue_2, "upper", upper)); } return intersect(new Range<>(elementType, null, false, maxValue, !upper.isMinIncluded())); }
Errors.Keys.IllegalArgumentValue_2, "upper", upper)); return intersect(new Range<>(elementType, lower.getMinValue(), lower.isMinIncluded(), maxValue, !upper.isMinIncluded()));
Errors.Keys.IllegalArgumentValue_2, "upper", upper)); return intersect(new Range<>(elementType, lower.getMinValue(), lower.isMinIncluded(), maxValue, !upper.isMinIncluded()));
assertTrue(ranges.add( 40, 50)); assertTrue(ranges.add( 60, 70)); final SortedSet<Range<Integer>> subset = ranges.intersect(NumberRange.create(5, true, 45, false));