コード例 #1
0
 @Override
 public int reduce(int identity, IntBinaryOperator op) {
   return performOperation(
       TerminalFunctions.reduceFunction(identity, op),
       true,
       (i1, i2) -> op.applyAsInt(i1, i2),
       null);
 }
コード例 #2
0
 @Override
 public OptionalInt reduce(IntBinaryOperator op) {
   Integer result =
       performOperation(
           TerminalFunctions.reduceFunction(op),
           true,
           (i1, i2) -> {
             if (i1 != null) {
               if (i2 != null) {
                 return op.applyAsInt(i1, i2);
               }
               return i1;
             }
             return i2;
           },
           null);
   if (result == null) {
     return OptionalInt.empty();
   } else {
     return OptionalInt.of(result);
   }
 }