MinimumOnSlidingWindow<'T> Type

Given a sequence of numeric values that will be added to this instance, the algorithm keeps track of the minimum value of the last numberOfItems added values. The name of the algorithm is ascending minima algorithm, one of the algorithms in the class of "minimum on a sliding window algorithms".

Constructors

Constructor Description

MinimumOnSlidingWindow(numberOfItems, startValue)

Full Usage: MinimumOnSlidingWindow(numberOfItems, startValue)

Parameters:
    numberOfItems : int - The number of items N. The algorithm evaluates the minimum of the last N items that where added to this instance.
    startValue : 'T - The start value. This is the first entry to add to the instance. Thus, the MinimumOnSlidingWindow.MinimumValue always return a valid value.

Initializes a new instance of the MinimumOnSlidingWindow class.

numberOfItems : int

The number of items N. The algorithm evaluates the minimum of the last N items that where added to this instance.

startValue : 'T

The start value. This is the first entry to add to the instance. Thus, the MinimumOnSlidingWindow.MinimumValue always return a valid value.

Instance members

Instance member Description

this.Add

Full Usage: this.Add

Parameters:
    val : 'T - The val.

Adds the specified value to the window, and removes the item that is now expired from the window.

val : 'T

The val.

this.MinimumValue

Full Usage: this.MinimumValue

Returns: 'T

Gets the current minimum value of the window.

Returns: 'T

this.Remove

Full Usage: this.Remove

Removes the expired element from this window. Note: normally this is done when you use the MinimumOnSlidingWindow.Add function, thus there is no need to call this function separately. When the minimum item is the item that is expired now, then this function will remove this item from the collection and sets the current minimum to the next greater item.