Java Stream Operation lazyStream(PrimitiveIterator.OfLong iterator)

Here you can find the source of lazyStream(PrimitiveIterator.OfLong iterator)

Description

Utility Method to create a stream from an iterator.

License

Open Source License

Parameter

Parameter Description
iterator Iterator to use

Return

A long stream with the iterated longs

Declaration

public static LongStream lazyStream(PrimitiveIterator.OfLong iterator) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Iterator;

import java.util.PrimitiveIterator;

import java.util.stream.LongStream;
import java.util.stream.Stream;
import static java.util.Spliterator.IMMUTABLE;
import static java.util.Spliterator.NONNULL;
import static java.util.Spliterators.spliteratorUnknownSize;

import static java.util.stream.StreamSupport.longStream;
import static java.util.stream.StreamSupport.stream;

public class Main {
    /**//w w w. j  av  a 2 s  . c o m
     * Utility Method to create a stream from an iterator. Elements are added lazily.
     *
     * @param iterator Iterator to use
     * @return A long stream with the iterated longs
     */
    public static LongStream lazyStream(PrimitiveIterator.OfLong iterator) {
        return longStream(spliteratorUnknownSize(iterator, IMMUTABLE | NONNULL), false);
    }

    /**
     * Utility Method to create a stream from an iterator. Elements are added lazily.
     *
     * @param iterator Iterator to use
     * @return A stream with the iterated objects
     */
    public static <E> Stream<E> lazyStream(Iterator<E> iterator) {
        return stream(spliteratorUnknownSize(iterator, IMMUTABLE | NONNULL), false);
    }
}

Related

  1. isFinite(Stream stream)
  2. iterableOf(Stream stream)
  3. iteratorToFiniteStream(Iterator iterator, boolean parallel)
  4. iteratorToStream(final Iterator iterator)
  5. lazyPartition(final Stream stream, final int maxPartitionSize)
  6. longArray(Stream stream)
  7. longList(LongStream stream)
  8. makeStream(final Object[] array)
  9. mapElementsSizes(IntStream intStream)