Add XML documentation for combinatorics methods in EnumerableExtensions
This commit is contained in:
1 parent
fefdc59bd8
commit
9907908381
1 file changed
+33
@@ -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();
|
||||
@@ -38,6 +47,14 @@ public static class EnumerableExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <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();
|
||||
@@ -69,6 +86,14 @@ public static class EnumerableExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <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();
|
||||
@@ -97,6 +122,14 @@ public static class EnumerableExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <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();
|
||||
|
||||
Reference in new issue
Block a user