Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vto lead #12

Merged
merged 3 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions MoreLinq/Extensions.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,37 @@ public static T LastOrDefault<T>(this IExtremaEnumerable<T> source)
[GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")]
public static partial class LeadExtension
{

/// <summary>
/// Produces a sequence of tuple containing a pair of elements separated by a positive offset.
/// </summary>
/// <remarks>
/// This operator evaluates in a deferred and streaming manner.<br/>
/// For elements of the sequence that are less than <paramref name="offset"/> items from the end,
/// default(T) is used as the lead value.<br/>
/// </remarks>
/// <typeparam name="TSource">The type of the elements in the source sequence</typeparam>
/// <param name="source">The sequence over which to evaluate Lead</param>
/// <param name="offset">The offset (expressed as a positive number) by which to lead each element of the sequence</param>
/// <returns>The produced sequence of tuple</returns>

public static IEnumerable<(TSource Item, TSource OffsetItem)> Lead<TSource>(this IEnumerable<TSource> source, int offset)
=> MoreEnumerable.Lead(source, offset);

/// <summary>
/// Produces a sequence of tuple containing a pair of elements separated by a positive offset.
/// </summary>
/// <remarks>
/// This operator evaluates in a deferred and streaming manner.<br/>
/// </remarks>
/// <typeparam name="TSource">The type of the elements in the source sequence</typeparam>
/// <param name="source">The sequence over which to evaluate Lead</param>
/// <param name="offset">The offset (expressed as a positive number) by which to lead each element of the sequence</param>
/// <param name="defaultLeadValue">A default value supplied for the leading element when none is available</param>
/// <returns>The produced sequence of tuple</returns>

public static IEnumerable<(TSource Item, TSource OffsetItem)> Lead<TSource>(this IEnumerable<TSource> source, int offset, TSource defaultLeadValue)
=> MoreEnumerable.Lead(source, offset, defaultLeadValue);
/// <summary>
/// Produces a projection of a sequence by evaluating pairs of elements separated by a positive offset.
/// </summary>
Expand Down
35 changes: 35 additions & 0 deletions MoreLinq/Lead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,40 @@ public static IEnumerable<TResult> Lead<TSource, TResult>(this IEnumerable<TSour
yield return resultSelector(leadQueue.Dequeue(), defaultLeadValue);
}
}

/// <summary>
/// Produces a sequence of tuple containing a pair of elements separated by a positive offset.
/// </summary>
/// <remarks>
/// This operator evaluates in a deferred and streaming manner.<br/>
/// For elements of the sequence that are less than <paramref name="offset"/> items from the end,
/// default(T) is used as the lead value.<br/>
/// </remarks>
/// <typeparam name="TSource">The type of the elements in the source sequence</typeparam>
/// <param name="source">The sequence over which to evaluate Lead</param>
/// <param name="offset">The offset (expressed as a positive number) by which to lead each element of the sequence</param>
/// <returns>The produced sequence of tuple</returns>

public static IEnumerable<(TSource Item, TSource OffsetItem)> Lead<TSource>(this IEnumerable<TSource> source, int offset)
{
return Lead(source, offset, default, ValueTuple.Create);
}

/// <summary>
/// Produces a sequence of tuple containing a pair of elements separated by a positive offset.
/// </summary>
/// <remarks>
/// This operator evaluates in a deferred and streaming manner.<br/>
/// </remarks>
/// <typeparam name="TSource">The type of the elements in the source sequence</typeparam>
/// <param name="source">The sequence over which to evaluate Lead</param>
/// <param name="offset">The offset (expressed as a positive number) by which to lead each element of the sequence</param>
/// <param name="defaultLeadValue">A default value supplied for the leading element when none is available</param>
/// <returns>The produced sequence of tuple</returns>

public static IEnumerable<(TSource Item, TSource OffsetItem)> Lead<TSource>(this IEnumerable<TSource> source, int offset, TSource defaultLeadValue)
{
return Lead(source, offset, default, ValueTuple.Create);
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ This method has 2 overloads.
Produces a projection of a sequence by evaluating pairs of elements separated
by a positive offset.

This method has 2 overloads.
This method has 4 overloads.

### LeftJoin

Expand Down