Search in sources :

Example 1 with DoubleConsumer

use of java.util.function.DoubleConsumer in project jdk8u_jdk by JetBrains.

the class DoublePipeline method forEachWithCancel.

@Override
final void forEachWithCancel(Spliterator<Double> spliterator, Sink<Double> sink) {
    Spliterator.OfDouble spl = adapt(spliterator);
    DoubleConsumer adaptedSink = adapt(sink);
    do {
    } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
}
Also used : DoubleConsumer(java.util.function.DoubleConsumer) ObjDoubleConsumer(java.util.function.ObjDoubleConsumer) Spliterator(java.util.Spliterator)

Example 2 with DoubleConsumer

use of java.util.function.DoubleConsumer in project j2objc by google.

the class SpliteratorsTest method testEmptyDoubleSpliterator.

public void testEmptyDoubleSpliterator() {
    Spliterator.OfDouble empty = Spliterators.emptyDoubleSpliterator();
    assertNull(empty.trySplit());
    assertEquals(0, empty.estimateSize());
    assertEquals(0, empty.getExactSizeIfKnown());
    DoubleConsumer alwaysFails = (double value) -> fail();
    Consumer<Double> alwaysFailsBoxed = (Double value) -> fail();
    empty.tryAdvance(alwaysFails);
    empty.tryAdvance(alwaysFailsBoxed);
    empty.forEachRemaining(alwaysFails);
    empty.forEachRemaining(alwaysFailsBoxed);
    assertEquals(Spliterator.SIZED | Spliterator.SUBSIZED, empty.characteristics());
}
Also used : DoubleConsumer(java.util.function.DoubleConsumer) Spliterator(java.util.Spliterator)

Example 3 with DoubleConsumer

use of java.util.function.DoubleConsumer in project j2objc by google.

the class OptionalDoubleTest method testIfPresent.

public void testIfPresent() {
    DoubleConsumer alwaysFails = value -> fail();
    OptionalDouble.empty().ifPresent(alwaysFails);
    final AtomicReference<Double> reference = new AtomicReference<>();
    DoubleConsumer recorder = value -> reference.set(value);
    OptionalDouble.of(56.0).ifPresent(recorder);
    assertEquals(56.0, reference.get().doubleValue());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DoubleSupplier(java.util.function.DoubleSupplier) OptionalDouble(java.util.OptionalDouble) Optional(java.util.Optional) IOException(java.io.IOException) TestCase(junit.framework.TestCase) NoSuchElementException(java.util.NoSuchElementException) AtomicReference(java.util.concurrent.atomic.AtomicReference) DoubleConsumer(java.util.function.DoubleConsumer) Supplier(java.util.function.Supplier) DoubleConsumer(java.util.function.DoubleConsumer) AtomicReference(java.util.concurrent.atomic.AtomicReference) OptionalDouble(java.util.OptionalDouble)

Example 4 with DoubleConsumer

use of java.util.function.DoubleConsumer in project j2objc by google.

the class DoublePipeline method forEachWithCancel.

@Override
public final void forEachWithCancel(Spliterator<Double> spliterator, Sink<Double> sink) {
    Spliterator.OfDouble spl = adapt(spliterator);
    DoubleConsumer adaptedSink = adapt(sink);
    do {
    } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
}
Also used : DoubleConsumer(java.util.function.DoubleConsumer) ObjDoubleConsumer(java.util.function.ObjDoubleConsumer) Spliterator(java.util.Spliterator)

Example 5 with DoubleConsumer

use of java.util.function.DoubleConsumer in project j2objc by google.

the class DoubleConsumerTest method testAndThen.

public void testAndThen() throws Exception {
    StringBuilder sb = new StringBuilder();
    DoubleConsumer one = d -> sb.append("one:" + d + ",");
    DoubleConsumer two = d -> sb.append("two:" + d);
    one.andThen(two).accept(1.0d);
    assertEquals("one:1.0,two:1.0", sb.toString());
}
Also used : TestCase(junit.framework.TestCase) DoubleConsumer(java.util.function.DoubleConsumer) DoubleConsumer(java.util.function.DoubleConsumer)

Aggregations

DoubleConsumer (java.util.function.DoubleConsumer)8 Spliterator (java.util.Spliterator)4 ObjDoubleConsumer (java.util.function.ObjDoubleConsumer)3 TestCase (junit.framework.TestCase)3 IOException (java.io.IOException)1 NoSuchElementException (java.util.NoSuchElementException)1 Optional (java.util.Optional)1 OptionalDouble (java.util.OptionalDouble)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 DoubleSupplier (java.util.function.DoubleSupplier)1 Supplier (java.util.function.Supplier)1