Example usage for java.util Spliterator forEachRemaining

List of usage examples for java.util Spliterator forEachRemaining

Introduction

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

Prototype

default void forEachRemaining(Consumer<? super T> action) 

Source Link

Document

Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.

Usage

From source file:enumj.EnumeratorTest.java

@Test
public void testAsSpliterator() {
    System.out.println("asSpliterator");
    EnumeratorGenerator.generatorPairs().limit(100)
            .map(p -> Pair.of(p.getLeft().enumerator(), p.getRight().enumerator().asSpliterator()))
            .forEach(p -> {//from  w  ww.  ja v  a  2  s  . c  o m
                MutableLong c = new MutableLong(p.getLeft().count());
                final Spliterator<Double> s = p.getRight();
                s.forEachRemaining(d -> c.decrement());
                assertEquals(0, c.longValue());
            });
}