Add XML documentation for combinatorics methods in EnumerableExtensions

This commit is contained in:
Sebastian Lindemeier committed 2026-12-02 10:25:50 +01:00
1 parent fefdc59bd8
commit 9907908381
1 file changed
+36 -3
@@ -7,6 +7,15 @@ namespace AdventOfCode.Extensions;
public static class EnumerableExtensions
{
/// <summary>
/// Generates all unique combinations of the specified length from the sequence, preserving the source order within each combination.
/// Each source element can be selected at most once in a generated combination.
/// If <paramref name="count"/> is greater than the number of elements in <paramref name="values"/>, no combinations are returned.
/// </summary>
/// <typeparam name="TValue">The type of elements in the source sequence.</typeparam>
/// <param name="values">The sequence whose elements are used to build the combinations.</param>
/// <param name="count">The length of each generated combination.</param>
/// <returns>A sequence of arrays containing the combinations from <paramref name="values"/>.</returns>
public static IEnumerable<TValue[]> Combinations<TValue>(this IEnumerable<TValue> values, int count)
{
var pool = values.ToArray();
@@ -37,7 +46,15 @@ public static class EnumerableExtensions
yield return GetCombination(indices, pool);
}
}
/// <summary>
/// Generates combinations of the specified length from the sequence, allowing the same source element to be selected multiple times.
/// If <paramref name="count"/> is greater than the number of elements in <paramref name="values"/>, no combinations are returned.
/// </summary>
/// <typeparam name="TValue">The type of elements in the source sequence.</typeparam>
/// <param name="values">The sequence whose elements are used to build the repeated combinations.</param>
/// <param name="count">The length of each generated combination.</param>
/// <returns>A sequence of arrays containing the repeated combinations from <paramref name="values"/>.</returns>
public static IEnumerable<TValue[]> CombinationsWithRepeats<TValue>(this IEnumerable<TValue> values, int count)
{
var pool = values.ToArray();
@@ -68,7 +85,15 @@ public static class EnumerableExtensions
yield return GetCombination(indices, pool);
}
}
/// <summary>
/// Generates ordered permutations of the specified length from the sequence, permitting the same source element to appear multiple times in a selection.
/// If <paramref name="count"/> is greater than the number of elements in <paramref name="values"/>, no selections are returned.
/// </summary>
/// <typeparam name="TValue">The type of elements in the source sequence.</typeparam>
/// <param name="values">The sequence whose elements are used to build the repeated permutations.</param>
/// <param name="count">The length of each generated permutation.</param>
/// <returns>A sequence of arrays containing the ordered repeated permutations from <paramref name="values"/>.</returns>
public static IEnumerable<TValue[]> PermutationsWithRepeats<TValue>(this IEnumerable<TValue> values, int count)
{
var pool = values.ToArray();
@@ -96,7 +121,15 @@ public static class EnumerableExtensions
yield return GetCombination(indices, pool);
}
}
/// <summary>
/// Enumerates ordered permutations of the specified length from the sequence, without reusing the same source position within a permutation.
/// If <paramref name="count"/> is greater than the number of elements in <paramref name="values"/>, the returned sequence is empty.
/// </summary>
/// <typeparam name="TValue">The type of elements in the sequence.</typeparam>
/// <param name="values">The sequence from which to create permutations.</param>
/// <param name="count">The number of elements to include in each permutation.</param>
/// <returns>A sequence of arrays containing the ordered permutations from <paramref name="values"/>.</returns>
public static IEnumerable<TValue[]> Permutations<TValue>(this IEnumerable<TValue> values, int count)
{
var pool = values.ToArray();