windowedAndTransform<R> method
Returns a Iterable of results of applying the given transform
function
to an each Iterable representing a view over the window of the given
size
sliding along this collection with the given step
.
Implementation
Iterable<R> windowedAndTransform<R>({
required int size,
required R Function(Iterable<E> chunk) transform,
int step = 1,
bool partialWindows = false,
}) {
if (size <= 0) {
throw ArgumentError.value(size, 'size', 'must be greater than zero');
}
if (step <= 0) {
throw ArgumentError.value(step, 'step', 'must be greater than zero');
}
final length = partialWindows
? (this.length / step).ceil()
: (this.length - size) ~/ step + 1;
return Iterable.generate(
length,
(index) => transform(skip(index * step).take(size)),
);
}