一个双链表节点的类,还比较常用,记录一下。
class DoubleLinkedNode<T>
{
public DoubleLinkedNode(T value)
{
this.Value = value;
}
public T Value { get; set; }
DoubleLinkedNode<T> next;
public DoubleLinkedNode<T> Next
{
get { return next; }
set
{
next = value;
if (next != null)
next.previous = this;
}
}
DoubleLinkedNode<T> previous;
public DoubleLinkedNode<T> Previous
{
get { return previous; }
set
{
previous = value;
if (previous != null)
previous.next = this;
}
}
public override string ToString()
{
return Value.ToString();
}
}