com.annimon.stream.operator.DoubleScanIdentity Maven / Gradle / Ivy
package com.annimon.stream.operator;
import com.landawn.abacus.util.function.DoubleBinaryOperator;
import com.annimon.stream.iterator.PrimitiveExtIterator;
import com.annimon.stream.iterator.PrimitiveIterator;
public class DoubleScanIdentity extends PrimitiveExtIterator.OfDouble {
private final PrimitiveIterator.OfDouble iterator;
private final double identity;
private final DoubleBinaryOperator accumulator;
public DoubleScanIdentity(PrimitiveIterator.OfDouble iterator, double identity,
DoubleBinaryOperator accumulator) {
this.iterator = iterator;
this.identity = identity;
this.accumulator = accumulator;
}
@Override
protected void nextIteration() {
if (!isInit) {
// Return identity
hasNext = true;
next = identity;
return;
}
hasNext = iterator.hasNext();
if (hasNext) {
final double current = iterator.next();
next = accumulator.applyAsDouble(next, current);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy