Example usage for java.util Spliterator SIZED

List of usage examples for java.util Spliterator SIZED

Introduction

In this page you can find the example usage for java.util Spliterator SIZED.

Prototype

int SIZED

To view the source code for java.util Spliterator SIZED.

Click Source Link

Document

Characteristic value signifying that the value returned from estimateSize() prior to traversal or splitting represents a finite size that, in the absence of structural source modification, represents an exact count of the number of elements that would be encountered by a complete traversal.

Usage

From source file:com.wrmsr.kleist.util.Itertools.java

public static <T> Stream<T> lazyStream(Supplier<? extends T> supplier) {
    return StreamSupport.stream(Spliterators.spliterator(lazyIterator(supplier), 1, Spliterator.SIZED), false);
}

From source file:org.apache.tinkerpop.gremlin.process.traversal.Traversal.java

/**
 * Return the traversal as a {@link Stream}.
 *
 * @return the traversal as a stream.//  w ww. jav  a 2  s.  c o m
 */
public default Stream<E> toStream() {
    return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(this, Spliterator.IMMUTABLE | Spliterator.SIZED), false);
}

From source file:org.briljantframework.array.AbstractBooleanArray.java

@Override
public Stream<Boolean> stream() {
    return StreamSupport.stream(Spliterators.spliterator(new Iterator<Boolean>() {
        int current = 0;

        @Override/*ww  w  .j  av  a 2  s  . c om*/
        public boolean hasNext() {
            return current < size();
        }

        @Override
        public Boolean next() {
            return get(current++);
        }
    }, size(), Spliterator.SIZED), false);
}

From source file:org.briljantframework.array.AbstractComplexArray.java

@Override
public Stream<Complex> stream() {
    return StreamSupport.stream(Spliterators.spliterator(new Iterator<Complex>() {
        int current = 0;

        @Override//from  ww w. jav  a2 s.  c  om
        public boolean hasNext() {
            return current < size();
        }

        @Override
        public Complex next() {
            return get(current++);
        }
    }, size(), Spliterator.SIZED), false);
}

From source file:org.briljantframework.array.AbstractDoubleArray.java

@Override
public DoubleStream stream() {
    PrimitiveIterator.OfDouble ofDouble = new PrimitiveIterator.OfDouble() {
        public int current = 0;

        @Override/*from  www  . j a v  a  2s.  c  o m*/
        public double nextDouble() {
            return get(current++);
        }

        @Override
        public boolean hasNext() {
            return current < size();
        }
    };

    Spliterator.OfDouble spliterator = Spliterators.spliterator(ofDouble, size(), Spliterator.SIZED);
    return StreamSupport.doubleStream(spliterator, false);
}

From source file:org.briljantframework.array.AbstractIntArray.java

@Override
public IntStream stream() {
    PrimitiveIterator.OfInt ofInt = new PrimitiveIterator.OfInt() {
        private int current = 0;

        @Override//from  ww w.  ja  v a  2  s  .co  m
        public int nextInt() {
            return get(current++);
        }

        @Override
        public boolean hasNext() {
            return current < size();
        }

    };
    Spliterator.OfInt spliterator = Spliterators.spliterator(ofInt, size(), Spliterator.SIZED);
    return StreamSupport.intStream(spliterator, false);
}

From source file:org.briljantframework.array.AbstractLongArray.java

@Override
public LongStream stream() {
    PrimitiveIterator.OfLong ofLong = new PrimitiveIterator.OfLong() {
        public int current = 0;

        @Override//from w  w  w  . j ava 2 s  . c o m
        public long nextLong() {
            return get(current++);
        }

        @Override
        public boolean hasNext() {
            return current < size();
        }
    };
    Spliterator.OfLong spliterator = Spliterators.spliterator(ofLong, size(), Spliterator.SIZED);
    return StreamSupport.longStream(spliterator, false);
}