Question: - implement the Queue ADT using array based approach. Using C++ programming Language #include QueueArray.h template QueueArray ::QueueArray(int maxNumber) { } template QueueArray ::QueueArray(const QueueArray&

- implement the Queue ADT using array based approach. Using C++ programming Language

#include "QueueArray.h"

template QueueArray::QueueArray(int maxNumber) { }

template QueueArray::QueueArray(const QueueArray& other) { }

template QueueArray& QueueArray::operator=(const QueueArray& other) { }

template QueueArray::~QueueArray() { }

template void QueueArray::enqueue(const DataType& newDataItem) throw (logic_error) { }

template DataType QueueArray::dequeue() throw (logic_error) { DataType temp; return temp; }

template void QueueArray::clear() { }

template bool QueueArray::isEmpty() const { return false; }

template bool QueueArray::isFull() const { return false; }

template void QueueArray::putFront(const DataType& newDataItem) throw (logic_error) { }

template DataType QueueArray::getRear() throw (logic_error) { DataType temp; return temp; }

template int QueueArray::getLength() const { return -1; }

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

template void QueueArray::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 << " Back = " << back << endl; for ( j = 0 ; j < maxSize ; j++ ) cout << j << "\t"; cout << endl; if ( back >= front ) for ( j = 0 ; j < maxSize ; j++ ) if ( ( j >= front ) && ( j <= back ) ) cout << dataItems[j] << "\t"; else cout << " \t"; else for ( j = 0 ; j < maxSize ; j++ ) if ( ( j >= front ) || ( j <= back ) ) cout << dataItems[j] << "\t"; else cout << " \t"; cout << endl; } }

QueueArray.h

___-----------------------------------------------------------------------------

#ifndef QUEUEARRAY_H #define QUEUEARRAY_H

#include #include

using namespace std;

#include "Queue.h"

template class QueueArray : public Queue { public: QueueArray(int maxNumber = Queue::MAX_QUEUE_SIZE); QueueArray(const QueueArray& other); QueueArray& operator=(const QueueArray& other); ~QueueArray();

void enqueue(const DataType& newDataItem) throw (logic_error); DataType dequeue() throw (logic_error);

void clear();

bool isEmpty() const; bool isFull() const;

void putFront(const DataType& newDataItem) throw (logic_error); DataType getRear() throw (logic_error); int getLength() const;

void showStructure() const;

private: int maxSize; int front; int back; DataType* dataItems; };

#endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!