Takes a stream and enumerates it (similar to Python's enumerate()) to return
the item along with its position.

@param <T>
@param stream
@return
510391
public static <T> Stream<Map.Entry<Integer, T>> enumerate(Stream<T> stream) {
        Iterator<Map.Entry<Integer, T>> iterator = new Iterator<Map.Entry<Integer, T>>() {
            private int counter = 0;
            
            private final Iterator<T> internalIterator = stream.iterator();
            
            /** {@inheritDoc} */
            @Override
            public boolean hasNext() {
                return internalIterator.hasNext();
            }
            
            /** {@inheritDoc} */
            @Override
            public Map.Entry<Integer, T> next() {
                return new AbstractMap.SimpleImmutableEntry<>(counter++, internalIterator.next());
            }

            /** {@inheritDoc} */
            @Override
            public void remove() {
                throw new UnsupportedOperationException("This is a read-only iterator, remove operation is not supported.");
            }
        };
        return stream(iterator, stream.isParallel());
    }
664514
function (stream) {
        var self = this;
        stream.on('data', function (chunk) {
            self.push(chunk);
        });
        stream.on('end', function () {
            self.push(null);
        });
        this.readableUnit = stream;
        return this;
    }
725381
public static <T> Stream<T> parallelConcat(final Collection<? extends Stream<? extends T>> c) {
        return parallelConcat(c, DEFAULT_READING_THREAD_NUM);
    }
170856
public <T, R> Stream<R> map(Stream<T> stream, Function<? super T, ? extends R> mapper) {
        Callable<Stream<R>> callable = () -> stream.map(mapper);
        return ThreadMethods.forkJoinExecution(callable, concurrencyConfiguration, stream.isParallel());
    }
17038
public static final <A> Collection<A> toConcurrentLazyCollection(final Stream<A> stream) {
        return toConcurrentLazyCollection(stream.iterator());
    }
1067991
public static <U> Stream<U> reverse(final Stream<U> stream) {
        return reversedStream(stream.collect(Collectors.toList()));
    }
475967
public static <T> Stream<T> stream(final Iterable<T> source) {
        return new Stream<T>() {
            @Override
            public Iterator<T> iterator() {
                return source.iterator();
            }
        };
    }
846660
public static <U> Stream<U> stream(final Iterator<U> it) {
        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, Spliterator.ORDERED), false);
    }
97125
@SuppressWarnings("resource")
    public static Scanner streamToScanner( InputStream stream, String delimiter ) {
        java.util.Scanner s = new java.util.Scanner(stream).useDelimiter(delimiter);
        return s;
    }
1253383
public static <T> Set<T> toSet(BaseStream<T, ? extends BaseStream> stream) {
        return StreamSupport.stream(
                Spliterators.spliteratorUnknownSize(stream.iterator(), Spliterator.ORDERED),
                false).collect(Collectors.<T>toSet());
    }
506995
public static <T> Set<T> toSet(Stream<T> stream) {
        return stream.collect(Collectors.<T>toSet());
    }
435846
public static <T, R> Map<R, T> mapBy(Stream<T> stream,
            Function<T, R> classifier) {
        return stream
                .collect(toMap(classifier, identity(), (o, o2) -> o2));
    }
1083631
def FromStream(cls, stream):
        

        if stream.system:
            specifier = DataStreamSelector.MatchSystemOnly
        else:
            specifier = DataStreamSelector.MatchUserOnly

        return DataStreamSelector(stream.stream_type, stream.stream_id, specifier)
411297
public <T> Optional<T> min(Stream<T> stream, Comparator<? super T> comparator) {
        Callable<Optional<T>> callable = () -> stream.min(comparator);
        return ThreadMethods.forkJoinExecution(callable, concurrencyConfiguration, stream.isParallel());
    }
1097179
public <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
        List<R> list = new ArrayList<R>();
        while (iterator.hasNext()) {
            list.add(mapper.apply(iterator.next()));
        }
        return Stream.of(list);
    }
19967
public static <T> CloseableIterator<T> fromStream(Stream<T> stream) {
        return wrap(stream.iterator(), stream);
    }
1198210
@Override
    public <X> LazyCollectionX<X> fromStream(final ReactiveSeq<X> stream) {
        return ListX.fromIterable(stream.collect(Collectors.toList()));
    }