LinkedList<T> LinkedList<T> LinkedList<T> LinkedList<T> Class

정의

이중 연결 목록을 나타냅니다.Represents a doubly linked list.

generic <typename T>
public ref class LinkedList : System::Collections::Generic::ICollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IReadOnlyCollection<T>, System::Collections::ICollection, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class LinkedList<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.ICollection, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
type LinkedList<'T> = class
    interface ICollection<'T>
    interface ICollection
    interface IReadOnlyCollection<'T>
    interface ISerializable
    interface IDeserializationCallback
    interface seq<'T>
    interface IEnumerable
Public Class LinkedList(Of T)
Implements ICollection, ICollection(Of T), IDeserializationCallback, IEnumerable(Of T), IReadOnlyCollection(Of T), ISerializable

형식 매개 변수

T

링크된 목록의 요소 형식을 지정합니다.Specifies the element type of the linked list.

상속
LinkedList<T>LinkedList<T>LinkedList<T>LinkedList<T>
특성
구현

예제

다음 코드 예제에서는 다양 한 기능을 보여 줍니다는 LinkedList<T> 클래스입니다.The following code example demonstrates many features of the LinkedList<T> class.

#using <System.dll>

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

public ref class Example
{
public:
    static void Main()
    {
        // Create the link list.
        array<String^>^ words =
            { "the", "fox", "jumped", "over", "the", "dog" };
        LinkedList<String^>^ sentence = gcnew LinkedList<String^>(words);
        Display(sentence, "The linked list values:");
        Console::WriteLine("sentence.Contains(\"jumped\") = {0}",
            sentence->Contains("jumped"));

        // Add the word 'today' to the beginning of the linked list.
        sentence->AddFirst("today");
        Display(sentence, "Test 1: Add 'today' to beginning of the list:");

        // Move the first node to be the last node.
        LinkedListNode<String^>^ mark1 = sentence->First;
        sentence->RemoveFirst();
        sentence->AddLast(mark1);
        Display(sentence, "Test 2: Move first node to be last node:");

        // Change the last node to 'yesterday'.
        sentence->RemoveLast();
        sentence->AddLast("yesterday");
        Display(sentence, "Test 3: Change the last node to 'yesterday':");

        // Move the last node to be the first node.
        mark1 = sentence->Last;
        sentence->RemoveLast();
        sentence->AddFirst(mark1);
        Display(sentence, "Test 4: Move last node to be first node:");


        // Indicate the last occurence of 'the'.
        sentence->RemoveFirst();
        LinkedListNode<String^>^ current = sentence->FindLast("the");
        IndicateNode(current, "Test 5: Indicate last occurence of 'the':");

        // Add 'lazy' and 'old' after 'the' (the LinkedListNode named current).
        sentence->AddAfter(current, "old");
        sentence->AddAfter(current, "lazy");
        IndicateNode(current, "Test 6: Add 'lazy' and 'old' after 'the':");

        // Indicate 'fox' node.
        current = sentence->Find("fox");
        IndicateNode(current, "Test 7: Indicate the 'fox' node:");

        // Add 'quick' and 'brown' before 'fox':
        sentence->AddBefore(current, "quick");
        sentence->AddBefore(current, "brown");
        IndicateNode(current, "Test 8: Add 'quick' and 'brown' before 'fox':");

        // Keep a reference to the current node, 'fox',
        // and to the previous node in the list. Indicate the 'dog' node.
        mark1 = current;
        LinkedListNode<String^>^ mark2 = current->Previous;
        current = sentence->Find("dog");
        IndicateNode(current, "Test 9: Indicate the 'dog' node:");

        // The AddBefore method throws an InvalidOperationException
        // if you try to add a node that already belongs to a list.
        Console::WriteLine("Test 10: Throw exception by adding node (fox) already in the list:");
        try
        {
            sentence->AddBefore(current, mark1);
        }
        catch (InvalidOperationException^ ex)
        {
            Console::WriteLine("Exception message: {0}", ex->Message);
        }
        Console::WriteLine();

        // Remove the node referred to by mark1, and then add it
        // before the node referred to by current.
        // Indicate the node referred to by current.
        sentence->Remove(mark1);
        sentence->AddBefore(current, mark1);
        IndicateNode(current, "Test 11: Move a referenced node (fox) before the current node (dog):");

        // Remove the node referred to by current.
        sentence->Remove(current);
        IndicateNode(current, "Test 12: Remove current node (dog) and attempt to indicate it:");

        // Add the node after the node referred to by mark2.
        sentence->AddAfter(mark2, current);
        IndicateNode(current, "Test 13: Add node removed in test 11 after a referenced node (brown):");

        // The Remove method finds and removes the
        // first node that that has the specified value.
        sentence->Remove("old");
        Display(sentence, "Test 14: Remove node that has the value 'old':");

        // When the linked list is cast to ICollection(Of String),
        // the Add method adds a node to the end of the list.
        sentence->RemoveLast();
        ICollection<String^>^ icoll = sentence;
        icoll->Add("rhinoceros");
        Display(sentence, "Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':");

        Console::WriteLine("Test 16: Copy the list to an array:");
        // Create an array with the same number of
        // elements as the inked list.
        array<String^>^ sArray = gcnew array<String^>(sentence->Count);
        sentence->CopyTo(sArray, 0);

        for each (String^ s in sArray)
        {
            Console::WriteLine(s);
        }


        // Release all the nodes.
        sentence->Clear();

        Console::WriteLine();
        Console::WriteLine("Test 17: Clear linked list. Contains 'jumped' = {0}",
            sentence->Contains("jumped"));

        Console::ReadLine();
    }

private:
    static void Display(LinkedList<String^>^ words, String^ test)
    {
        Console::WriteLine(test);
        for each (String^ word in words)
        {
            Console::Write(word + " ");
        }
        Console::WriteLine();
        Console::WriteLine();
    }

    static void IndicateNode(LinkedListNode<String^>^ node, String^ test)
    {
        Console::WriteLine(test);
        if (node->List == nullptr)
        {
            Console::WriteLine("Node '{0}' is not in the list.\n",
                node->Value);
            return;
        }

        StringBuilder^ result = gcnew StringBuilder("(" + node->Value + ")");
        LinkedListNode<String^>^ nodeP = node->Previous;

        while (nodeP != nullptr)
        {
            result->Insert(0, nodeP->Value + " ");
            nodeP = nodeP->Previous;
        }

        node = node->Next;
        while (node != nullptr)
        {
            result->Append(" " + node->Value);
            node = node->Next;
        }

        Console::WriteLine(result);
        Console::WriteLine();
    }
};

int main()
{
    Example::Main();
}

//This code example produces the following output:
//
//The linked list values:
//the fox jumped over the dog

//Test 1: Add 'today' to beginning of the list:
//today the fox jumped over the dog

//Test 2: Move first node to be last node:
//the fox jumped over the dog today

//Test 3: Change the last node to 'yesterday':
//the fox jumped over the dog yesterday

//Test 4: Move last node to be first node:
//yesterday the fox jumped over the dog

//Test 5: Indicate last occurence of 'the':
//the fox jumped over (the) dog

//Test 6: Add 'lazy' and 'old' after 'the':
//the fox jumped over (the) lazy old dog

//Test 7: Indicate the 'fox' node:
//the (fox) jumped over the lazy old dog

//Test 8: Add 'quick' and 'brown' before 'fox':
//the quick brown (fox) jumped over the lazy old dog

//Test 9: Indicate the 'dog' node:
//the quick brown fox jumped over the lazy old (dog)

//Test 10: Throw exception by adding node (fox) already in the list:
//Exception message: The LinkedList node belongs a LinkedList.

//Test 11: Move a referenced node (fox) before the current node (dog):
//the quick brown jumped over the lazy old fox (dog)

//Test 12: Remove current node (dog) and attempt to indicate it:
//Node 'dog' is not in the list.

//Test 13: Add node removed in test 11 after a referenced node (brown):
//the quick brown (dog) jumped over the lazy old fox

//Test 14: Remove node that has the value 'old':
//the quick brown dog jumped over the lazy fox

//Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':
//the quick brown dog jumped over the lazy rhinoceros

//Test 16: Copy the list to an array:
//the
//quick
//brown
//dog
//jumped
//over
//the
//lazy
//rhinoceros

//Test 17: Clear linked list. Contains 'jumped' = False
//
using System;
using System.Text;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create the link list.
        string[] words =
            { "the", "fox", "jumps", "over", "the", "dog" };
        LinkedList<string> sentence = new LinkedList<string>(words);
        Display(sentence, "The linked list values:");
        Console.WriteLine("sentence.Contains(\"jumps\") = {0}",
            sentence.Contains("jumps"));

        // Add the word 'today' to the beginning of the linked list.
        sentence.AddFirst("today");
        Display(sentence, "Test 1: Add 'today' to beginning of the list:");

        // Move the first node to be the last node.
        LinkedListNode<string> mark1 = sentence.First;
        sentence.RemoveFirst();
        sentence.AddLast(mark1);
        Display(sentence, "Test 2: Move first node to be last node:");

        // Change the last node to 'yesterday'.
        sentence.RemoveLast();
        sentence.AddLast("yesterday");
        Display(sentence, "Test 3: Change the last node to 'yesterday':");

        // Move the last node to be the first node.
        mark1 = sentence.Last;
        sentence.RemoveLast();
        sentence.AddFirst(mark1);
        Display(sentence, "Test 4: Move last node to be first node:");


        // Indicate the last occurence of 'the'.
        sentence.RemoveFirst();
        LinkedListNode<string> current = sentence.FindLast("the");
        IndicateNode(current, "Test 5: Indicate last occurence of 'the':");

        // Add 'lazy' and 'old' after 'the' (the LinkedListNode named current).
        sentence.AddAfter(current, "old");
        sentence.AddAfter(current, "lazy");
        IndicateNode(current, "Test 6: Add 'lazy' and 'old' after 'the':");

        // Indicate 'fox' node.
        current = sentence.Find("fox");
        IndicateNode(current, "Test 7: Indicate the 'fox' node:");

        // Add 'quick' and 'brown' before 'fox':
        sentence.AddBefore(current, "quick");
        sentence.AddBefore(current, "brown");
        IndicateNode(current, "Test 8: Add 'quick' and 'brown' before 'fox':");

        // Keep a reference to the current node, 'fox',
        // and to the previous node in the list. Indicate the 'dog' node.
        mark1 = current;
        LinkedListNode<string> mark2 = current.Previous;
        current = sentence.Find("dog");
        IndicateNode(current, "Test 9: Indicate the 'dog' node:");

        // The AddBefore method throws an InvalidOperationException
        // if you try to add a node that already belongs to a list.
        Console.WriteLine("Test 10: Throw exception by adding node (fox) already in the list:");
        try
        {
            sentence.AddBefore(current, mark1);
        }
        catch (InvalidOperationException ex)
        {
            Console.WriteLine("Exception message: {0}", ex.Message);
        }
        Console.WriteLine();

        // Remove the node referred to by mark1, and then add it
        // before the node referred to by current.
        // Indicate the node referred to by current.
        sentence.Remove(mark1);
        sentence.AddBefore(current, mark1);
        IndicateNode(current, "Test 11: Move a referenced node (fox) before the current node (dog):");

        // Remove the node referred to by current.
        sentence.Remove(current);
        IndicateNode(current, "Test 12: Remove current node (dog) and attempt to indicate it:");

        // Add the node after the node referred to by mark2.
        sentence.AddAfter(mark2, current);
        IndicateNode(current, "Test 13: Add node removed in test 11 after a referenced node (brown):");

        // The Remove method finds and removes the
        // first node that that has the specified value.
        sentence.Remove("old");
        Display(sentence, "Test 14: Remove node that has the value 'old':");

        // When the linked list is cast to ICollection(Of String),
        // the Add method adds a node to the end of the list.
        sentence.RemoveLast();
        ICollection<string> icoll = sentence;
        icoll.Add("rhinoceros");
        Display(sentence, "Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':");

        Console.WriteLine("Test 16: Copy the list to an array:");
        // Create an array with the same number of
        // elements as the inked list.
        string[] sArray = new string[sentence.Count];
        sentence.CopyTo(sArray, 0);

        foreach (string s in sArray)
        {
            Console.WriteLine(s);
        }

        // Release all the nodes.
        sentence.Clear();

        Console.WriteLine();
        Console.WriteLine("Test 17: Clear linked list. Contains 'jumps' = {0}",
            sentence.Contains("jumps"));

        Console.ReadLine();
    }

    private static void Display(LinkedList<string> words, string test)
    {
        Console.WriteLine(test);
        foreach (string word in words)
        {
            Console.Write(word + " ");
        }
        Console.WriteLine();
        Console.WriteLine();
    }

    private static void IndicateNode(LinkedListNode<string> node, string test)
    {
        Console.WriteLine(test);
        if (node.List == null)
        {
            Console.WriteLine("Node '{0}' is not in the list.\n",
                node.Value);
            return;
        }

        StringBuilder result = new StringBuilder("(" + node.Value + ")");
        LinkedListNode<string> nodeP = node.Previous;

        while (nodeP != null)
        {
            result.Insert(0, nodeP.Value + " ");
            nodeP = nodeP.Previous;
        }

        node = node.Next;
        while (node != null)
        {
            result.Append(" " + node.Value);
            node = node.Next;
        }

        Console.WriteLine(result);
        Console.WriteLine();
    }
}

//This code example produces the following output:
//
//The linked list values:
//the fox jumps over the dog

//Test 1: Add 'today' to beginning of the list:
//today the fox jumps over the dog

//Test 2: Move first node to be last node:
//the fox jumps over the dog today

//Test 3: Change the last node to 'yesterday':
//the fox jumps over the dog yesterday

//Test 4: Move last node to be first node:
//yesterday the fox jumps over the dog

//Test 5: Indicate last occurence of 'the':
//the fox jumps over (the) dog

//Test 6: Add 'lazy' and 'old' after 'the':
//the fox jumps over (the) lazy old dog

//Test 7: Indicate the 'fox' node:
//the (fox) jumps over the lazy old dog

//Test 8: Add 'quick' and 'brown' before 'fox':
//the quick brown (fox) jumps over the lazy old dog

//Test 9: Indicate the 'dog' node:
//the quick brown fox jumps over the lazy old (dog)

//Test 10: Throw exception by adding node (fox) already in the list:
//Exception message: The LinkedList node belongs a LinkedList.

//Test 11: Move a referenced node (fox) before the current node (dog):
//the quick brown jumps over the lazy old fox (dog)

//Test 12: Remove current node (dog) and attempt to indicate it:
//Node 'dog' is not in the list.

//Test 13: Add node removed in test 11 after a referenced node (brown):
//the quick brown (dog) jumps over the lazy old fox

//Test 14: Remove node that has the value 'old':
//the quick brown dog jumps over the lazy fox

//Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':
//the quick brown dog jumps over the lazy rhinoceros

//Test 16: Copy the list to an array:
//the
//quick
//brown
//dog
//jumps
//over
//the
//lazy
//rhinoceros

//Test 17: Clear linked list. Contains 'jumps' = False
//
Imports System
Imports System.Text
Imports System.Collections.Generic
Public Class Example

    Public Shared Sub Main()
        ' Create the link list.
        Dim words() As String = {"the", "fox", _
            "jumps", "over", "the", "dog"}
        Dim sentence As New LinkedList(Of String)(words)
        Console.WriteLine("sentence.Contains(""jumps"") = {0}", _
            sentence.Contains("jumps"))
        Display(sentence, "The linked list values:")
        ' Add the word 'today' to the beginning of the linked list.
        sentence.AddFirst("today")
        Display(sentence, "Test 1: Add 'today' to beginning of the list:")
        ' Move the first node to be the last node.
        Dim mark1 As LinkedListNode(Of String) = sentence.First
        sentence.RemoveFirst()
        sentence.AddLast(mark1)
        Display(sentence, "Test 2: Move first node to be last node:")
        ' Change the last node to 'yesterday'.
        sentence.RemoveLast()
        sentence.AddLast("yesterday")
        Display(sentence, "Test 3: Change the last node to 'yesterday':")
        ' Move the last node to be the first node.
        mark1 = sentence.Last
        sentence.RemoveLast()
        sentence.AddFirst(mark1)
        Display(sentence, "Test 4: Move last node to be first node:")
        ' Indicate the last occurence of 'the'.
        sentence.RemoveFirst()
        Dim current As LinkedListNode(Of String) = sentence.FindLast("the")
        IndicateNode(current, "Test 5: Indicate last occurence of 'the':")
        ' Add 'lazy' and 'old' after 'the' (the LinkedListNode named current).
        sentence.AddAfter(current, "old")
        sentence.AddAfter(current, "lazy")
        IndicateNode(current, "Test 6: Add 'lazy' and 'old' after 'the':")
        ' Indicate 'fox' node.
        current = sentence.Find("fox")
        IndicateNode(current, "Test 7: Indicate the 'fox' node:")
        ' Add 'quick' and 'brown' before 'fox':
        sentence.AddBefore(current, "quick")
        sentence.AddBefore(current, "brown")
        IndicateNode(current, "Test 8: Add 'quick' and 'brown' before 'fox':")
        ' Keep a reference to the current node, 'fox',
        ' and to the previous node in the list. Indicate the 'dog' node.
        mark1 = current
        Dim mark2 As LinkedListNode(Of String) = current.Previous
        current = sentence.Find("dog")
        IndicateNode(current, "Test 9: Indicate the 'dog' node:")
        ' The AddBefore method throws an InvalidOperationException
        ' if you try to add a node that already belongs to a list.
        Console.WriteLine("Test 10: Throw exception by adding node (fox) already in the list:")
        Try
            sentence.AddBefore(current, mark1)
        Catch ex As InvalidOperationException
            Console.WriteLine("Exception message: {0}", ex.Message)
        End Try
        Console.WriteLine()
        ' Remove the node referred to by mark1, and then add it
        ' before the node referred to by current.
        ' Indicate the node referred to by current.
        sentence.Remove(mark1)
        sentence.AddBefore(current, mark1)
        IndicateNode(current, "Test 11: Move a referenced node (fox) before the current node (dog):")
        ' Remove the node referred to by current. 
        sentence.Remove(current)
        IndicateNode(current, "Test 12: Remove current node (dog) and attempt to indicate it:")
        ' Add the node after the node referred to by mark2.
        sentence.AddAfter(mark2, current)
        IndicateNode(current, "Test 13: Add node removed in test 11 after a referenced node (brown):")
        ' The Remove method finds and removes the
        ' first node that that has the specified value.
        sentence.Remove("old")
        Display(sentence, "Test 14: Remove node that has the value 'old':")
        ' When the linked list is cast to ICollection(Of String),
        ' the Add method adds a node to the end of the list.
        sentence.RemoveLast()
        Dim icoll As ICollection(Of String) = sentence
        icoll.Add("rhinoceros")
        Display(sentence, "Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':")
        Console.WriteLine("Test 16: Copy the list to an array:")
        ' Create an array with the same number of
        ' elements as the inked list.
        Dim sArray() As String = New String((sentence.Count) - 1) {}
        sentence.CopyTo(sArray, 0)
        For Each s As String In sArray
            Console.WriteLine(s)
        Next

        ' Release all the nodes.
        sentence.Clear()
        Console.WriteLine()
        Console.WriteLine("Test 17: Clear linked list. Contains 'jumps' = {0}", sentence.Contains("jumps"))
        Console.ReadLine()
    End Sub

    Private Shared Sub Display(ByVal words As LinkedList(Of String), ByVal test As String)
        Console.WriteLine(test)
        For Each word As String In words
            Console.Write((word + " "))
        Next
        Console.WriteLine()
        Console.WriteLine()
    End Sub

    Private Shared Sub IndicateNode(ByVal node As LinkedListNode(Of String), ByVal test As String)
        Console.WriteLine(test)
        If IsNothing(node.List) Then
            Console.WriteLine("Node '{0}' is not in the list." & vbLf, node.Value)
            Return
        End If
        Dim result As StringBuilder = New StringBuilder(("(" _
                        + (node.Value + ")")))
        Dim nodeP As LinkedListNode(Of String) = node.Previous

        While (Not (nodeP) Is Nothing)
            result.Insert(0, (nodeP.Value + " "))
            nodeP = nodeP.Previous

        End While
        node = node.Next

        While (Not (node) Is Nothing)
            result.Append((" " + node.Value))
            node = node.Next

        End While
        Console.WriteLine(result)
        Console.WriteLine()
    End Sub
End Class
'This code example produces the following output:
'
'The linked list values:
'the fox jumps over the dog 
'Test 1: Add 'today' to beginning of the list:
'today the fox jumps over the dog

'Test 2: Move first node to be last node:
'the fox jumps over the dog today

'Test 3: Change the last node to 'yesterday':
'the fox jumps over the dog yesterday

'Test 4: Move last node to be first node:
'yesterday the fox jumps over the dog

'Test 5: Indicate last occurence of 'the':
'the fox jumps over (the) dog

'Test 6: Add 'lazy' and 'old' after 'the':
'the fox jumps over (the) lazy old dog

'Test 7: Indicate the 'fox' node:
'the (fox) jumps over the lazy old dog

'Test 8: Add 'quick' and 'brown' before 'fox':
'the quick brown (fox) jumps over the lazy old dog

'Test 9: Indicate the 'dog' node:
'the quick brown fox jumps over the lazy old (dog)

'Test 10: Throw exception by adding node (fox) already in the list:
'Exception message: The LinkedList node belongs a LinkedList.

'Test 11: Move a referenced node (fox) before the current node (dog):
'the quick brown jumps over the lazy old fox (dog)

'Test 12: Remove current node (dog) and attempt to indicate it:
'Node 'dog' is not in the list.

'Test 13: Add node removed in test 11 after a referenced node (brown):
'the quick brown (dog) jumps over the lazy old fox

'Test 14: Remove node that has the value 'old':
'the quick brown dog jumps over the lazy fox 

'Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':
'the quick brown dog jumps over the lazy rhinoceros

'Test 16: Copy the list to an array:
'the
'quick
'brown
'dog
'jumps
'over
'the
'lazy
'rhinoceros

'Test 17: Clear linked list. Contains 'jumps' = False
'

설명

LinkedList<T> 범용 연결 된 목록이입니다.LinkedList<T> is a general-purpose linked list. 열거자 및 구현 지원는 ICollection 인터페이스를.NET Framework의 다른 컬렉션 클래스와 일치 합니다.It supports enumerators and implements the ICollection interface, consistent with other collection classes in the .NET Framework.

LinkedList<T> 형식의 개별 노드에 제공 LinkedListNode<T>이므로 삽입과 제거는 o (1) 작업입니다.LinkedList<T> provides separate nodes of type LinkedListNode<T>, so insertion and removal are O(1) operations.

노드를 제거 하 고 같은 목록 또는 다른 목록에 없는 추가 개체 힙에 할당의 결과에 다시 삽입할 수 있습니다.You can remove nodes and reinsert them, either in the same list or in another list, which results in no additional objects allocated on the heap. 또한 목록에서 내부 개수를 유지 관리 때문에 시작 된 Count 속성은 O(1) 작업 합니다.Because the list also maintains an internal count, getting the Count property is an O(1) operation.

각 노드에 LinkedList<T> 형식의 개체가 LinkedListNode<T>합니다.Each node in a LinkedList<T> object is of the type LinkedListNode<T>. 때문에 LinkedList<T> 이중으로 연결 되어 있으면 각 노드는 앞쪽으로 Next 노드를 버전과 Previous 노드.Because the LinkedList<T> is doubly linked, each node points forward to the Next node and backward to the Previous node.

동시 노드 및 해당 값은 만들 때 참조 형식이 포함 된 목록은 더 잘 수행 합니다.Lists that contain reference types perform better when a node and its value are created at the same time. LinkedList<T> 수락 null 유효한 Value 참조에 대 한 속성 형식 및 중복 값을 허용 합니다.LinkedList<T> accepts null as a valid Value property for reference types and allows duplicate values.

경우는 LinkedList<T> 비어 합니다 FirstLast 속성과 null합니다.If the LinkedList<T> is empty, the First and Last properties contain null.

LinkedList<T> 클래스 체인, 분할 주기, 또는 일관 되지 않은 상태의 목록을 만들 수 있는 기타 기능을 지원 하지 않습니다.The LinkedList<T> class does not support chaining, splitting, cycles, or other features that can leave the list in an inconsistent state. 목록에는 단일 스레드 일관 된 상태로 유지 됩니다.The list remains consistent on a single thread. 지 원하는 유일한 다중 스레드 시나리오는 LinkedList<T> 는 다중 스레드 읽기 작업입니다.The only multithreaded scenario supported by LinkedList<T> is multithreaded read operations.

생성자

LinkedList<T>() LinkedList<T>() LinkedList<T>() LinkedList<T>()

비어 있는 LinkedList<T> 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the LinkedList<T> class that is empty.

LinkedList<T>(IEnumerable<T>) LinkedList<T>(IEnumerable<T>) LinkedList<T>(IEnumerable<T>) LinkedList<T>(IEnumerable<T>)

지정한 LinkedList<T>에서 복사된 요소가 포함되어 있고 복사된 요소의 수를 수용하는 충분한 용량을 가지는 IEnumerable 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the LinkedList<T> class that contains elements copied from the specified IEnumerable and has sufficient capacity to accommodate the number of elements copied.

LinkedList<T>(SerializationInfo, StreamingContext) LinkedList<T>(SerializationInfo, StreamingContext) LinkedList<T>(SerializationInfo, StreamingContext) LinkedList<T>(SerializationInfo, StreamingContext)

지정한 LinkedList<T>SerializationInfo를 사용하여 serialize할 수 있는 StreamingContext 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the LinkedList<T> class that is serializable with the specified SerializationInfo and StreamingContext.

속성

Count Count Count Count

LinkedList<T>에 실제로 포함된 노드의 수를 가져옵니다.Gets the number of nodes actually contained in the LinkedList<T>.

First First First First

LinkedList<T>의 첫 번째 노드를 가져옵니다.Gets the first node of the LinkedList<T>.

Last Last Last Last

LinkedList<T>의 마지막 노드를 가져옵니다.Gets the last node of the LinkedList<T>.

메서드

AddAfter(LinkedListNode<T>, LinkedListNode<T>) AddAfter(LinkedListNode<T>, LinkedListNode<T>) AddAfter(LinkedListNode<T>, LinkedListNode<T>) AddAfter(LinkedListNode<T>, LinkedListNode<T>)

LinkedList<T>의 지정한 기존 노드 다음에 지정한 새 노드를 추가합니다.Adds the specified new node after the specified existing node in the LinkedList<T>.

AddAfter(LinkedListNode<T>, T) AddAfter(LinkedListNode<T>, T) AddAfter(LinkedListNode<T>, T) AddAfter(LinkedListNode<T>, T)

LinkedList<T>의 지정한 기존 노드 다음에 지정한 값이 포함된 새 노드를 추가합니다.Adds a new node containing the specified value after the specified existing node in the LinkedList<T>.

AddBefore(LinkedListNode<T>, LinkedListNode<T>) AddBefore(LinkedListNode<T>, LinkedListNode<T>) AddBefore(LinkedListNode<T>, LinkedListNode<T>) AddBefore(LinkedListNode<T>, LinkedListNode<T>)

LinkedList<T>의 지정한 기존 노드 앞에 지정한 새 노드를 추가합니다.Adds the specified new node before the specified existing node in the LinkedList<T>.

AddBefore(LinkedListNode<T>, T) AddBefore(LinkedListNode<T>, T) AddBefore(LinkedListNode<T>, T) AddBefore(LinkedListNode<T>, T)

LinkedList<T>의 지정한 기존 노드 앞에 지정한 값이 포함된 새 노드를 추가합니다.Adds a new node containing the specified value before the specified existing node in the LinkedList<T>.

AddFirst(LinkedListNode<T>) AddFirst(LinkedListNode<T>) AddFirst(LinkedListNode<T>) AddFirst(LinkedListNode<T>)

LinkedList<T>의 시작 위치에 지정한 새 노드를 추가합니다.Adds the specified new node at the start of the LinkedList<T>.

AddFirst(T) AddFirst(T) AddFirst(T) AddFirst(T)

LinkedList<T>의 시작 위치에 지정한 값이 포함된 새 노드를 추가합니다.Adds a new node containing the specified value at the start of the LinkedList<T>.

AddLast(LinkedListNode<T>) AddLast(LinkedListNode<T>) AddLast(LinkedListNode<T>) AddLast(LinkedListNode<T>)

LinkedList<T>의 끝에 지정한 새 노드를 추가합니다.Adds the specified new node at the end of the LinkedList<T>.

AddLast(T) AddLast(T) AddLast(T) AddLast(T)

LinkedList<T>의 끝에 지정한 값이 포함된 새 노드를 추가합니다.Adds a new node containing the specified value at the end of the LinkedList<T>.

Clear() Clear() Clear() Clear()

LinkedList<T>에서 노드를 모두 제거합니다.Removes all nodes from the LinkedList<T>.

Contains(T) Contains(T) Contains(T) Contains(T)

값이 LinkedList<T>에 있는지 여부를 확인합니다.Determines whether a value is in the LinkedList<T>.

CopyTo(T[], Int32) CopyTo(T[], Int32) CopyTo(T[], Int32) CopyTo(T[], Int32)

대상 배열의 지정된 인덱스에서 시작하여 전체 LinkedList<T>을 호환되는 1차원 Array에 복사합니다.Copies the entire LinkedList<T> to a compatible one-dimensional Array, starting at the specified index of the target array.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
Find(T) Find(T) Find(T) Find(T)

지정한 값이 포함된 첫 번째 노드를 찾습니다.Finds the first node that contains the specified value.

FindLast(T) FindLast(T) FindLast(T) FindLast(T)

지정한 값이 포함된 마지막 노드를 찾습니다.Finds the last node that contains the specified value.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

LinkedList<T>를 반복하는 열거자를 반환합니다.Returns an enumerator that iterates through the LinkedList<T>.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

ISerializable 인터페이스를 구현하고 LinkedList<T> 인스턴스를 직렬화하는 데 필요한 데이터를 반환합니다.Implements the ISerializable interface and returns the data needed to serialize the LinkedList<T> instance.

GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object)

ISerializable 인터페이스를 구현하고, deserialization이 완료되면 deserialization 이벤트를 발생시킵니다.Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.

Remove(LinkedListNode<T>) Remove(LinkedListNode<T>) Remove(LinkedListNode<T>) Remove(LinkedListNode<T>)

LinkedList<T>에서 지정된 노드를 제거합니다.Removes the specified node from the LinkedList<T>.

Remove(T) Remove(T) Remove(T) Remove(T)

LinkedList<T>에서 맨 처음 발견되는 지정된 값을 제거합니다.Removes the first occurrence of the specified value from the LinkedList<T>.

RemoveFirst() RemoveFirst() RemoveFirst() RemoveFirst()

LinkedList<T>의 시작 위치에서 노드를 제거합니다.Removes the node at the start of the LinkedList<T>.

RemoveLast() RemoveLast() RemoveLast() RemoveLast()

LinkedList<T>의 끝에서 노드를 제거합니다.Removes the node at the end of the LinkedList<T>.

ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)

명시적 인터페이스 구현

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

특정 ICollection 인덱스부터 시작하여 Array의 요소를 Array에 복사합니다.Copies the elements of the ICollection to an Array, starting at a particular Array index.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

ICollection에 대한 액세스가 동기화되어 스레드로부터 안전하게 보호되는지를 나타내는 값을 가져옵니다.Gets a value indicating whether access to the ICollection is synchronized (thread safe).

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

ICollection에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.Gets an object that can be used to synchronize access to the ICollection.

ICollection<T>.Add(T) ICollection<T>.Add(T) ICollection<T>.Add(T) ICollection<T>.Add(T)

ICollection<T>의 끝에 항목을 추가합니다.Adds an item at the end of the ICollection<T>.

ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly

ICollection<T>가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether the ICollection<T> is read-only.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

링크된 목록을 컬렉션으로 반복하는 열거자를 반환합니다.Returns an enumerator that iterates through the linked list as a collection.

IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator()

컬렉션을 반복하는 열거자를 반환합니다.Returns an enumerator that iterates through a collection.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

반환을 DataTable 복사본이 들어 있는 DataRow 개체를 지정 된 입력 IEnumerable<T> 개체는 제네릭 매개 변수 TDataRow.Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

복사본 DataRow 지정 된 개체 DataTable, 지정 된 입력 IEnumerable<T> 개체는 제네릭 매개 변수 TDataRow합니다.Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

복사본 DataRow 지정 된 개체 DataTable, 지정 된 입력 IEnumerable<T> 개체는 제네릭 매개 변수 TDataRow합니다.Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

요소를 캐스팅을 IEnumerable 를 지정 된 형식입니다.Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

요소를 필터링 하는 IEnumerable 지정된 된 형식에 기반 합니다.Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

변환를 IEnumerableIQueryable합니다.Converts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

소스 컬렉션에 있는 모든 노드의 상위 항목이 들어 있는 요소 컬렉션을 반환합니다.Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

소스 컬렉션에 있는 모든 노드의 상위 항목이 들어 있는 필터링된 요소 컬렉션을 반환합니다.Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 일치하는 XName이 있는 요소만 컬렉션에 포함됩니다.Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

소스 컬렉션에 있는 모든 문서 및 요소의 하위 노드 컬렉션을 반환합니다.Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

소스 컬렉션에 있는 모든 요소 및 문서의 하위 요소가 들어 있는 요소 컬렉션을 반환합니다.Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName)

소스 컬렉션에 있는 모든 요소 및 문서의 하위 요소가 들어 있는 필터링된 요소 컬렉션을 반환합니다.Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 일치하는 XName이 있는 요소만 컬렉션에 포함됩니다.Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

소스 컬렉션에 있는 모든 요소 및 문서의 자식 요소 컬렉션을 반환합니다.Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

소스 컬렉션에 있는 모든 요소 및 문서의 필터링된 자식 요소 컬렉션을 반환합니다.Returns a filtered collection of the child elements of every element and document in the source collection. 일치하는 XName이 있는 요소만 컬렉션에 포함됩니다.Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

소스 컬렉션의 모든 노드가 문서 순으로 정렬되어 들어 있는 노드 컬렉션을 반환합니다.Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

소스 컬렉션에 있는 모든 문서 및 요소의 자식 노드 컬렉션을 반환합니다.Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

부모 노드에서 소스 컬렉션의 모든 노드를 제거합니다.Removes every node in the source collection from its parent node.

적용 대상

스레드 보안

이 형식은 스레드로부터 안전이 없습니다.This type is not thread safe. 경우는 LinkedList<T> 여러 스레드가 액세스 하는 고유한 동기화 메커니즘을 구현 해야 합니다.If the LinkedList<T> needs to be accessed by multiple threads, you will need to implement their own synchronization mechanism.

LinkedList<T> 지원할 수 있습니다 여러 판독기 동시에 따라 컬렉션을 수정 되지 않습니다.A LinkedList<T> can support multiple readers concurrently, as long as the collection is not modified. 이 경우에 컬렉션을 열거 본질적으로 스레드로부터 안전한 프로시저가 아닙니다.Even so, enumerating through a collection is intrinsically not a thread-safe procedure. 열거형 쓰기 권한과 경쟁 하는 드문 경우에서 컬렉션을 열거 하는 동안 잠가야 합니다.In the rare case where an enumeration contends with write accesses, the collection must be locked during the entire enumeration. 여러 스레드에서 컬렉션에 액세스하여 읽고 쓸 수 있도록 허용하려면 사용자 지정 동기화를 구현해야 합니다.To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

추가 정보