Fix list partitioning helper.

Fixes #2934

// FREEBIE
This commit is contained in:
Moxie Marlinspike
2015-04-12 10:07:30 -07:00
parent 77e846d24e
commit b9541a65b0
2 changed files with 85 additions and 3 deletions

View File

@@ -201,10 +201,9 @@ public class Util {
List<List<T>> results = new LinkedList<>();
for (int index=0;index<list.size();index+=partitionSize) {
int offset = index * partitionSize;
int subListSize = Math.min(partitionSize, list.size() - offset);
int subListSize = Math.min(partitionSize, list.size() - index);
results.add(list.subList(offset, offset + subListSize));
results.add(list.subList(index, index + subListSize));
}
return results;