Sliding Window

noun

say it: “SLY-ding WIN-doh” /ˈslaɪdɪŋ ˈwɪndoʊ/

Looking only at the most recent items or seconds of a stream, so new ones join and old ones leave.

What is a sliding window?

A sliding window is a way to work on only the most recent part of a stream: the last 10 seconds of messages, the last 50 trades, the last 20 songs. New items join at the back and items too old to count leave from the front, which is a queue's job, so each item is added and removed once: O(n) for the whole stream. Spam guards, login limits and moving averages all use one.

In a sentence

  • “The spam guard counts each sender's messages in a 10-second sliding window, forgetting older ones as time moves on.”

Level: Freelancer · More Data Structures terms at this level

Updated