SortedSet<T>.CreateSetComparer Metodo

Definizione

Restituisce un oggetto IEqualityComparer che può essere usato per creare una raccolta contenente singoli set.

Overload

CreateSetComparer()

Restituisce un oggetto IEqualityComparer che può essere usato per creare una raccolta contenente singoli set.

CreateSetComparer(IEqualityComparer<T>)

Restituisce un oggetto IEqualityComparer, in base a un operatore di confronto specificato, che può essere usato per creare una raccolta contenente singoli set.

CreateSetComparer()

Origine:
SortedSet.cs
Origine:
SortedSet.cs
Origine:
SortedSet.cs

Restituisce un oggetto IEqualityComparer che può essere usato per creare una raccolta contenente singoli set.

public static System.Collections.Generic.IEqualityComparer<System.Collections.Generic.SortedSet<T>> CreateSetComparer ();

Restituisce

Operatore di confronto per la creazione di una raccolta di set.

Commenti

L'oggetto IEqualityComparer verifica l'uguaglianza a un solo livello. È tuttavia possibile concatenare i comparer a livelli aggiuntivi per eseguire test di uguaglianza più approfonditi.

La chiamata a questo metodo è un'operazione O(1) .

Si applica a

.NET 9 e altre versioni
Prodotto Versioni
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

CreateSetComparer(IEqualityComparer<T>)

Origine:
SortedSet.cs
Origine:
SortedSet.cs
Origine:
SortedSet.cs

Restituisce un oggetto IEqualityComparer, in base a un operatore di confronto specificato, che può essere usato per creare una raccolta contenente singoli set.

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

Parametri

memberEqualityComparer
IEqualityComparer<T>

Operatore di confronto da usare per la creazione dell'operatore di confronto restituito.

Restituisce

Operatore di confronto per la creazione di una raccolta di set.

Esempio

Nell'esempio seguente viene usato il CreateSetComparer metodo per creare un set di set. Questo esempio di codice fa parte di un esempio più grande fornito per la SortedSet<T> classe.

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

Commenti

E memberEqualityComparer l'oggetto corrente SortedSet<T> deve avere la stessa definizione di uguaglianza.

È possibile usare il comparer restituito da questo metodo nel SortedSet<T>.SortedSet<T>(IEnumerable<T>, IComparer<T>) costruttore per creare una tabella hash di singoli set.

Si applica a

.NET 9 e altre versioni
Prodotto Versioni
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1