แก้ไข

แชร์ผ่าน


SortedSet<T>.CreateSetComparer Method

Definition

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

Overloads

CreateSetComparer()

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

CreateSetComparer(IEqualityComparer<T>)

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

CreateSetComparer()

Source:
SortedSet.cs
Source:
SortedSet.cs
Source:
SortedSet.cs

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

public:
 static System::Collections::Generic::IEqualityComparer<System::Collections::Generic::SortedSet<T> ^> ^ CreateSetComparer();
public static System.Collections.Generic.IEqualityComparer<System.Collections.Generic.SortedSet<T>> CreateSetComparer ();
static member CreateSetComparer : unit -> System.Collections.Generic.IEqualityComparer<System.Collections.Generic.SortedSet<'T>>
Public Shared Function CreateSetComparer () As IEqualityComparer(Of SortedSet(Of T))

Returns

A comparer for creating a collection of sets.

Remarks

The IEqualityComparer object checks for equality at only one level; however, you can chain together comparers at additional levels to perform deeper equality testing.

Calling this method is an O(1) operation.

Applies to

CreateSetComparer(IEqualityComparer<T>)

Source:
SortedSet.cs
Source:
SortedSet.cs
Source:
SortedSet.cs

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

public:
 static System::Collections::Generic::IEqualityComparer<System::Collections::Generic::SortedSet<T> ^> ^ CreateSetComparer(System::Collections::Generic::IEqualityComparer<T> ^ memberEqualityComparer);
public static System.Collections.Generic.IEqualityComparer<System.Collections.Generic.SortedSet<T>> CreateSetComparer (System.Collections.Generic.IEqualityComparer<T>? memberEqualityComparer);
public static System.Collections.Generic.IEqualityComparer<System.Collections.Generic.SortedSet<T>> CreateSetComparer (System.Collections.Generic.IEqualityComparer<T> memberEqualityComparer);
static member CreateSetComparer : System.Collections.Generic.IEqualityComparer<'T> -> System.Collections.Generic.IEqualityComparer<System.Collections.Generic.SortedSet<'T>>
Public Shared Function CreateSetComparer (memberEqualityComparer As IEqualityComparer(Of T)) As IEqualityComparer(Of SortedSet(Of T))

Parameters

memberEqualityComparer
IEqualityComparer<T>

The comparer to use for creating the returned comparer.

Returns

A comparer for creating a collection of sets.

Examples

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();

var allMedia = new HashSet<SortedSet<string>>(comparer);
allMedia.Add(mediaFiles1);
allMedia.Add(mediaFiles2);
' Create a set of the sets.
Dim comparer As IEqualityComparer(Of SortedSet(Of String)) = _
    SortedSet(Of String).CreateSetComparer()
Dim allMedia As New HashSet(Of SortedSet(Of String))(comparer)
allMedia.Add(mediaFiles1)
allMedia.Add(mediaFiles2)

Remarks

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.

Applies to