/** * * @param array array of items to reduce by * @param start where to start in the array * @param length where to end in the array * @param reduceBy the function to do the reduce by * @return the reduction */ public static double reduceBy( final double[] array, final int start, final int length, ReduceBy reduceBy ) { double sum = 0; for (int index = start; index < length; index++) { double v = array[index]; sum = reduceBy.reduce(sum, v); } return sum; }
/** * * @param array array of items to reduce by * @param start where to start in the array * @param length where to end in the array * @param reduceBy the function to do the reduce by * @return the reduction */ public static double reduceBy( final double[] array, final int start, final int length, ReduceBy reduceBy ) { double sum = 0; for (int index = start; index < length; index++) { double v = array[index]; sum = reduceBy.reduce(sum, v); } return sum; }
/** * * @param array array of items to reduce by * @param start where to start in the array * @param length where to end in the array * @param reduceBy the function to do the reduce by * @return the reduction */ public static double reduceBy( final double[] array, final int start, final int length, ReduceBy reduceBy ) { double sum = 0; for (int index = start; index < length; index++) { double v = array[index]; 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. * * @param array array of items to reduce by * @param reduceBy reduceBy interface * @return the final value */ public static double reduceBy( final double[] array, ReduceBy reduceBy ) { double sum = 0; for ( double v : array ) { sum = reduceBy.reduce(sum, v); } return sum; }
/** * * @param array array of items to reduce by * @param length where to end in the array * @param reduceBy the function to do the reduce by * @return the reduction */ public static double reduceBy( final double[] array, final int length, ReduceBy reduceBy ) { double sum = 0; for (int index = 0; index < length; index++) { double v = array[index]; 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. * * @param array array of items to reduce by * @param reduceBy reduceBy interface * @return the final value */ public static double reduceBy( final double[] array, ReduceBy reduceBy ) { double sum = 0; for ( double 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. * * @param array array of items to reduce by * @param reduceBy reduceBy interface * @return the final value */ public static double reduceBy( final double[] array, ReduceBy reduceBy ) { double sum = 0; for ( double v : array ) { sum = reduceBy.reduce(sum, v); } return sum; }
/** * * @param array array of items to reduce by * @param length where to end in the array * @param reduceBy the function to do the reduce by * @return the reduction */ public static double reduceBy( final double[] array, final int length, ReduceBy reduceBy ) { double sum = 0; for (int index = 0; index < length; index++) { double v = array[index]; sum = reduceBy.reduce(sum, v); } return sum; }
/** * * @param array array of items to reduce by * @param length where to end in the array * @param reduceBy the function to do the reduce by * @return the reduction */ public static double reduceBy( final double[] array, final int length, ReduceBy reduceBy ) { double sum = 0; for (int index = 0; index < length; index++) { double v = array[index]; sum = reduceBy.reduce(sum, v); } return sum; }