windowed method
Returns a new lazy Iterable of windows of the given size sliding along
this collection with the given step.
The last window may have less elements than the given size.
Both size and step must be positive and can be greater than the number
of elements in this collection.
Implementation
Iterable<Iterable<E>> windowed(
int size, {
int step = 1,
bool partialWindows = false,
}) sync* {
ArgumentErrorUtils.checkPositiveInt(size, name: "size");
ArgumentErrorUtils.checkPositiveInt(step, name: "step");
final gap = step - size;
if (gap >= 0) {
yield* _withPositiveGap(
gap: gap,
size: size,
partialWindows: partialWindows,
);
} else {
yield* _withNegativeGap(
step: step,
size: size,
partialWindows: partialWindows,
);
}
}