LinkedList<T> 생성자

정의

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

오버로드

LinkedList<T>()

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

LinkedList<T>(IEnumerable<T>)

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

LinkedList<T>(SerializationInfo, StreamingContext)
사용되지 않음.

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

LinkedList<T>()

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

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

예제

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

#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Collections::Generic;

void main()
{
    // Create and initialize a new LinkedList.
    LinkedList< String^ > ^ ll = gcnew LinkedList< String^ >;
    ll->AddLast(L"red");
    ll->AddLast(L"orange");
    ll->AddLast(L"yellow");
    ll->AddLast(L"orange");

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

        for each (String^ s in ll)
        {
            Console::WriteLine(L"   {0}", s);
        }
    }
    else
    {
        Console::WriteLine(L"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
*/
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> 비어 있으면 및 Last 속성에 가 First 포함됩니다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>입니다.

예외

collection이(가) null인 경우

예제

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

설명

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

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

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

적용 대상

LinkedList<T>(SerializationInfo, StreamingContext)

주의

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

지정한 LinkedList<T>SerializationInfo를 사용하여 serialize할 수 있는 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);
[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 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>
[<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.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> 비어 있으면 및 Last 속성에 가 First 포함됩니다null.

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

추가 정보

적용 대상