private ImmutableList<Range<C>> intersectRanges(final Range<C> range) {
    if (ranges.isEmpty() || range.isEmpty()) {
      return ImmutableList.of();
    } else if (range.encloses(span())) {
      return ranges;
    }

    final int fromIndex;
    if (range.hasLowerBound()) {
      fromIndex =
          SortedLists.binarySearch(
              ranges,
              Range.<C>upperBoundFn(),
              range.lowerBound,
              KeyPresentBehavior.FIRST_AFTER,
              KeyAbsentBehavior.NEXT_HIGHER);
    } else {
      fromIndex = 0;
    }

    int toIndex;
    if (range.hasUpperBound()) {
      toIndex =
          SortedLists.binarySearch(
              ranges,
              Range.<C>lowerBoundFn(),
              range.upperBound,
              KeyPresentBehavior.FIRST_PRESENT,
              KeyAbsentBehavior.NEXT_HIGHER);
    } else {
      toIndex = ranges.size();
    }
    final int length = toIndex - fromIndex;
    if (length == 0) {
      return ImmutableList.of();
    } else {
      return new ImmutableList<Range<C>>() {
        @Override
        public int size() {
          return length;
        }

        @Override
        public Range<C> get(int index) {
          checkElementIndex(index, length);
          if (index == 0 || index == length - 1) {
            return ranges.get(index + fromIndex).intersection(range);
          } else {
            return ranges.get(index + fromIndex);
          }
        }

        @Override
        boolean isPartialView() {
          return true;
        }
      };
    }
  }
private ImmutableList<Range<C>> intersectRanges(final Range<C> range) {
    if (ranges.isEmpty() || range.isEmpty()) {
      return ImmutableList.of();
    } else if (range.encloses(span())) {
      return ranges;
    }

    final int fromIndex;
    if (range.hasLowerBound()) {
      fromIndex =
          SortedLists.binarySearch(
              ranges,
              Range.<C>upperBoundFn(),
              range.lowerBound,
              KeyPresentBehavior.FIRST_AFTER,
              KeyAbsentBehavior.NEXT_HIGHER);
    } else {
      fromIndex = 0;
    }

    int toIndex;
    if (range.hasUpperBound()) {
      toIndex =
          SortedLists.binarySearch(
              ranges,
              Range.<C>lowerBoundFn(),
              range.upperBound,
              KeyPresentBehavior.FIRST_PRESENT,
              KeyAbsentBehavior.NEXT_HIGHER);
    } else {
      toIndex = ranges.size();
    }
    final int length = toIndex - fromIndex;
    if (length == 0) {
      return ImmutableList.of();
    } else {
      return new ImmutableList<Range<C>>() {
        @Override
        public int size() {
          return length;
        }

        @Override
        public Range<C> get(int index) {
          checkElementIndex(index, length);
          if (index == 0 || index == length - 1) {
            return ranges.get(index + fromIndex).intersection(range);
          } else {
            return ranges.get(index + fromIndex);
          }
        }

        @Override
        boolean isPartialView() {
          return true;
        }
      };
    }
  }
private ImmutableList < Range < C > > intersectRanges ( final Range < C > range ) { if ( ranges . isEmpty ( ) || range . isEmpty ( ) ) { return ImmutableList . of ( ) ; } else if ( range . encloses ( span ( ) ) ) { return ranges ; } final int fromIndex ; if ( range . hasLowerBound ( ) ) { fromIndex = SortedLists . binarySearch ( ranges , Range . < C > upperBoundFn ( ) , range . lowerBound , KeyPresentBehavior . FIRST_AFTER , KeyAbsentBehavior . NEXT_HIGHER ) ; } else { fromIndex = 0 ; } int toIndex ; if ( range . hasUpperBound ( ) ) { toIndex = SortedLists . binarySearch ( ranges , Range . < C > lowerBoundFn ( ) , range . upperBound , KeyPresentBehavior . FIRST_PRESENT , KeyAbsentBehavior . NEXT_HIGHER ) ; } else { toIndex = ranges . size ( ) ; } final int length = toIndex - fromIndex ; if ( length == 0 ) { return ImmutableList . of ( ) ; } else { return new ImmutableList < Range < C > > ( ) { @ Override public int size ( ) { return length ; } @ Override public Range < C > get ( int index ) { checkElementIndex ( index , length ) ; if ( index == 0 || index == length - 1 ) { return ranges . get ( index + fromIndex ) . intersection ( range ) ; } else { return ranges . get ( index + fromIndex ) ; } } @ Override boolean isPartialView ( ) { return true ; } } ; } }
Returns a list containing the nonempty intersections of {@code range} with the ranges in this
range set.
Returns a list containing the nonempty intersections of {