fn window(comptime T: type, buffer: []const T, size: usize, advance: usize) WindowIterator(T)

Returns an iterator with a sliding window of slices for buffer. The sliding window has length size and on every iteration moves forward by advance.

Extract data for moving average with: window(u8, "abcdefg", 3, 1) will return slices “abc”, “bcd”, “cde”, “def”, “efg”, null, in that order.

Chunk or split every N items with: window(u8, "abcdefg", 3, 3) will return slices “abc”, “def”, “g”, null, in that order.

Pick every even index with: window(u8, "abcdefg", 1, 2) will return slices “a”, “c”, “e”, “g” null, in that order.

The size and advance must be not be zero.

Parameters

T: type,
buffer: []const T,
size: usize,
advance: usize,