SortedSet<T> 생성자

정의

SortedSet<T> 클래스의 새 인스턴스를 초기화합니다.

오버로드

Name Description
SortedSet<T>()

SortedSet<T> 클래스의 새 인스턴스를 초기화합니다.

SortedSet<T>(IComparer<T>)

지정된 비교자를 사용하는 클래스의 SortedSet<T> 새 인스턴스를 초기화합니다.

SortedSet<T>(IEnumerable<T>)

지정된 열거 가능한 컬렉션에서 복사한 요소를 포함하는 클래스의 SortedSet<T> 새 인스턴스를 초기화합니다.

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

지정된 열거 가능한 컬렉션에서 복사되고 지정된 비교자를 사용하는 요소를 포함하는 클래스의 새 인스턴스 SortedSet<T> 를 초기화합니다.

SortedSet<T>(SerializationInfo, StreamingContext)

직렬화된 데이터를 포함하는 클래스의 SortedSet<T> 새 인스턴스를 초기화합니다.

설명

이 생성자는 작업입니다 O(1) .

SortedSet<T>()

SortedSet<T> 클래스의 새 인스턴스를 초기화합니다.

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

적용 대상

SortedSet<T>(IComparer<T>)

지정된 비교자를 사용하는 클래스의 SortedSet<T> 새 인스턴스를 초기화합니다.

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

매개 변수

comparer
IComparer<T>

개체 비교에 사용할 기본 비교자입니다.

예외

comparernull입니다.

예제

다음 예제에서는 파일 이름을 확장명으로 정렬하는 정렬된 집합을 생성하는 데 사용되는 비교자(ByFileExtension)를 정의합니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 SortedSet<T> 일부입니다.

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

적용 대상

SortedSet<T>(IEnumerable<T>)

지정된 열거 가능한 컬렉션에서 복사한 요소를 포함하는 클래스의 SortedSet<T> 새 인스턴스를 초기화합니다.

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

매개 변수

collection
IEnumerable<T>

복사할 열거 가능한 컬렉션입니다.

설명

열거 가능한 컬렉션의 중복 요소는 클래스의 SortedSet<T> 새 인스턴스에 복사되지 않으며 예외가 throw되지 않습니다.

이 생성자는 O(n log n) 매개 변수의 요소 collection 수가 있는 n 작업입니다.

적용 대상

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

지정된 열거 가능한 컬렉션에서 복사되고 지정된 비교자를 사용하는 요소를 포함하는 클래스의 새 인스턴스 SortedSet<T> 를 초기화합니다.

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

매개 변수

collection
IEnumerable<T>

복사할 열거 가능한 컬렉션입니다.

comparer
IComparer<T>

개체 비교에 사용할 기본 비교자입니다.

예외

collectionnull입니다.

적용 대상

SortedSet<T>(SerializationInfo, StreamingContext)

직렬화된 데이터를 포함하는 클래스의 SortedSet<T> 새 인스턴스를 초기화합니다.

protected:
 SortedSet(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected SortedSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
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)

매개 변수

info
SerializationInfo

개체를 serialize하는 데 필요한 정보가 들어 있는 SortedSet<T> 개체입니다.

context
StreamingContext

개체와 연결된 serialize된 스트림의 원본 및 대상을 SortedSet<T> 포함하는 구조체입니다.

설명

이 생성자는 역직렬화 중에 호출되어 스트림을 통해 전송되는 개체를 다시 구성합니다.

적용 대상