Returns an unmodifiable view of {@code iterable}.
978648
public static <T> Iterable<T> unmodifiableIterable(
      final Iterable<T> iterable) {
    checkNotNull(iterable);
    if (iterable instanceof UnmodifiableIterable ||
        iterable instanceof ImmutableCollection) {
      return iterable;
    }
    return new UnmodifiableIterable<T>(iterable);
  }
415422
public static <T> Iterable<T> iterableOf(Iterator<T> it) {
        final Iterator<T> theIt = Require.nonNull(it, "it");
        return new Iterable<T>() {

            @Override
            public Iterator<T> iterator() {
                return theIt;
            }
        };
    }
973336
public <E extends T> Iterable<E> createView (final Iterable<E> input)
    {
        return new Iterable<E>() {
            public Iterator<E> iterator() {
                return filter(input.iterator());
            }
        };
    }
104066
public static <T> Set<T> toSet(Iterable<T> iterable)
   {
      if (iterable == null)
      {
         return null;
      }
      else if (iterable instanceof Set)
      {
         return (Set<T>) iterable;
      }
      else
      {
         Set<T> list = new LinkedHashSet<>();
         for (T obj : iterable)
         {
            list.add(obj);
         }
         return list;
      }
   }
1005592
public static Predicates<Object> in(Iterable<?> iterable)
    {
        if (iterable instanceof SetIterable<?>)
        {
            return new InSetIterablePredicate((SetIterable<?>) iterable);
        }
        if (iterable instanceof Set<?>)
        {
            return new InSetPredicate((Set<?>) iterable);
        }
        if (iterable instanceof Collection<?> && ((Collection<?>) iterable).size() <= SMALL_COLLECTION_THRESHOLD)
        {
            return new InCollectionPredicate((Collection<?>) iterable);
        }
        return new InSetIterablePredicate(UnifiedSet.newSet(iterable));
    }
420657
public static <T> List<T> iterableToList(Iterable<T> iterable) {
        if (iterable == null) {
            return Collections.emptyList();
        }
        if (iterable instanceof List) {
            return (List<T>) iterable;
        }
        Iterator<T> i = iterable.iterator();
        if (i.hasNext()) {
            List<T> list = new ArrayList<>();
            while (i.hasNext()) {
                list.add(i.next());
            }
            return list;
        }
        return Collections.emptyList();
    }
269669
@Override
    public <R> ListT<W,R> unitIterable(final Iterable<R> it) {
        return of(run.unitIterable(it)
                     .map(i -> ListX.of(i)));
    }
21664
private Iterable<YamlNode> cast(Iterable<Object> nodes) {
        return () -> new UnmodifiableIterator<YamlNode>() {
            private final Iterator<Object> iter = nodes.iterator();

            @Override
            public boolean hasNext() {
                return iter.hasNext();
            }

            @Override
            public YamlNode next() {
                return (YamlNode) iter.next();
            }
        };
    }
701365
public static <T> Iterable<T> cast(Iterable<?> iterable) {
    return iterable == null ? null : new CastingIterable<T>(iterable);
  }
1192663
@Override
    public <U> CollectionX<U> unitIterable(final Iterable<U> u) {
        return ListX.fromIterable(u);
    }
899680
public static <T> Iterable<T> distinct(final Iterable<T> iterable) {
        requireNonNull(iterable);
        return () -> Iterators2.distinct(iterable.iterator());
    }
1171996
public static <T> LazyIterable<T> select(Iterable<T> iterable, Predicate<? super T> predicate)
    {
        return new SelectIterable<T>(iterable, predicate);
    }
314579
public static <T> List<T> toList(Iterable<T> iterable)
    {
        Objects.requireNonNull(iterable, "The iterable is null");
        return Iterables.toCollection(iterable, new ArrayList<T>());
    }
1302567
public <E> List<E> unmodifiable(List<E> input)
    {
        if (input == null) {
            return null;
        }
        return Collections.unmodifiableList(input);
    }
162673
public static <T> ImmutableMultimap<T, Integer> itemToIndexMultimap(
      Iterable<T> iterable) {
    final ImmutableMultimap.Builder<T, Integer> ret = ImmutableMultimap.builder();
    int idx = 0;
    for (final T x : iterable) {
      ret.put(x, idx++);
    }
    return ret.build();
  }
537566
public static <E, L extends List<E>> UnmodifiableMutableList<E> of(L list)
    {
        if (list == null)
        {
            throw new IllegalArgumentException("cannot create an UnmodifiableMutableList for null");
        }
        if (list instanceof RandomAccess)
        {
            return new RandomAccessUnmodifiableMutableList<E>(RandomAccessListAdapter.adapt(list));
        }
        return new UnmodifiableMutableList<E>(ListAdapter.adapt(list));
    }
1164479
@ReplacedBy("com.google.common.collect.Iterators#unmodifiableIterator()")
    public static <T> Iterator<T> getUnmodifiableIterator (final Iterator<T> itr)
    {
        return new Iterator<T>() {
            public boolean hasNext () {
                return itr.hasNext();
            }
            public T next () {
                return itr.next();
            }
            public void remove () {
                throw new UnsupportedOperationException(
                    "Cannot remove from an UnmodifiableIterator!");
            }
        };
    }