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

Algorithms..::..SetDifference<(Of <(<'T>)>)> Method (IEnumerable<(Of <(<'T>)>)>, IEnumerable<(Of <(<'T>)>)>)

Computes the set-theoretic difference of two collections. The difference of two sets is all items that appear in the first set, but not in the second. If an item appears X times in the first set, and Y times in the second set, the difference contains the item X - Y times (0 times if X < Y). The source collections are not changed. A new collection is created with the difference of the collections; the order of the items in this collection is undefined.

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

Syntax


public static IEnumerable<T> SetDifference<T>(
	IEnumerable<T> collection1,
	IEnumerable<T> collection2
)
Public Shared Function SetDifference(Of T) ( _
	collection1 As IEnumerable(Of T), _
	collection2 As IEnumerable(Of T) _
) As IEnumerable(Of T)
public:
generic<typename T>
static IEnumerable<T>^ SetDifference(
	IEnumerable<T>^ collection1, 
	IEnumerable<T>^ collection2
)

Type Parameters

T

Parameters

collection1
Type: IEnumerable<(Of <(<'T>)>)>
The first collection to difference.
collection2
Type: IEnumerable<(Of <(<'T>)>)>
The second collection to difference.

Return Value

The difference of collection1 and collection2, considered as sets.

Exceptions


ExceptionCondition
ArgumentNullExceptioncollection1 or collection2 is null.

Remarks


When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items.

The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals.

If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the Difference or DifferenceWith methods on that class.