Wintellect.PowerCollections Namespace
Algorithms Class
Algorithms Methods
GhostDoc Pro Sample Help File

Algorithms..::..CartesianProduct<(Of <(<'TFirst, TSecond>)>)> Method

Computes the cartestian product of two collections: all possible pairs of items, with the first item taken from the first collection and the second item taken from the second collection. If the first collection has N items, and the second collection has M items, the cartesian product will have N * M pairs.

Namespace:  Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax


public static IEnumerable<Pair<TFirst, TSecond>> CartesianProduct<TFirst, TSecond>(
	IEnumerable<TFirst> first,
	IEnumerable<TSecond> second
)
Public Shared Function CartesianProduct(Of TFirst, TSecond) ( _
	first As IEnumerable(Of TFirst), _
	second As IEnumerable(Of TSecond) _
) As IEnumerable(Of Pair(Of TFirst, TSecond))
public:
generic<typename TFirst, typename TSecond>
static IEnumerable<Pair<TFirst, TSecond>^>^ CartesianProduct(
	IEnumerable<TFirst>^ first, 
	IEnumerable<TSecond>^ second
)

Type Parameters

TFirst
The type of items in the first collection.
TSecond
The type of items in the second collection.

Parameters

first
Type: IEnumerable<(Of <(<'TFirst>)>)>
The first collection.
second
Type: IEnumerable<(Of <(<'TSecond>)>)>
The second collection.

Return Value

An IEnumerable<Pair<TFirst, TSecond>> that enumerates the cartesian product of the two collections.