C#チェーンテーブル構造(1)-ノード
6851 ワード
ノード・クラスを定義します.ノード・データ値、前ノード、後ノード(双方向チェーン・テーブルの場合、前ノード、後ノード)が含まれます.
参照:http://www.cnblogs.com/linzheng/news/2011/07/14/2106530.html
using System;
using System.Collections.Generic;
using System.Text;
namespace Csharp
{
public class Node<T> where T : IComparable<T>
{
T data;
/// <summary>
/// the current data
/// </summary>
public T Data
{
get
{
return this.data;
}
set
{
this.data = value;
}
}
Node<T> next;
/// <summary>
/// the next node
/// </summary>
public Node<T> Next
{
get
{
return this.next;
}
set
{
this.next = value;
}
}
Node<T> prev;
/// <summary>
/// the prev node
/// </summary>
public Node<T> Prev
{
get
{
return this.prev;
}
set
{
this.prev = value;
}
}
/// <summary>
/// no arguments to constitution
/// </summary>
public Node()
{
this.data = default(T);
this.next = null;
this.prev = null;
}
/// <summary>
/// one data to constitution
/// </summary>
/// <param name="t">a data</param>
public Node(T t)
{
this.data = t;
this.next = null;
this.prev = null;
}
/// <summary>
/// three data to constitution
/// </summary>
/// <param name="t">the current data</param>
/// <param name="next_">the next data</param>
/// <param name="prev_">the previous data</param>
public Node(T t, Node<T> next_, Node<T> prev_)
{
this.data = t;
this.next = next_;
this.prev = prev_;
}
}
}
参照:http://www.cnblogs.com/linzheng/news/2011/07/14/2106530.html