您的位置:首页 > 编程语言 > C#

C# 链表结构(1)-结点

2012-02-09 17:55 337 查看
以一个类来定义结点类,其中包含结点数据值,前结点,后结点(双向链表的情况有前、后结点)。

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: