国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#通過鏈表實現隊列的方法

2020-01-24 01:54:49
字體:
來源:轉載
供稿:網友

本文實例講述了C#通過鏈表實現隊列的方法。分享給大家供大家參考。具體實現方法如下:

public class Node{ public int Data { get; set; } public Node Next { get; set; } public Node(int data) {   this.Data = data; }}public class Queue{ private Node _head; private Node _tail; private int _count = 0; public Queue() { } public void Enqueue(int data) {   Node _newNode = new Node(data);   if (_head == null)   {    _head = _newNode;    _tail = _head;   }   else   {    _tail.Next = _newNode;    _tail = _tail.Next;   }   _count++; } public int Dequeue() {   if (_head == null)   {    throw new Exception("Queue is Empty");   }   int _result = _head.Data;   _head = _head.Next;   return _result; } public int Count {   get   {    return this._count;   } }}

希望本文所述對大家的C#程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 赣州市| 新沂市| 大城县| 高雄市| 嵊泗县| 余江县| 罗山县| 资溪县| 黔西县| 阿尔山市| 巧家县| 南陵县| 马山县| 大方县| 上林县| 嘉鱼县| 松潘县| 土默特右旗| 敦化市| 中山市| 厦门市| 玉龙| 德江县| 盐边县| 长沙市| 古交市| 内江市| 哈巴河县| 芒康县| 徐汇区| 双鸭山市| 南丹县| 凤山县| 西丰县| 萍乡市| 阳高县| 通化市| 依兰县| 加查县| 连城县| 普格县|