Table of Contents

Class CollectionExtensions

Namespace
MLEM.Misc
Assembly
MLEM.dll

A set of extensions for dealing with collections of various kinds

public static class CollectionExtensions
Inheritance
CollectionExtensions
Inherited Members

Methods

Append<T>(IEnumerable<T>, T)

Appends a value to the end of the sequence.

public static IEnumerable<T> Append<T>(this IEnumerable<T> source, T element)

Parameters

source IEnumerable<T>

A sequence of values.

element T

The value to append to source.

Returns

IEnumerable<T>

A new sequence that ends with element.

Type Parameters

T

The type of the elements of source.

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>>). Given the input set {{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

things IEnumerable<IEnumerable<T>>

The different sets to be combined

Returns

IEnumerable<IEnumerable<T>>

All combinations of set items as described

Type Parameters

T

The 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>>). Given the input set {{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

things IEnumerable<IEnumerable<T>>

The different sets to be combined

Returns

IEnumerable<IEnumerable<int>>

All combinations of set items as described

Type Parameters

T

The type of the items in the sets

Prepend<T>(IEnumerable<T>, T)

Prepends a value to the beginning of the sequence.

public static IEnumerable<T> Prepend<T>(this IEnumerable<T> source, T element)

Parameters

source IEnumerable<T>

A sequence of values.

element T

The value to prepend to source.

Returns

IEnumerable<T>

A new sequence that begins with element.

Type Parameters

T

The type of the elements of source.