C# 链表结构(1)-结点
以一个类来定义结点类,其中包含结点数据值,前结点,后结点(双向链表的情况有前、后结点)。
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
作者:Ivan