您的问题似乎不完整,您是想询问关于C语言编程的某个具体问题吗?比如C语言的语法、编程技巧、项目开发等。请提供更具体的信息,这样我才能给出更准确的回答。
- 内容介绍
- 文章标签
- 相关推荐
本文共计335个文字,预计阅读时间需要2分钟。
队列和栈都是基于链表的约束版数据结构,就像在超市购物,队列是先进先出的数据结构。接下来,我将展示一个基于链表类List的队列实现。
javanamespace LinkedListLibrary{ public class QueueInheritance : List { // 模拟一个队列 }}
队列和堆栈都是约束版的链表,就像在超市购物,队列是先进先出的数据结构。
接着上一篇,派生于链表类List,来模拟一个队列。
namespace LinkedListLibrary { public class QueueInheritance : List { public QueueInheritance() : base("queue"){} //入队:到最后面 public void Enqueue(object dataValue) { InsertAtBack(dataValue); } //出队:在最前面删除 public object Dequeue() { return RemoveFromFront(); } } }
客户端调用。
public static void Main(string[] args) { QueueInheritance queue = new QueueInheritance(); bool aBoolean = true; char aChar = 'a'; int anInt = 1; string aStr = "hello"; queue.Enqueue(aBoolean); queue.Display(); queue.Enqueue(aChar); queue.Display(); queue.Enqueue(anInt); queue.Display(); queue.Enqueue(aStr); queue.Display(); object removedObject = null; try { while (true) { removedObject = queue.Dequeue(); Console.WriteLine(removedObject + "出队列~~"); queue.Display(); } } catch (EmptyListException emptyListException) { Console.Error.WriteLine(emptyListException.StackTrace); } Console.ReadKey(); }
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对自由互联的支持。如果你想了解更多相关内容请查看下面相关链接
本文共计335个文字,预计阅读时间需要2分钟。
队列和栈都是基于链表的约束版数据结构,就像在超市购物,队列是先进先出的数据结构。接下来,我将展示一个基于链表类List的队列实现。
javanamespace LinkedListLibrary{ public class QueueInheritance : List { // 模拟一个队列 }}
队列和堆栈都是约束版的链表,就像在超市购物,队列是先进先出的数据结构。
接着上一篇,派生于链表类List,来模拟一个队列。
namespace LinkedListLibrary { public class QueueInheritance : List { public QueueInheritance() : base("queue"){} //入队:到最后面 public void Enqueue(object dataValue) { InsertAtBack(dataValue); } //出队:在最前面删除 public object Dequeue() { return RemoveFromFront(); } } }
客户端调用。
public static void Main(string[] args) { QueueInheritance queue = new QueueInheritance(); bool aBoolean = true; char aChar = 'a'; int anInt = 1; string aStr = "hello"; queue.Enqueue(aBoolean); queue.Display(); queue.Enqueue(aChar); queue.Display(); queue.Enqueue(anInt); queue.Display(); queue.Enqueue(aStr); queue.Display(); object removedObject = null; try { while (true) { removedObject = queue.Dequeue(); Console.WriteLine(removedObject + "出队列~~"); queue.Display(); } } catch (EmptyListException emptyListException) { Console.Error.WriteLine(emptyListException.StackTrace); } Console.ReadKey(); }
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对自由互联的支持。如果你想了解更多相关内容请查看下面相关链接

