Skip to content

Commit

Permalink
Fix some doc comments
Browse files Browse the repository at this point in the history
Fixes:

- formatting
- inconsistencies
- grammar
- wrapping
- code examples

for following operators:

- Interleave
- Lag
- Lead
- Permutations
- Slice
- SortedMerge
- Subsets
- Window
  • Loading branch information
atifaziz committed Jan 30, 2023
1 parent f6bc02a commit 283c44c
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 251 deletions.
315 changes: 193 additions & 122 deletions MoreLinq/Extensions.g.cs

Large diffs are not rendered by default.

33 changes: 20 additions & 13 deletions MoreLinq/Interleave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,31 @@ namespace MoreLinq
public static partial class MoreEnumerable
{
/// <summary>
/// Interleaves the elements of two or more sequences into a single sequence, skipping sequences as they are consumed
/// Interleaves the elements of two or more sequences into a single sequence, skipping
/// sequences as they are consumed.
/// </summary>
/// <typeparam name="T">The type of the elements of the source sequences.</typeparam>
/// <param name="sequence">The first sequence in the interleave group.</param>
/// <param name="otherSequences">The other sequences in the interleave group.</param>
/// <returns>A sequence of interleaved elements from all of the source sequences.</returns>
/// <remarks>
/// Interleave combines sequences by visiting each in turn, and returning the first element of each, followed
/// by the second, then the third, and so on. So, for example:<br/>
/// <para>
/// Interleave combines sequences by visiting each in turn, and returning the first element
/// of each, followed by the second, then the third, and so on. So, for example:</para>
/// <code><![CDATA[
/// {1,1,1}.Interleave( {2,2,2}, {3,3,3} ) => { 1,2,3,1,2,3,1,2,3 }
/// var xs = new[] { 1, 1, 1 }.Interleave(new[] { 2, 2, 2 }, new[] { 3, 3, 3 });
/// // xs = { 1, 2, 3, 1, 2, 3, 1, 2, 3 }
/// ]]></code>
/// This operator behaves in a deferred and streaming manner.<br/>
/// When sequences are of unequal length, this method will skip those sequences that have been fully consumed
/// and continue interleaving the remaining sequences.<br/>
/// The sequences are interleaved in the order that they appear in the <paramref name="otherSequences"/>
/// collection, with <paramref name="sequence"/> as the first sequence.
/// <para>
/// This operator behaves in a deferred and streaming manner.</para>
/// <para>
/// When sequences are of unequal length, this method will skip those sequences that have
/// been fully consumed and continue interleaving the remaining sequences.</para>
/// <para>
/// The sequences are interleaved in the order that they appear in the <paramref
/// name="otherSequences"/> collection, with <paramref name="sequence"/> as the first
/// sequence.</para>
/// </remarks>
/// <typeparam name="T">The type of the elements of the source sequences</typeparam>
/// <param name="sequence">The first sequence in the interleave group</param>
/// <param name="otherSequences">The other sequences in the interleave group</param>
/// <returns>A sequence of interleaved elements from all of the source sequences</returns>

public static IEnumerable<T> Interleave<T>(this IEnumerable<T> sequence, params IEnumerable<T>[] otherSequences)
{
Expand Down
50 changes: 32 additions & 18 deletions MoreLinq/Lag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,26 @@ namespace MoreLinq
public static partial class MoreEnumerable
{
/// <summary>
/// Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset.
/// Produces a projection of a sequence by evaluating pairs of elements separated by a
/// negative offset.
/// </summary>
/// <typeparam name="TSource">The type of the elements of the source sequence.</typeparam>
/// <typeparam name="TResult">The type of the elements of the result sequence.</typeparam>
/// <param name="source">The sequence over which to evaluate lag.</param>
/// <param name="offset">The offset (expressed as a positive number) by which to lag each
/// value of the sequence.</param>
/// <param name="resultSelector">A projection function which accepts the current and lagged
/// items (in that order) and returns a result.</param>
/// <returns>
/// A sequence produced by projecting each element of the sequence with its lagged
/// pairing.</returns>
/// <remarks>
/// This operator evaluates in a deferred and streaming manner.<br/>
/// For elements prior to the lag offset, <c>default(T)</c> is used as the lagged value.<br/>
/// <para>
/// This operator evaluates in a deferred and streaming manner.</para>
/// <para>
/// For elements prior to the lag offset, <c>default(T)</c> is used as the lagged
/// value.</para>
/// </remarks>
/// <typeparam name="TSource">The type of the elements of the source sequence</typeparam>
/// <typeparam name="TResult">The type of the elements of the result sequence</typeparam>
/// <param name="source">The sequence over which to evaluate lag</param>
/// <param name="offset">The offset (expressed as a positive number) by which to lag each value of the sequence</param>
/// <param name="resultSelector">A projection function which accepts the current and lagged items (in that order) and returns a result</param>
/// <returns>A sequence produced by projecting each element of the sequence with its lagged pairing</returns>

public static IEnumerable<TResult> Lag<TSource, TResult>(this IEnumerable<TSource> source, int offset, Func<TSource, TSource?, TResult> resultSelector)
{
Expand All @@ -47,18 +55,24 @@ public static IEnumerable<TResult> Lag<TSource, TResult>(this IEnumerable<TSourc
}

/// <summary>
/// Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset.
/// Produces a projection of a sequence by evaluating pairs of elements separated by a
/// negative offset.
/// </summary>
/// <typeparam name="TSource">The type of the elements of the source sequence.</typeparam>
/// <typeparam name="TResult">The type of the elements of the result sequence.</typeparam>
/// <param name="source">The sequence over which to evaluate lag.</param>
/// <param name="offset">The offset (expressed as a positive number) by which to lag each
/// value of the sequence.</param>
/// <param name="defaultLagValue">A default value supplied for the lagged value prior to the
/// lag offset.</param>
/// <param name="resultSelector">A projection function which accepts the current and lagged
/// items (in that order) and returns a result.</param>
/// <returns>
/// A sequence produced by projecting each element of the sequence with its lagged
/// pairing.</returns>
/// <remarks>
/// This operator evaluates in a deferred and streaming manner.<br/>
/// This operator evaluates in a deferred and streaming manner.
/// </remarks>
/// <typeparam name="TSource">The type of the elements of the source sequence</typeparam>
/// <typeparam name="TResult">The type of the elements of the result sequence</typeparam>
/// <param name="source">The sequence over which to evaluate lag</param>
/// <param name="offset">The offset (expressed as a positive number) by which to lag each value of the sequence</param>
/// <param name="defaultLagValue">A default value supplied for the lagged value prior to the lag offset</param>
/// <param name="resultSelector">A projection function which accepts the current and lagged items (in that order) and returns a result</param>
/// <returns>A sequence produced by projecting each element of the sequence with its lagged pairing</returns>

public static IEnumerable<TResult> Lag<TSource, TResult>(this IEnumerable<TSource> source, int offset, TSource defaultLagValue, Func<TSource, TSource, TResult> resultSelector)
{
Expand Down
51 changes: 32 additions & 19 deletions MoreLinq/Lead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,26 @@ namespace MoreLinq
public static partial class MoreEnumerable
{
/// <summary>
/// Produces a projection of a sequence by evaluating pairs of elements separated by a positive offset.
/// Produces a projection of a sequence by evaluating pairs of elements separated by a
/// positive offset.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TResult">The type of the elements in the result 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="resultSelector">A projection function which accepts the current and
/// subsequent (lead) element (in that order) and produces a result.</param>
/// <returns>
/// A sequence produced by projecting each element of the sequence with its lead
/// pairing.</returns>
/// <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/>
/// <para>
/// This operator evaluates in a deferred and streaming manner.</para>
/// <para>
/// For elements of the sequence that are less than <paramref name="offset"/> items from the
/// end, <c>default(T)</c> is used as the lead value.</para>
/// </remarks>
/// <typeparam name="TSource">The type of the elements in the source sequence</typeparam>
/// <typeparam name="TResult">The type of the elements in the result 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="resultSelector">A projection function which accepts the current and subsequent (lead) element (in that order) and produces a result</param>
/// <returns>A sequence produced by projecting each element of the sequence with its lead pairing</returns>

public static IEnumerable<TResult> Lead<TSource, TResult>(this IEnumerable<TSource> source, int offset, Func<TSource, TSource?, TResult> resultSelector)
{
Expand All @@ -48,18 +55,24 @@ public static IEnumerable<TResult> Lead<TSource, TResult>(this IEnumerable<TSour
}

/// <summary>
/// Produces a projection of a sequence by evaluating pairs of elements separated by a positive offset.
/// Produces a projection of a sequence by evaluating pairs of elements separated by a
/// positive offset.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TResult">The type of the elements in the result 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>
/// <param name="resultSelector">A projection function which accepts the current and
/// subsequent (lead) element (in that order) and produces a result.</param>
/// <returns>
/// A sequence produced by projecting each element of the sequence with its lead
/// pairing.</returns>
/// <remarks>
/// This operator evaluates in a deferred and streaming manner.<br/>
/// This operator evaluates in a deferred and streaming manner.
/// </remarks>
/// <typeparam name="TSource">The type of the elements in the source sequence</typeparam>
/// <typeparam name="TResult">The type of the elements in the result 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>
/// <param name="resultSelector">A projection function which accepts the current and subsequent (lead) element (in that order) and produces a result</param>
/// <returns>A sequence produced by projecting each element of the sequence with its lead pairing</returns>

public static IEnumerable<TResult> Lead<TSource, TResult>(this IEnumerable<TSource> source, int offset, TSource defaultLeadValue, Func<TSource, TSource, TResult> resultSelector)
{
Expand Down
16 changes: 10 additions & 6 deletions MoreLinq/Permutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,21 @@ IList<T> PermuteValueSet()
/// <summary>
/// Generates a sequence of lists that represent the permutations of the original sequence.
/// </summary>
/// <typeparam name="T">The type of the elements in the sequence.</typeparam>
/// <param name="sequence">The original sequence to permute.</param>
/// <returns>
/// A sequence of lists representing permutations of the original sequence.</returns>
/// <remarks>
/// A permutation is a unique re-ordering of the elements of the sequence.<br/>
/// <para>
/// A permutation is a unique re-ordering of the elements of the sequence.</para>
/// <para>
/// This operator returns permutations in a deferred, streaming fashion; however, each
/// permutation is materialized into a new list. There are N! permutations of a sequence,
/// where N => sequence.Count().<br/>
/// where N &#8658; <c>sequence.Count()</c>.</para>
/// <para>
/// Be aware that the original sequence is considered one of the permutations and will be
/// returned as one of the results.
/// returned as one of the results.</para>
/// </remarks>
/// <typeparam name="T">The type of the elements in the sequence</typeparam>
/// <param name="sequence">The original sequence to permute</param>
/// <returns>A sequence of lists representing permutations of the original sequence</returns>

public static IEnumerable<IList<T>> Permutations<T>(this IEnumerable<T> sequence)
{
Expand Down
30 changes: 19 additions & 11 deletions MoreLinq/Slice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,28 @@ namespace MoreLinq
public static partial class MoreEnumerable
{
/// <summary>
/// Extracts a contiguous count of elements from a sequence at a particular zero-based starting index
/// Extracts a contiguous count of elements from a sequence at a particular zero-based
/// starting index.
/// </summary>
/// <typeparam name="T">The type of the elements in the source sequence.</typeparam>
/// <param name="sequence">The sequence from which to extract elements.</param>
/// <param name="startIndex">The zero-based index at which to begin slicing.</param>
/// <param name="count">The number of items to slice out of the index.</param>
/// <returns>
/// A new sequence containing any elements sliced out from the source sequence.</returns>
/// <remarks>
/// If the starting position or count specified result in slice extending past the end of the sequence,
/// it will return all elements up to that point. There is no guarantee that the resulting sequence will
/// contain the number of elements requested - it may have anywhere from 0 to <paramref name="count"/>.<br/>
/// This method is implemented in an optimized manner for any sequence implementing <c>IList{T}</c>.<br/>
/// The result of Slice() is identical to: <c>sequence.Skip(startIndex).Take(count)</c>
/// <para>
/// If the starting position or count specified result in slice extending past the end of
/// the sequence, it will return all elements up to that point. There is no guarantee that
/// the resulting sequence will contain the number of elements requested - it may have
/// anywhere from 0 to <paramref name="count"/>.</para>
/// <para>
/// This method is implemented in an optimized manner for any sequence implementing <see
/// cref="IList{T}"/>.</para>
/// <para>
/// The result of <see cref="Slice{T}"/> is identical to:
/// <c>sequence.Skip(startIndex).Take(count)</c></para>
/// </remarks>
/// <typeparam name="T">The type of the elements in the source sequence</typeparam>
/// <param name="sequence">The sequence from which to extract elements</param>
/// <param name="startIndex">The zero-based index at which to begin slicing</param>
/// <param name="count">The number of items to slice out of the index</param>
/// <returns>A new sequence containing any elements sliced out from the source sequence</returns>

public static IEnumerable<T> Slice<T>(this IEnumerable<T> sequence, int startIndex, int count)
{
Expand Down
Loading

0 comments on commit 283c44c

Please sign in to comment.