queuel.cpp

来自「Data Abstraction & Problem Solving with 」· C++ 代码 · 共 64 行

CPP
64
字号
// ********************************************************// Implementation file QueueL.cpp for the ADT queue.// ADT list implementation.// ********************************************************#include "QueueL.h"  // header fileQueue::Queue(){}  // end default constructorQueue::Queue(const Queue& Q): aList(Q.aList){}  // end copy constructorQueue::~Queue(){}  // end destructorbool Queue::isEmpty() const{   return (aList.getLength() == 0);}  // end isEmptyvoid Queue::enqueue(QueueItemType newItem) throw(QueueException){   try   {      aList.insert(aList.getLength()+1, newItem);   } // end try   catch (ListException e)   {      throw QueueException("QueueException: cannot enqueue item");   } // end catch}  // end enqueuevoid Queue::dequeue() throw(QueueException){   if (aList.isEmpty())      throw QueueException("QueueException: empty queue, cannot dequeue");   else      aList.remove(1);}  // end dequeuevoid Queue::dequeue(QueueItemType& queueFront) throw(QueueException){   if (aList.isEmpty())      throw QueueException("QueueException: empty queue, cannot dequeue");   else   {      aList.retrieve(1, queueFront);      aList.remove(1);   } // end if}  // end dequeuevoid Queue::getFront(QueueItemType& queueFront) const                      throw(QueueException){   if (!aList.isEmpty())      throw QueueException("QueueException: empty queue, cannot getFront");   else      aList.retrieve(1, queueFront);}  // end getFront// End of implementation file.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?