public final class Iterators
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.Iterator<java.util.List<T>> |
partition(java.util.Iterator<T> iterator,
int size)
Divides an iterator into unmodifiable sublists of the given size (the final
list may be smaller).
|
static <T> java.util.Iterator<java.util.List<T>> |
partition(java.util.List<T> list,
int size)
Partition List,better performance with RandomAccess type.
|
public static <T> java.util.Iterator<java.util.List<T>> partition(java.util.Iterator<T> iterator,
int size)
[a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e]] -- an outer iterator containing two inner lists of
three and two elements, all in the original order.
The returned lists implement RandomAccess.
iterator - the iterator to return a partitioned view ofsize - the desired size of each partition (the last may be smaller)iterator divided into partitionsjava.lang.IllegalArgumentException - if size is nonpositivepublic static <T> java.util.Iterator<java.util.List<T>> partition(java.util.List<T> list,
int size)
T - Element type.list - Data.size - Chunk size.