コード例 #1
0
 public <S> ImmutableSortedSet<Pair<T, S>> zip(Iterable<S> that) {
   Comparator<? super T> comparator = this.comparator();
   if (comparator == null) {
     TreeSortedSet<Pair<T, S>> pairs =
         TreeSortedSet.newSet(
             Comparators.<Pair<T, S>, T>byFunction(
                 Functions.<T>firstOfPair(), Comparators.<T>naturalOrder()));
     return Iterate.zip(this, that, pairs).toImmutable();
   }
   return Iterate.zip(
           this, that, TreeSortedSet.<Pair<T, S>>newSet(Comparators.<T>byFirstOfPair(comparator)))
       .toImmutable();
 }
コード例 #2
0
 public ImmutableSortedSet<Pair<T, Integer>> zipWithIndex() {
   Comparator<? super T> comparator = this.comparator();
   if (comparator == null) {
     TreeSortedSet<Pair<T, Integer>> pairs =
         TreeSortedSet.newSet(
             Comparators.<Pair<T, Integer>, T>byFunction(
                 Functions.<T>firstOfPair(), Comparators.<T>naturalOrder()));
     return Iterate.zipWithIndex(this, pairs).toImmutable();
   }
   return Iterate.zipWithIndex(
           this, TreeSortedSet.<Pair<T, Integer>>newSet(Comparators.<T>byFirstOfPair(comparator)))
       .toImmutable();
 }
コード例 #3
0
  public <T> ImmutableList<T> ofAll(Iterable<? extends T> items) {
    if (items instanceof ImmutableList<?>) {
      return (ImmutableList<T>) items;
    }

    return this.of((T[]) Iterate.toArray(items));
  }