zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    HTTP协议详解
    如何编写出拥抱变化的代码
    Cookie ,Session
    Request 请求
    MySQL如何处理死锁
    如何优化冒泡排序
    java数据结构分析
    response响应
    Tomcat服务器
    HTTP协议
  • 原文地址:https://www.cnblogs.com/oneivan/p/2344311.html
Copyright © 2011-2022 走看看