Created
January 31, 2016 19:37
-
-
Save messo/7f8d2a2e4d9b1d5f5d59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --------- | |
// VERSION 1 | |
// --------- | |
public void sum1(List<Iterator<Double>> iterators, int length) { | |
double[] data = new double[length]; | |
for (Iterator<Double> it : iterators) { | |
for (int i = 0; i < length; i++) { | |
data[i] += it.next(); | |
} | |
} | |
return data; | |
} | |
// --------- | |
// VERSION 2 | |
// --------- | |
public void sum2(List<Iterator<Double>> iterators, int length) { | |
double[] data = new double[length]; | |
for (int i = 0; i < length; i++) { | |
for (Iterator<Double> it : iterators) { | |
data[i] += it.next(); | |
} | |
} | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment