queue.cs
来自「使用C#写的数据结构库(从链表到图)」· CS 代码 · 共 123 行
CS
123 行
using System;
namespace DataTypeDemo
{
/// <summary>
/// Queue 的摘要说明。
/// </summary>
public class Queue : linkList
{
private node qhead;
private node rear;
public Queue()
{
//
// TODO: 在此处添加构造函数逻辑
//
this.qhead = null;
this.rear = null;
}
/**
*CreateQueue
*
* <PARAM>
* <RETURN> -
* <NOTES>
* <HISTORY> 2004/6/21 by LiJun
*/
public void CreateQueue()
{
base.CreateLinkList();
this.rear = base.treil;
this.qhead = base.head;
}
/**
*CreateQueue
*
* <PARAM> object[] data
* <RETURN> -
* <NOTES>
* <HISTORY> 2004/6/21 by LiJun
*/
public void CreateQueue(object[] data)
{
this.CreateQueue();
base.CreateLinkList(data);
this.rear = base.treil.Up;
this.qhead = base.head.Next;
}
/**
*JoinQueue
*
* <PARAM> object data
* <RETURN> -
* <NOTES>
* <HISTORY> 2004/6/21 by LiJun
*/
public void JoinQueue(object data)
{
base.AddNode(data);
this.rear = base.treil.Up;
}
/**
*OutQueue
*
* <PARAM>
* <RETURN>object
* <NOTES>
* <HISTORY> 2004/6/21 by LiJun
*/
public object OutQueue()
{
object d = null;
if(this.isEmpty() != true)
{
this.qhead = base.head.Next;
d = this.qhead.Data;
base.DeleteNode(1);
//this.qhead = base.head.Next;
}
return d;
}
/**
*isEmpty
*
* <PARAM>
* <RETURN> bool
* <NOTES>
* <HISTORY> 2004/6/21 by LiJun
*/
public bool isEmpty()
{
if(this.qhead == this.rear)
{
return true;
}
else
{
return false;
}
}
/**
*SetEmpty
*
* <PARAM>
* <RETURN> -
* <NOTES>
* <HISTORY> 2004/6/21 by LiJun
*/
public override void SetEmpty()
{
base.SetEmpty ();
this.CreateQueue();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?