LinkedList<T> コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
LinkedList<T> クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| 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 ()
例
次のコード例では、String型のLinkedList<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>は、参照型の有効なValueとしてnullを受け入れ、重複する値を許可します。
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>。
例外
collection は nullです。
例
このコンストラクターを含む例については、 LinkedList<T> クラスを参照してください。
注釈
LinkedList<T>は、参照型の有効なValueとしてnullを受け入れ、重複する値を許可します。
collectionに要素がない場合、新しいLinkedList<T>は空になり、FirstプロパティとLastプロパティにはnullが含まれます。
このコンストラクターは 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のシリアル化に必要な情報を格納しているLinkedList<T> オブジェクト。
- context
- StreamingContext
LinkedList<T>に関連付けられたシリアル化ストリームのソースと宛先を格納しているStreamingContext オブジェクト。
注釈
LinkedList<T>は、参照型の有効なValueとしてnullを受け入れ、重複する値を許可します。
LinkedList<T>が空の場合、FirstプロパティとLastプロパティにはnullが含まれます。
このコンストラクターは O(n) 操作です。