code: public ImmutableSortedSet<C> asSet(DiscreteDomain<C> domain) {
      checkNotNull(domain);
      if (isEmpty()) {
        return ImmutableSortedSet.of();
      }
      Range<C> span = span().canonical(domain);
      if (!span.hasLowerBound()) {
        // according to the spec of canonical, neither this ImmutableRangeSet nor
        // the range have a lower bound
        throw new IllegalArgumentException(
            "Neither the DiscreteDomain nor this range set are bounded below");
      } else if (!span.hasUpperBound()) {
        try {
          domain.maxValue();
        } catch (NoSuchElementException e) {
          throw new IllegalArgumentException(
              "Neither the DiscreteDomain nor this range set are bounded above");
        }
      }
  
      return new AsSet(domain);
    }
docs: Returns an {@link ImmutableSortedSet} containing the same values in the given domain
  {@linkplain RangeSet#contains contained} by this range set.
  
  <p><b>Note:</b> {@code a.asSet(d).equals(b.asSet(d))} does not imply {@code a.equals(b)}! For
  example, {@code a} and {@code b} could be {@code [2..4]} and {@code (1..5)}, or the empty
  ranges {@code [3..3)} and {@code [4..4)}.
  
  <p><b>Warning:</b> Be extremely careful what you do with the {@code asSet} view of a large
  range set (such as {@code ImmutableRangeSet.of(Range.greaterThan(0))}). Certain operations on
  such a set can be performed efficiently, but others (such as {@link Set#hashCode} or {@link
  Collections#frequency}) can cause major performance problems.
  
  <p>The returned set's {@link Object#toString} method returns a short-hand form of the set's
  contents, such as {@code "[1..100]}"}.
  
  @throws IllegalArgumentException if neither this range nor the domain has a lower bound, or if
  neither has an upper bound