Time window

A state to represent a window with fixed time capacity.

Every value pushed onto the state has an associated time, and time is taken to be strictly increasing. The window is taken to be fixed in terms of time duration rather than a fixed number of values.


State necessary for accumulation over a rolling window of fixed size, in terms of time.

When presented with a new time t', we guarantee that all times t remaining in the window satisfy:

t > t' - w

That is, at time t' this window represents the open-closed time interval (t' - w, t']

We require that window be of a type that, when added to a Time, gives a Time.


  • window_state::WindowedAssociativeOp{Value}: The underlying general-window state.
  • window::TimeDiff: The window, as a difference between two times.
  • times::Deque{Time}: The same length as the values stored in window_state, and representing the times of those observations.
  • window_full::Bool: For internal use - will be set to true once a point has dropped out of the window.
update_state!(state::TimeWindowAssociativeOp, time, value) -> state

Add the specified value to the state with associated time, and drop any values that are no longer in the time window.


  • state::TimeWindowAssociativeOp:
  • time: The time to which value corresponds.
  • value: The value to add to the window.


  • ::TimeWindowAssociativeOp: state, which has been mutated.

Returns true iff the given state has had at least one value drop out of the window, indicating that the window is now full.