//--------------------------------------------------------------------
//
//  Laboratory 6                                          show6.cpp
//
//  Array and linked list implementations of the showStructure
//  operation for the Queue ADT
//
//--------------------------------------------------------------------

template < class DT >
void Queue<DT>:: showStructure () const

// Array implementation. Outputs the data items in a queue. If the
// queue is empty, outputs "Empty queue". This operation is intended
// for testing and debugging purposes only.

{
    int j;   // Loop counter

    if ( front == -1 )
       cout << "Empty queue" << endl;
    else
    {
       cout << "front = " << front << "  rear = " << rear << endl;
       for ( j = 0 ; j < maxSize ; j++ )
           cout << j << "\t";
       cout << endl;
       if ( rear >= front )
          for ( j = 0 ; j < maxSize ; j++ )
              if ( ( j >= front ) && ( j <= rear ) )
                 cout << dataItems[j] << "\t";
              else
                 cout << " \t";
       else
          for ( j = 0 ; j < maxSize ; j++ )
              if ( ( j >= front ) || ( j <= rear ) )
                 cout << dataItems[j] << "\t";
              else
                 cout << " \t";
       cout << endl;
    }
}

//--------------------------------------------------------------------

template < class DT >
void Queue<DT>:: showStructure () const

// Linked list implementation. Outputs the elements in a queue. If
// the queue is empty, outputs "Empty queue". This operation is
// intended for testing and debugging purposes only.

{
    QueueNode<DT> *p;   // Iterates through the queue

    if ( front == 0 )
       cout << "Empty queue" << endl;
    else
    {
       cout << "front ";
       for ( p = front ; p != 0 ; p = p->next )
           cout << p->dataItem << " ";
       cout << "rear" << endl;
    }
}


