slide

fnauto slide(Flag!"withPartial" f = Yes.withPartial, Source)(Source source, size_t windowSize, size_t stepSize = 1) if (isForwardRange!Source)

A fixed-sized sliding window iteration of size windowSize over a source range by a custom stepSize.

The Source range must be at least a ForwardRange and the windowSize must be greater than zero.

For windowSize = 1 it splits the range into single element groups (aka unflatten) For windowSize = 2 it is similar to zip(source, source.save.dropOne).

Parameters

fWhether the last element has fewer elements than windowSize it should be be ignored (No.withPartial) or added (Yes.withPartial)
sourceRange from which the slide will be selected
windowSizeSliding window size
stepSizeSteps between the windows (by default 1)

Returns

Range of all sliding windows with propagated bi-directionality,

forwarding, random access, and slicing.

Note

To avoid performance overhead, bi-directionality

is only available when hasSlicing and hasLength are true.

See Also