sliding window

The most recent k items of a sequence or stream, which moves forward one item at a time as new data arrives.

In more detail

A deque with a length cap or a ring buffer holds a sliding window in memory proportional to k. Moving averages, per-window maximums and rate limits over recent requests are all computed this way.

Examples

The course computes a moving average over a ring buffer and a window maximum with a deque.
A threshold rule keeps recent event times for each source in a queue, drops those older than the window, and alerts when the queue reaches the limit.

Related terms

Taught in

References