com.intellij.openapi.vcs.CollectionSplitter Maven / Gradle / Ivy
package com.intellij.openapi.vcs;
import java.util.*;
public class CollectionSplitter {
private final int myBunchSize;
public CollectionSplitter(int bunchSize) {
myBunchSize = bunchSize;
}
public List> split(final Collection in) {
if (in.size() <= myBunchSize) return Collections.>singletonList(new ArrayList(in));
final List> result = new LinkedList>();
List piece = new LinkedList();
for (T path : in) {
if (myBunchSize == piece.size()) {
result.add(piece);
piece = new LinkedList();
}
piece.add(path);
}
if (! piece.isEmpty()) {
result.add(piece);
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy