@Override public long reduce(long identity, LongBinaryOperator op) { return performOperation( TerminalFunctions.reduceFunction(identity, op), true, (i1, i2) -> op.applyAsLong(i1, i2), null); }
@Override public OptionalLong reduce(LongBinaryOperator op) { Long result = performOperation( TerminalFunctions.reduceFunction(op), true, (i1, i2) -> { if (i1 != null) { if (i2 != null) { return op.applyAsLong(i1, i2); } return i1; } return i2; }, null); if (result == null) { return OptionalLong.empty(); } else { return OptionalLong.of(result); } }