LinkedList<T> コンストラクター

定義

LinkedList<T> クラスの新しいインスタンスを初期化します。

オーバーロード

LinkedList<T>()

LinkedList<T> クラスの新しい空のインスタンスを初期化します。

LinkedList<T>(IEnumerable<T>)

指定した LinkedList<T> からコピーした要素を格納し、コピーされる要素の数を格納できるだけの容量を備えた、IEnumerable クラスの新しいインスタンスを初期化します。

LinkedList<T>(SerializationInfo, StreamingContext)
古い.

指定した LinkedList<T>SerializationInfo を使用して、シリアル化可能な StreamingContext クラスの新しいインスタンスを初期化します。

LinkedList<T>()

Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs

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> 場合、 First プロパティと Last プロパティには が含まれます null

このコンストラクターは O(1) 操作です。

適用対象

LinkedList<T>(IEnumerable<T>)

Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs

指定した 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、新しい LinkedList<T> は空になり、 プロパティと Last プロパティには がFirst含まれますnull

このコンストラクターは O(n) 操作です。ここで n 、 は 内 collectionの要素の数です。

適用対象

LinkedList<T>(SerializationInfo, StreamingContext)

Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs

注意事項

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

指定した 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);
[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 をシリアル化するために必要な情報を格納している LinkedList<T> オブジェクト。

context
StreamingContext

StreamingContext に関連付けられているシリアル化ストリームのソースおよびデスティネーションを格納している LinkedList<T> オブジェクト。

属性

注釈

LinkedList<T>null 参照型に対して有効 Value な として受け入れ、重複する値を許可します。

が空の LinkedList<T> 場合、 First プロパティと Last プロパティには が含まれます null

このコンストラクターは O(n) 操作です。

こちらもご覧ください

適用対象