Refine search
Range<C> effectiveRange = range; try { if (!range.hasLowerBound()) { effectiveRange = effectiveRange.intersection(Range.atLeast(domain.minValue())); if (!range.hasUpperBound()) { effectiveRange = effectiveRange.intersection(Range.atMost(domain.maxValue())); : new RegularContiguousSet<C>(effectiveRange, domain);
@Override public ContiguousSet<C> intersection(ContiguousSet<C> other) { checkNotNull(other); checkArgument(this.domain.equals(other.domain)); if (other.isEmpty()) { return other; } else { C lowerEndpoint = Ordering.natural().max(this.first(), other.first()); C upperEndpoint = Ordering.natural().min(this.last(), other.last()); return (lowerEndpoint.compareTo(upperEndpoint) <= 0) ? ContiguousSet.create(Range.closed(lowerEndpoint, upperEndpoint), domain) : new EmptyContiguousSet<C>(domain); } }
@Override ContiguousSet<C> subSetImpl( C fromElement, boolean fromInclusive, C toElement, boolean toInclusive) { if (fromElement.compareTo(toElement) == 0 && !fromInclusive && !toInclusive) { // Range would reject our attempt to create (x, x). return new EmptyContiguousSet<C>(domain); } return intersectionInCurrentDomain( Range.range( fromElement, BoundType.forBoolean(fromInclusive), toElement, BoundType.forBoolean(toInclusive))); }
@Override ContiguousSet<C> tailSetImpl(C fromElement, boolean inclusive) { return intersectionInCurrentDomain(Range.downTo(fromElement, BoundType.forBoolean(inclusive))); }
@Override ContiguousSet<C> headSetImpl(C toElement, boolean inclusive) { return intersectionInCurrentDomain(Range.upTo(toElement, BoundType.forBoolean(inclusive))); }
private Object readResolve() { return new RegularContiguousSet<C>(range, domain); } }
@Override public Range<C> range() { return range(CLOSED, CLOSED); }
@Override ContiguousSet<C> subSetImpl( C fromElement, boolean fromInclusive, C toElement, boolean toInclusive) { if (fromElement.compareTo(toElement) == 0 && !fromInclusive && !toInclusive) { // Range would reject our attempt to create (x, x). return new EmptyContiguousSet<C>(domain); } return intersectionInCurrentDomain( Range.range( fromElement, BoundType.forBoolean(fromInclusive), toElement, BoundType.forBoolean(toInclusive))); }
@Override ContiguousSet<C> tailSetImpl(C fromElement, boolean inclusive) { return intersectionInCurrentDomain(Range.downTo(fromElement, BoundType.forBoolean(inclusive))); }
@Override ContiguousSet<C> headSetImpl(C toElement, boolean inclusive) { return intersectionInCurrentDomain(Range.upTo(toElement, BoundType.forBoolean(inclusive))); }
private Object readResolve() { return new RegularContiguousSet<C>(range, domain); } }
@Override public Range<C> range() { return range(CLOSED, CLOSED); }
Range<C> effectiveRange = range; try { if (!range.hasLowerBound()) { effectiveRange = effectiveRange.intersection(Range.atLeast(domain.minValue())); if (!range.hasUpperBound()) { effectiveRange = effectiveRange.intersection(Range.atMost(domain.maxValue())); : new RegularContiguousSet<C>(effectiveRange, domain);