LinkedList<T> 생성자

정의

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

오버로드

Name Description
LinkedList<T>()

비어 있는 클래스의 새 인스턴스를 LinkedList<T> 초기화합니다.

LinkedList<T>(IEnumerable<T>)

지정된 요소에서 복사된 요소를 포함하고 복사된 LinkedList<T> 요소 수를 IEnumerable 수용할 수 있는 충분한 용량이 있는 클래스의 새 인스턴스를 초기화합니다.

LinkedList<T>(SerializationInfo, StreamingContext)

지정된 클래스와 을 사용하여 직렬화할 수 있는 클래스의 LinkedList<T> 새 인스턴스를 SerializationInfo 초기화합니다 StreamingContext.

LinkedList<T>()

비어 있는 클래스의 새 인스턴스를 LinkedList<T> 초기화합니다.

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

예제

다음 코드 예제에서는 형식StringLinkedList<T> 만들고 초기화하고, 여러 노드를 추가한 다음, 해당 내용을 표시합니다.

using System;
using System.Collections;
using System.Collections.Generic;

public class GenericCollection
{
    public static void Main()
    {
        // Create and initialize a new LinkedList.
        LinkedList<String> ll = new LinkedList<String>();
        ll.AddLast("red");
        ll.AddLast("orange");
        ll.AddLast("yellow");
        ll.AddLast("orange");

        // Display the contents of the LinkedList.
        if (ll.Count > 0)
        {
            Console.WriteLine("The first item in the list is {0}.", ll.First.Value);
            Console.WriteLine("The last item in the list is {0}.", ll.Last.Value);

            Console.WriteLine("The LinkedList contains:");
            foreach (String s in ll)
                Console.WriteLine("   {0}", s);
        }
        else
        {
            Console.WriteLine("The LinkedList is empty.");
        }
    }
}

/* This code produces the following output.

The first item in the list is red.
The last item in the list is orange.
The LinkedList contains:
   red
   orange
   yellow
   orange
*/
Imports System.Collections
Imports System.Collections.Generic

Public Class GenericCollection

    Public Shared Sub Main()

        ' Create and initialize a new LinkedList.
        Dim ll As New LinkedList(Of String)()
        ll.AddLast("red")
        ll.AddLast("orange")
        ll.AddLast("yellow")
        ll.AddLast("orange")

        ' Display the contents of the LinkedList.
        If ll.Count > 0 Then
            Console.WriteLine("The first item in the list is {0}.", ll.First.Value)
            Console.WriteLine("The last item in the list is {0}.", ll.Last.Value)

            Console.WriteLine("The LinkedList contains:")
            For Each s As String In  ll
                Console.WriteLine("   {0}", s)
            Next s 
        Else
            Console.WriteLine("The LinkedList is empty.")
        End If

    End Sub 

End Class

'This code produces the following output.
'
'The first item in the list is red.
'The last item in the list is orange.
'The LinkedList contains:
'   red
'   orange
'   yellow
'   orange

설명

LinkedList<T>null 참조 형식에 유효한 Value 것으로 허용되며 중복 값을 허용합니다.

비어 있는 LinkedList<T> 경우 및 First 속성은 .를 Last 포함합니다null.

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

적용 대상

LinkedList<T>(IEnumerable<T>)

지정된 요소에서 복사된 요소를 포함하고 복사된 LinkedList<T> 요소 수를 IEnumerable 수용할 수 있는 충분한 용량이 있는 클래스의 새 인스턴스를 초기화합니다.

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

매개 변수

collection
IEnumerable<T>

IEnumerable 요소가 새 LinkedList<T>요소에 복사되는 경우.

예외

collectionnull입니다.

예제

이 생성자를 포함하는 예제는 클래스를 참조하세요 LinkedList<T> .

설명

LinkedList<T>null 참조 형식에 유효한 Value 것으로 허용되며 중복 값을 허용합니다.

요소가 없으면 collection 새 항목이 비어 있고 속성에 Last .가 First 포함됩니다nullLinkedList<T>.

이 생성자는 O(n) 연산입니다. 여기서 n 는 요소 수가 있습니다 collection.

적용 대상

LinkedList<T>(SerializationInfo, StreamingContext)

지정된 클래스와 을 사용하여 직렬화할 수 있는 클래스의 LinkedList<T> 새 인스턴스를 SerializationInfo 초기화합니다 StreamingContext.

protected:
 LinkedList(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected LinkedList(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Collections.Generic.LinkedList<'T> : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Generic.LinkedList<'T>
Protected Sub New (info As SerializationInfo, context As StreamingContext)

매개 변수

info
SerializationInfo

SerializationInfo 를 serialize하는 데 필요한 정보를 포함하는 개체입니다LinkedList<T>.

context
StreamingContext

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

설명

LinkedList<T>null 참조 형식에 유효한 Value 것으로 허용되며 중복 값을 허용합니다.

비어 있는 LinkedList<T> 경우 및 First 속성은 .를 Last 포함합니다null.

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

추가 정보

적용 대상