padded Partition
Divides an iterable into unmodifiable sublists of the given size, padding the final iterable with null values if necessary. For example, partitioning an iterable containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e, null]] -- an outer iterable containing two inner lists of three elements each, all in the original order.
Iterators returned by the returned iterable do not support the remove method.
Return
an iterable of unmodifiable lists containing the elements of this divided into partitions (the final iterable may have trailing null elements)
See also
Parameters
the desired size of each partition
Throws
if size is non-positive
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 inner lists of three elements each, all in the original order.
The returned lists implement java.util.RandomAccess.
Note: The current implementation eagerly allocates storage for size elements. As a consequence, passing values like Int.MAX_VALUE can lead to an OutOfMemoryError.
Return
an iterator of immutable lists containing the elements of iterator divided into partitions (the final iterable may have trailing null elements)
See also
Parameters
the desired size of each partition
Throws
if size is non-positive