Export (0) Print
Expand All

SortedSet<T>.CreateSetComparer Method (IEqualityComparer<T>)

Returns an IEqualityComparer object, according to a specified comparer, that can be used to create a collection that contains individual sets.

Namespace:  System.Collections.Generic
Assembly:  System (in System.dll)

public static IEqualityComparer<SortedSet<T>> CreateSetComparer(
	IEqualityComparer<T> memberEqualityComparer
)

Parameters

memberEqualityComparer
Type: System.Collections.Generic.IEqualityComparer<T>

The comparer to use for creating the returned comparer.

Return Value

Type: System.Collections.Generic.IEqualityComparer<SortedSet<T>>
A comparer for creating a collection of sets.

The memberEqualityComparer and the current SortedSet<T> must have the same definition of equality.

You can use the comparer returned by this method in the SortedSet<T>.SortedSet<T>(IEnumerable<T>, IComparer<T>) constructor to create a hash table of individual sets.

The following example uses the CreateSetComparer method to create a set of sets. This code example is part of a larger example provided for the SortedSet<T> class.

// Create a set of the sets.
IEqualityComparer<SortedSet<string>> comparer =
    SortedSet<string>.CreateSetComparer();

HashSet<SortedSet<string>> allMedia =
    new HashSet<SortedSet<string>>(comparer);
allMedia.Add(mediaFiles1);
allMedia.Add(mediaFiles2);

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4
Show:
© 2015 Microsoft