* @param sample The array in which to return the sample.
* @param times The times of three events, for measuring performance.
*/
private static void sample1(ScoredDocIDs collection, int collectionSize, int[] sample, long[] times)
throws IOException {
ScoredDocIDsIterator it = collection.iterator();
if (RandomSample.returnTimings) {
times[0] = System.currentTimeMillis();
}
int sampleSize = sample.length;
int prime = RandomSample.findGoodStepSize(collectionSize, sampleSize);
int mod = prime % collectionSize;
if (RandomSample.returnTimings) {
times[1] = System.currentTimeMillis();
}
int sampleCount = 0;
int index = 0;
for (; sampleCount < sampleSize;) {
if (index + mod < collectionSize) {
for (int i = 0; i < mod; i++, index++) {
it.next();
}
} else {
index = index + mod - collectionSize;
it = collection.iterator();
for (int i = 0; i < index; i++) {
it.next();
}
}
sample[sampleCount++] = it.getDocID();
}
if (RandomSample.returnTimings) {
times[2] = System.currentTimeMillis();
}
} // end RandomSample.sample1()