Click or drag to resize

GeneratorWindowTSource Method

Makes a generator that generates a moving window of elements over a given generator.

Namespace:  Gamelogic.Extensions.Algorithms
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
C#
public static IGenerator<TSource[]> Window<TSource>(
	this IGenerator<TSource> source,
	int windowSize
)

Parameters

source
Type: Gamelogic.Extensions.AlgorithmsIGeneratorTSource
The source generator.
windowSize
Type: SystemInt32
Size of the window.

Type Parameters

TSource
The type of the source generator.

Return Value

Type: IGeneratorTSource
A new generator.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IGeneratorTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionwindowSize;Argument must be positive.
Examples
In the following example,
var generator = Generator.Count(4).Window(2);
the generator will generate (0 1) (1 2) (2 3) (3 0) (0 1)... The window of size 2 move one element (of the original generator) at a time. The following is an implementation of a box blur on the given sequence:
public static IGenerator<float> BoxBlur(IGenerator<float> generator)
{
    return generator.Window(3).Select(w => (w[0] + w[1] + w[2])/3f);
}
See Also