Lazily constructs a Collection from specified Stream. Collections iterator may be safely used
concurrently by multiple threads.
17038
public static final <A> Collection<A> toConcurrentLazyCollection(final Stream<A> stream) {
        return toConcurrentLazyCollection(stream.iterator());
    }
1279738
public static <T> Source<T> from(Collection<T> collection) {
        return from(collection.iterator());
    }
1003022
private static <T> Stream<T> enumerationAsStream(Enumeration<? extends T> e)
    {
        Iterator<T> iterator = new Iterator<T>()
        {
            @Override
            public T next()
            {
                return e.nextElement();
            }

            @Override
            public boolean hasNext()
            {
                return e.hasMoreElements();
            }
        };
        return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(
                iterator, Spliterator.ORDERED), false);
    }
929849
public static <T> Collector<T, ?, ArrayList<T>> toArrayList() {
    return java.util.stream.Collectors.toCollection(ArrayList::new);
  }
889662
public static <R> Stream<R> of(Iterable<R> iterable) {
        return new Stream<R>(iterable.iterator());
    }
58188
public static <E> List<E> buildList(Iterable<E> iterable) {
        return StreamSupport.stream(iterable.spliterator(), false)
                .collect(toList());
    }
1052999
public static <T, C extends Collection<? super T>> C toCollection(
        Iterator<T> iterator, C collection)
    {
        Objects.requireNonNull(iterator, "The iterator is null");
        Objects.requireNonNull(iterator, "The collection is null");
        while (iterator.hasNext())
        {
            collection.add(iterator.next());
        }
        return collection;
    }
579208
public static <T> Stream<T> of(final T value) {
        return new Stream<T>() {
            @Override
            public Iterator<T> iterator() {
                return new ReadOnlyIterator<T>() {

                    boolean has = true;

                    @Override
                    public boolean hasNext() {
                        return has;
                    }

                    @Override
                    public T next() {
                        has = false;
                        return value;
                    }
                };
            }
        };
    }
252165
public static <T> Iterator<T> join(Collection<Iterable<T>> iterables) {
        Queue<Iterator<T>> iters = 
            new ArrayDeque<Iterator<T>>(iterables.size());
        for (Iterable<T> i : iterables)
            iters.add(i.iterator());
        return new CombinedIterator<T>(iters);
    }
1312031
static IntStream stream(
        IntTuple tuple, int startInclusive, int endExclusive) 
    {
        IntTupleSpliterator intTupleSpliterator = 
            new IntTupleSpliterator(
                tuple, startInclusive, endExclusive);
        return StreamSupport.intStream(intTupleSpliterator, false);
    }
141107
public static <T> Stream<T> parallelConcat(final Collection<? extends Stream<? extends T>> c, final int readThreadNum) {
        return parallelConcat(c, readThreadNum, calculateQueueSize(c.size()));
    }
725381
public static <T> Stream<T> parallelConcat(final Collection<? extends Stream<? extends T>> c) {
        return parallelConcat(c, DEFAULT_READING_THREAD_NUM);
    }
1145761
@SafeVarargs
    public static <T> Stream<T> stream(Iterator<T>... iterators) {
        return withCloseHandler(
            Arrays.stream(iterators)
                .map(StreamUtils::streamForIterator)
                .reduce(Stream::concat)
                .orElseGet(Stream::empty),
            iterators
        );
    }
973914
public static <T, C extends Collection<T>> Map<T, C> makeElementsToContainersMap(
      final Iterable<C> collections) {
    final ImmutableMap.Builder<T, C> ret = ImmutableMap.builder();

    for (final C collection : collections) {
      for (final T item : collection) {
        ret.put(item, collection);
      }
    }

    return ret.build();
  }
835786
public static <T, C extends Collection<T>> Stream<T>
    ifExistIntoStream(C collection) {
        return getOptional(collection).map(Collection::stream)
                .orElseGet(Stream::empty);
    }
716240
public static <T> Stream<T> toStream( Iterator<T> iterator)
    {
    Iterable<T> iterable = () -> iterator;
    return toStream( iterable);
    }
878774
public Stream<T> lazyStream() throws IllegalStateException {

        if (pagerStream == null) {
            synchronized (this) {
                if (pagerStream == null) {

                    // Make sure that current page is 0, this will ensure the whole list is streamed
                    // regardless of what page the instance is currently on.
                    currentPage = 0;

                    pagerStream = StreamSupport.stream(new PagerSpliterator<T>(this), false);
                    return (pagerStream);
                }
            }
        }

        throw new IllegalStateException("Stream already issued");
    }