Class CollectionExtensions
A set of extensions for dealing with collections of various kinds
public static class CollectionExtensions
- Inheritance
-
CollectionExtensions
- Inherited Members
Methods
Combinations<T>(IEnumerable<IEnumerable<T>>)
This method returns a set of possible combinations of n items from n different sets, where the order of the items in each combination is based on the order of the input sets.
For a version of this method that returns indices rather than entries, see IndexCombinations<T>(IEnumerable<IEnumerable<T>>).
{{1, 2, 3}, {A, B}, {+, -}}, the returned set would contain the following sets:
{1, A, +}, {1, A, -}, {1, B, +}, {1, B, -},
{2, A, +}, {2, A, -}, {2, B, +}, {2, B, -},
{3, A, +}, {3, A, -}, {3, B, +}, {3, B, -}
public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<IEnumerable<T>> things)
Parameters
thingsIEnumerable<IEnumerable<T>>The different sets to be combined
Returns
- IEnumerable<IEnumerable<T>>
All combinations of set items as described
Type Parameters
TThe type of the items in the sets
IndexCombinations<T>(IEnumerable<IEnumerable<T>>)
This method returns a set of possible combinations of n indices of items from n different sets, where the order of the items' indices in each combination is based on the order of the input sets.
For a version of this method that returns entries rather than indices, see Combinations<T>(IEnumerable<IEnumerable<T>>).
{{1, 2, 3}, {A, B}, {+, -}}, the returned set would contain the following sets:
{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1},
{1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1},
{2, 0, 0}, {2, 0, 1}, {2, 1, 0}, {2, 1, 1}
public static IEnumerable<IEnumerable<int>> IndexCombinations<T>(this IEnumerable<IEnumerable<T>> things)
Parameters
thingsIEnumerable<IEnumerable<T>>The different sets to be combined
Returns
- IEnumerable<IEnumerable<int>>
All combinations of set items as described
Type Parameters
TThe type of the items in the sets