Chunk by range

This commit is contained in:
M66B
2024-10-24 20:35:42 +02:00
parent 20d3449d32
commit 5e74805997
2 changed files with 18 additions and 1 deletions

View File

@@ -3789,6 +3789,8 @@ public class Helper {
}
static <T> List<List<T>> chunkList(List<T> list, int size) {
if (list == null || list.isEmpty())
return new ArrayList<>();
List<List<T>> result = new ArrayList<>(list.size() / size);
for (int i = 0; i < list.size(); i += size)
result.add(list.subList(i, i + size < list.size() ? i + size : list.size()));