SortedSet<T> Konstruktor

Definisi

Menginisialisasi instans baru dari kelas SortedSet<T>.

Overload

Nama Deskripsi
SortedSet<T>()

Menginisialisasi instans baru dari kelas SortedSet<T>.

SortedSet<T>(IComparer<T>)

Menginisialisasi instans SortedSet<T> baru kelas yang menggunakan pembanding tertentu.

SortedSet<T>(IEnumerable<T>)

Menginisialisasi instans SortedSet<T> baru kelas yang berisi elemen yang disalin dari koleksi enumerable tertentu.

SortedSet<T>(IEnumerable<T>, IComparer<T>)

Menginisialisasi instans SortedSet<T> baru kelas yang berisi elemen yang disalin dari koleksi enumerable tertentu dan yang menggunakan pembanding tertentu.

SortedSet<T>(SerializationInfo, StreamingContext)
Kedaluwarsa.

Menginisialisasi instans SortedSet<T> baru kelas yang berisi data berseri.

Keterangan

Konstruktor ini adalah O(1) operasi.

SortedSet<T>()

Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs

Menginisialisasi instans baru dari kelas SortedSet<T>.

public:
 SortedSet();
public SortedSet();
Public Sub New ()

Berlaku untuk

SortedSet<T>(IComparer<T>)

Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs

Menginisialisasi instans SortedSet<T> baru kelas yang menggunakan pembanding tertentu.

public:
 SortedSet(System::Collections::Generic::IComparer<T> ^ comparer);
public SortedSet(System.Collections.Generic.IComparer<T> comparer);
public SortedSet(System.Collections.Generic.IComparer<T>? comparer);
new System.Collections.Generic.SortedSet<'T> : System.Collections.Generic.IComparer<'T> -> System.Collections.Generic.SortedSet<'T>
Public Sub New (comparer As IComparer(Of T))

Parameter

comparer
IComparer<T>

Pembanding default yang digunakan untuk membandingkan objek.

Pengecualian

comparer adalah null.

Contoh

Contoh berikut mendefinisikan comparer (ByFileExtension) yang digunakan untuk membuat set yang diurutkan yang mengurutkan nama file berdasarkan ekstensinya. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk SortedSet<T> kelas .

// Create a sorted set using the ByFileExtension comparer.
var mediaFiles1 = new SortedSet<string>(new ByFileExtension());
' Create a sorted set using the ByFileExtension comparer.
Dim mediaFiles1 As New SortedSet(Of String)(New ByFileExtension)
// Defines a comparer to create a sorted set
// that is sorted by the file extensions.
public class ByFileExtension : IComparer<string>
{
    string xExt, yExt;

    CaseInsensitiveComparer caseiComp = new CaseInsensitiveComparer();

    public int Compare(string x, string y)
    {
        // Parse the extension from the file name.
        xExt = x.Substring(x.LastIndexOf(".") + 1);
        yExt = y.Substring(y.LastIndexOf(".") + 1);

        // Compare the file extensions.
        int vExt = caseiComp.Compare(xExt, yExt);
        if (vExt != 0)
        {
            return vExt;
        }
        else
        {
            // The extension is the same,
            // so compare the filenames.
            return caseiComp.Compare(x, y);
        }
    }
}
' Defines a comparer to create a sorted set
' that is sorted by the file extensions.
Public Class ByFileExtension
    Implements IComparer(Of String)
    Dim xExt, yExt As String

    Dim caseiComp As CaseInsensitiveComparer = _
                        New CaseInsensitiveComparer
    Public Function Compare(x As String, y As String) _
        As Integer Implements IComparer(Of String).Compare
        ' Parse the extension from the file name.
        xExt = x.Substring(x.LastIndexOf(".") + 1)
        yExt = y.Substring(y.LastIndexOf(".") + 1)

        ' Compare the file extensions.
        Dim vExt As Integer = caseiComp.Compare(xExt, yExt)
        If vExt <> 0 Then
            Return vExt
        Else
            ' The extension is the same, 
            ' so compare the filenames. 
            Return caseiComp.Compare(x, y)
        End If
    End Function        
    
End Class

Berlaku untuk

SortedSet<T>(IEnumerable<T>)

Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs

Menginisialisasi instans SortedSet<T> baru kelas yang berisi elemen yang disalin dari koleksi enumerable tertentu.

public:
 SortedSet(System::Collections::Generic::IEnumerable<T> ^ collection);
public SortedSet(System.Collections.Generic.IEnumerable<T> collection);
new System.Collections.Generic.SortedSet<'T> : seq<'T> -> System.Collections.Generic.SortedSet<'T>
Public Sub New (collection As IEnumerable(Of T))

Parameter

collection
IEnumerable<T>

Koleksi yang dapat dijumlahkan untuk disalin.

Keterangan

Elemen duplikat dalam koleksi enumerable tidak disalin ke dalam instans SortedSet<T> baru kelas, dan tidak ada pengecualian yang dilemparkan.

Konstruktor ini adalah O(n log n) operasi, di mana n adalah jumlah elemen dalam collection parameter .

Berlaku untuk

SortedSet<T>(IEnumerable<T>, IComparer<T>)

Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs

Menginisialisasi instans SortedSet<T> baru kelas yang berisi elemen yang disalin dari koleksi enumerable tertentu dan yang menggunakan pembanding tertentu.

public:
 SortedSet(System::Collections::Generic::IEnumerable<T> ^ collection, System::Collections::Generic::IComparer<T> ^ comparer);
public SortedSet(System.Collections.Generic.IEnumerable<T> collection, System.Collections.Generic.IComparer<T> comparer);
public SortedSet(System.Collections.Generic.IEnumerable<T> collection, System.Collections.Generic.IComparer<T>? comparer);
new System.Collections.Generic.SortedSet<'T> : seq<'T> * System.Collections.Generic.IComparer<'T> -> System.Collections.Generic.SortedSet<'T>
Public Sub New (collection As IEnumerable(Of T), comparer As IComparer(Of T))

Parameter

collection
IEnumerable<T>

Koleksi yang dapat dijumlahkan untuk disalin.

comparer
IComparer<T>

Pembanding default yang digunakan untuk membandingkan objek.

Pengecualian

collection adalah null.

Berlaku untuk

SortedSet<T>(SerializationInfo, StreamingContext)

Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs
Sumber:
SortedSet.cs

Perhatian

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Menginisialisasi instans SortedSet<T> baru kelas yang berisi data berseri.

protected:
 SortedSet(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected SortedSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected SortedSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Collections.Generic.SortedSet<'T> : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Generic.SortedSet<'T>
new System.Collections.Generic.SortedSet<'T> : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Generic.SortedSet<'T>
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameter

info
SerializationInfo

Objek yang berisi informasi yang diperlukan untuk membuat serialisasi SortedSet<T> objek.

context
StreamingContext

Struktur yang berisi sumber dan tujuan aliran berseri yang terkait dengan SortedSet<T> objek.

Atribut

Keterangan

Konstruktor ini dipanggil selama deserialisasi untuk menyusun ulang objek yang ditransmisikan melalui aliran.

Berlaku untuk