LinkedListNode(T) クラス (System.Collections.Generic)

ビューの切り替え:
スクリプトなし
.NET Framework クラス ライブラリ
LinkedListNode<T> クラス
この記事は翻訳者によって翻訳されたものです。 このページおよび元の英語コンテンツを同時に表示させるには、[ライトウェイト] に切り替えます。

LinkedList<T> のノードを表します。 このクラスは継承できません。

継承階層

System.Object
  System.Collections.Generic.LinkedListNode<T>

名前空間:  System.Collections.Generic
アセンブリ:  System (System.dll 内)
構文

Visual Basic
<ComVisibleAttribute(False)> _
Public NotInheritable Class LinkedListNode(Of T)
C#
[ComVisibleAttribute(false)]
public sealed class LinkedListNode<T>

Visual C++
[ComVisibleAttribute(false)]
generic<typename T>
public ref class LinkedListNode sealed
F#
[<Sealed>]
[<ComVisibleAttribute(false)>]
type LinkedListNode<'T> =  class end

型パラメーター

T

リンク リストの要素の型を示します。

LinkedListNode<T> 型で公開されるメンバーは以下のとおりです。

コンストラクター

  名前 説明
パブリック メソッド XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif LinkedListNode<T> 指定した値を含んだ LinkedListNode<T> クラスの新しいインスタンスを初期化します。
このページのトップへ
プロパティ

  名前 説明
パブリック プロパティ XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif List LinkedListNode<T> が属する LinkedList<T> を取得します。
パブリック プロパティ XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif Next LinkedList<T> 内の次のノードを取得します。
パブリック プロパティ XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif Previous LinkedList<T> 内の前のノードを取得します。
パブリック プロパティ XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif Value ノードに格納された値を取得します。
このページのトップへ
メソッド

  名前 説明
パブリック メソッド XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif Equals(Object) 指定した Object が、現在の Object と等しいかどうかを判断します。 (Object から継承されます。)
プロテクト メソッド XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif Finalize オブジェクトがガベジ コレクションにより収集される前に、そのオブジェクトがリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。)
パブリック メソッド XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif GetHashCode 特定の型のハッシュ関数として機能します。 (Object から継承されます。)
パブリック メソッド XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif GetType 現在のインスタンスの Type を取得します。 (Object から継承されます。)
プロテクト メソッド XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif MemberwiseClone 現在の Object の簡易コピーを作成します。 (Object から継承されます。)
パブリック メソッド XNA Framework によるサポート ahf4c754.PortableClassLibrary(ja-jp,VS.100).gif ToString 現在のオブジェクトを表す文字列を返します。 (Object から継承されます。)
このページのトップへ
解説

LinkedList<T> コレクションの各要素は、LinkedListNode<T> です。 LinkedListNode<T> には、値、その値が属する LinkedList<T> への参照、次のノードへの参照、および前のノードへの参照が格納されます。


LinkedListNode<T> を作成して LinkedList<T> に追加し、LinkedList<T> が変更された場合に、プロパティ値を追跡するコード例を次に示します。

Visual Basic

Imports System
Imports System.Collections.Generic

Public Class GenericCollection

    Public Shared Sub Main()

        ' Create a new LinkedListNode of type String and displays its properties.
        Dim lln As New LinkedListNode(Of String)("orange")
        Console.WriteLine("After creating the node ....")
        DisplayProperties(lln)

        ' Create a new LinkedList.
        Dim ll As New LinkedList(Of String)

        ' Add the "orange" node and display its properties.
        ll.AddLast(lln)
        Console.WriteLine("After adding the node to the empty LinkedList ....")
        DisplayProperties(lln)

        ' Add nodes before and after the "orange" node and display the "orange" node's properties.
        ll.AddFirst("red")
        ll.AddLast("yellow")
        Console.WriteLine("After adding red and yellow ....")
        DisplayProperties(lln)

    End Sub 'Main

    Public Shared Sub DisplayProperties(lln As LinkedListNode(Of String))

        If lln.List Is Nothing Then
            Console.WriteLine("   Node is not linked.")
        Else
            Console.WriteLine("   Node belongs to a linked list with {0} elements.", lln.List.Count)
        End If 

        If lln.Previous Is Nothing Then
            Console.WriteLine("   Previous node is null.")
        Else
            Console.WriteLine("   Value of previous node: {0}", lln.Previous.Value)
        End If 

        Console.WriteLine("   Value of current node:  {0}", lln.Value)

        If lln.Next Is Nothing Then
            Console.WriteLine("   Next node is null.")
        Else
            Console.WriteLine("   Value of next node:     {0}", lln.Next.Value)
        End If 

        Console.WriteLine()

    End Sub 'DisplayProperties 

End Class 'GenericCollection


'This code produces the following output.
'
'After creating the node ....
'   Node is not linked.
'   Previous node is null.
'   Value of current node:  orange
'   Next node is null.
'
'After adding the node to the empty LinkedList ....
'   Node belongs to a linked list with 1 elements.
'   Previous node is null.
'   Value of current node:  orange
'   Next node is null.
'
'After adding red and yellow ....
'   Node belongs to a linked list with 3 elements.
'   Value of previous node: red
'   Value of current node:  orange
'   Value of next node:     yellow



C#

using System;
using System.Collections.Generic;

public class GenericCollection  {

   public static void Main()  {

      // Create a new LinkedListNode of type String and displays its properties.
      LinkedListNode<String> lln = new LinkedListNode<String>( "orange" );
      Console.WriteLine( "After creating the node ...." );
      DisplayProperties( lln );

      // Create a new LinkedList.
      LinkedList<String> ll = new LinkedList<String>();

      // Add the "orange" node and display its properties.
      ll.AddLast( lln );
      Console.WriteLine( "After adding the node to the empty LinkedList ...." );
      DisplayProperties( lln );

      // Add nodes before and after the "orange" node and display the "orange" node's properties.
      ll.AddFirst( "red" );
      ll.AddLast( "yellow" );
      Console.WriteLine( "After adding red and yellow ...." );
      DisplayProperties( lln );

   }

   public static void DisplayProperties( LinkedListNode<String> lln )  {
      if ( lln.List == null )
         Console.WriteLine( "   Node is not linked." );
      else
         Console.WriteLine( "   Node belongs to a linked list with {0} elements.", lln.List.Count );

      if ( lln.Previous == null )
         Console.WriteLine( "   Previous node is null." );
      else
         Console.WriteLine( "   Value of previous node: {0}", lln.Previous.Value );

      Console.WriteLine( "   Value of current node:  {0}", lln.Value );

      if ( lln.Next == null )
         Console.WriteLine( "   Next node is null." );
      else
         Console.WriteLine( "   Value of next node:     {0}", lln.Next.Value );

      Console.WriteLine();
   }

}


/*

This code produces the following output.

After creating the node ....
   Node is not linked.
   Previous node is null.
   Value of current node:  orange
   Next node is null.

After adding the node to the empty LinkedList ....
   Node belongs to a linked list with 1 elements.
   Previous node is null.
   Value of current node:  orange
   Next node is null.

After adding red and yellow ....
   Node belongs to a linked list with 3 elements.
   Value of previous node: red
   Value of current node:  orange
   Value of next node:     yellow

*/


Visual C++

#using <System.dll>

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

public ref class GenericCollection  {

public:
   static void Main()  {

      // Create a new LinkedListNode of type String and displays its properties.
      LinkedListNode<String^>^ lln = gcnew LinkedListNode<String^>( "orange" );
      Console::WriteLine( "After creating the node ...." );
      DisplayProperties( lln );

      // Create a new LinkedList.
      LinkedList<String^>^ ll = gcnew LinkedList<String^>();

      // Add the "orange" node and display its properties.
      ll->AddLast( lln );
      Console::WriteLine( "After adding the node to the empty LinkedList ...." );
      DisplayProperties( lln );

      // Add nodes before and after the "orange" node and display the "orange" node's properties.
      ll->AddFirst( "red" );
      ll->AddLast( "yellow" );
      Console::WriteLine( "After adding red and yellow ...." );
      DisplayProperties( lln );

   }

   static void DisplayProperties( LinkedListNode<String^>^ lln )  {
      if ( lln->List == nullptr )
         Console::WriteLine( "   Node is not linked." );
      else
         Console::WriteLine( "   Node belongs to a linked list with {0} elements.", lln->List->Count );

      if ( lln->Previous == nullptr )
         Console::WriteLine( "   Previous node is null." );
      else
         Console::WriteLine( "   Value of previous node: {0}", lln->Previous->Value );

      Console::WriteLine( "   Value of current node:  {0}", lln->Value );

      if ( lln->Next == nullptr )
         Console::WriteLine( "   Next node is null." );
      else
         Console::WriteLine( "   Value of next node:     {0}", lln->Next->Value );

      Console::WriteLine();
   }

};

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

/*

This code produces the following output.

After creating the node ....
   Node is not linked.
   Previous node is null.
   Value of current node:  orange
   Next node is null.

After adding the node to the empty LinkedList ....
   Node belongs to a linked list with 1 elements.
   Previous node is null.
   Value of current node:  orange
   Next node is null.

After adding red and yellow ....
   Node belongs to a linked list with 3 elements.
   Value of previous node: red
   Value of current node:  orange
   Value of next node:     yellow

*/


バージョン情報

.NET Framework

サポート対象: 4、3.5、3.0、2.0

.NET Framework Client Profile

サポート対象: 4、3.5 SP1

サポート対象:
プラットフォーム

Windows 7, Windows Vista SP1 以降, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core はサポート対象外), Windows Server 2008 R2 (SP1 以降で Server Core をサポート), Windows Server 2003 SP2

.NET Framework では、各プラットフォームのすべてのバージョンはサポートしていません。 サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
スレッド セーフ

この型のすべてのパブリック static (Visual Basic では Shared) メンバーは、スレッド セーフです。 インスタンス メンバーの場合は、スレッド セーフであるとは限りません。
参照

参照