Skip to content

Instantly share code, notes, and snippets.

@messo
Created January 31, 2016 19:37
Show Gist options
  • Save messo/7f8d2a2e4d9b1d5f5d59 to your computer and use it in GitHub Desktop.
Save messo/7f8d2a2e4d9b1d5f5d59 to your computer and use it in GitHub Desktop.
// ---------
// 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