⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queue.cs

📁 使用C#写的数据结构库(从链表到图)
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -