Пример #1
0
void QueueType<ItemType>::Enqueue(ItemType i)
{
    if(IsFull())
    {
        throw FullQueue();
    }

    else
    {
        NodeType<ItemType> *location;
        location = new NodeType<ItemType>;
        location->info = i;
        location->next = NULL;

        if(rear == NULL)
            front = location;

        else
            rear->next = location;

        rear = location;
    }
}
Пример #2
0
void QueType::Enqueue(ItemType newItem)
// Adds newItem to the rear of the queue.
// Pre:  Queue has been initialized.
// Post: If (queue is not full) newItem is at the rear of the queue;
//       otherwise a FullQueue exception is thrown.  

{
  if (IsFull())
    throw FullQueue();
  else
  {
    NodeType* newNode;

    newNode = new NodeType;
    newNode->info = newItem;
    newNode->next = NULL;
    if (rear == NULL)
      front = newNode;
    else
      rear->next = newNode;
    rear = newNode;
  }
}