private static int mergeSameBuckets ( double [ ] values , double [ ] weights , int nextIndex ) { sort ( values , weights , nextIndex ) ; int current = 0 ; for ( int i = 1 ; i < nextIndex ; i ++ ) { if ( values [ current ] == values [ i ] ) { weights [ current ] += weights [ i ] ; } else { current ++ ; values [ current ] = values [ i ] ; weights [ current ] = weights [ i ] ; } } return current + 1 ; }
Simple pass that merges entries with the same value