public static < T > double reduceBy ( final double [ ] array , T object ) { if ( object . getClass ( ) . isAnonymousClass ( ) ) { return reduceByR ( array , object ) ; } try { ConstantCallSite callSite = Invoker . invokeReducerLongIntReturnLongMethodHandle ( object ) ; MethodHandle methodHandle = callSite . dynamicInvoker ( ) ; try { double sum = 0 ; for ( double v : array ) { sum = ( double ) methodHandle . invokeExact ( sum , v ) ; } return sum ; } catch ( Throwable throwable ) { return handle ( Long . class , throwable , "Unable to perform reduceBy" ) ; } } catch ( Exception ex ) { return reduceByR ( array , object ) ; } }
Reduce by functional support for int arrays .