Divides an iterator into unmodifiable sublists of the given size, padding the final iterator with null values if necessary. For example, partitioning an iterator containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e, null]] -- an outer iterator containing two
(Iterator<T> iterator, int size)
| 570 | * @throws IllegalArgumentException if {@code size} is nonpositive |
| 571 | */ |
| 572 | public static <T> UnmodifiableIterator<List<T>> paddedPartition(Iterator<T> iterator, int size) { |
| 573 | return partitionImpl(iterator, size, true); |
| 574 | } |
| 575 | |
| 576 | private static <T> UnmodifiableIterator<List<T>> partitionImpl( |
| 577 | final Iterator<T> iterator, final int size, final boolean pad) { |