/**
* Compute a histogram with number of finishers per bucket of time where the
* size of the bucket is indicated by <code>seconds</code>.
*/
private static ArrayOfInt computeHistogram(ArrayOf<Runner> runners, int seconds) {
final ArrayOfInt hist = Collections.arrayOfInt();
for (int i = 0, n = runners.length(); i < n; ++i) {
int index = runners.get(i).time() / seconds;
hist.set(index, hist.isSet(index) ? hist.get(index) + 1 : 1);
}
int sum = 0;
for (int i = 0, n = hist.length(); i < n; ++i) {
if (hist.isSet(i)) {
sum += hist.get(i);
}
hist.set(i, sum);
}
return hist;
}