public static double reduceBy ( final float [ ] array , ReduceBy reduceBy ) { double sum = 0 ; for ( float v : array ) { sum = reduceBy . reduce ( sum , v ) ; } return sum ; }
A very fast reduce by . If performance is your thing this seems to be as fast a plain for loop when benchmarking with JMH .