WindowRightExtensionWindowRightTSource Method |
Creates a right-aligned sliding window over the source sequence
of a given size.
Namespace:
MoreLinq.Extensions
Assembly:
MoreLinq (in MoreLinq.dll) Version: 3.0.0
Syntax public static IEnumerable<IList<TSource>> WindowRight<TSource>(
this IEnumerable<TSource> source,
int size
)
<ExtensionAttribute>
Public Shared Function WindowRight(Of TSource) (
source As IEnumerable(Of TSource),
size As Integer
) As IEnumerable(Of IList(Of TSource))
public:
[ExtensionAttribute]
generic<typename TSource>
static IEnumerable<IList<TSource>^>^ WindowRight(
IEnumerable<TSource>^ source,
int size
)
[<ExtensionAttribute>]
static member WindowRight :
source : IEnumerable<'TSource> *
size : int -> IEnumerable<IList<'TSource>>
Parameters
- source
- Type: System.Collections.GenericIEnumerableTSource
The sequence over which to create the sliding window. - size
- Type: SystemInt32
Size of the sliding window.
Type Parameters
- TSource
-
The type of the elements of source.
Return Value
Type:
IEnumerableIListTSourceA sequence representing each sliding window.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableTSource. 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).
Remarks
A window can contain fewer elements than size,
especially as it slides over the start of the sequence.
This operator uses deferred execution and streams its results.
Examples Console.WriteLine(
Enumerable
.Range(1, 5)
.WindowRight(3)
.Select(w => "AVG(" + w.ToDelimitedString(",") + ") = " + w.Average())
.ToDelimitedString(Environment.NewLine));
See Also