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));
}
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());
}
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());
}
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));
}
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());
}
Aggregations