public long reduce(long identity, @NotNull LongBinaryOperator accumulator) {
        long result = identity;
        while (iterator.hasNext()) {
            final long value = iterator.nextLong();
            result = accumulator.applyAsLong(result, value);
        }
        return result;
    }
public long reduce ( long identity , @ NotNull LongBinaryOperator accumulator ) { long result = identity ; while ( iterator . hasNext ( ) ) { final long value = iterator . nextLong ( ) ; result = accumulator . applyAsLong ( result , value ) ; } return result ; }
Performs a reduction on the elements of this stream, using the provided
identity value and an associative accumulation function, and returns the
reduced value.

<p>The {@code identity} value must be an identity for the accumulator
function. This means that for all {@code x},
{@code accumulator.apply(identity, x)} is equal to {@code x}.
The {@code accumulator} function must be an associative function.

<p>This is a terminal operation.

<p>Example:
<pre>
identity: 0
accumulator: (a, b) -&gt; a + b
stream: [1, 2, 3, 4, 5]
result: 15
</pre>

@param identity  the identity value for the accumulating function
@param accumulator  the accumulation function
@return the result of the reduction
@see #sum()
@see #min()
@see #max()