# 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.

`AssociativeWindowAggregation.TimeWindowAssociativeOp`

— Type```
TimeWindowAssociativeOp{Value,Op,Op!,Time}(window::TimeDiff)
TimeWindowAssociativeOp{Value,Op,Time}(window::TimeDiff)
```

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`

.

**Fields**

`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.

`AssociativeWindowAggregation.update_state!`

— Method`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.

**Arguments**

`state::TimeWindowAssociativeOp`

:`time`

: The time to which`value`

corresponds.`value`

: The value to add to the window.

**Returns**

`::TimeWindowAssociativeOp`

:`state`

, which has been mutated.

`AssociativeWindowAggregation.window_full`

— Method`window_full(state::TimeWindowAssociativeOp)::Bool`

Returns true iff the given `state`

has had at least one value drop out of the window, indicating that the window is now full.