implement the Queue ADT using the linked list approach inclu
implement the Queue ADT using the linked list approach
#include \"QueueLinked.h\"
template
QueueLinked::QueueNode::QueueNode(const DataType& nodeData, QueueNode* nextPtr)
{
}
template
QueueLinked::QueueLinked(int maxNumber = Queue::MAX_QUEUE_SIZE)
{
}
template
QueueLinked::QueueLinked(const QueueLinked& other)
{
}
template
QueueLinked& QueueLinked::operator=(const QueueLinked& other)
{
}
template
QueueLinked::~QueueLinked()
{
}
template
void QueueLinked::enqueue(const DataType& newDataItem) throw (logic_error)
{
}
template
DataType QueueLinked::dequeue() throw (logic_error)
{
DataType temp;
return temp;
}
template
void QueueLinked::clear()
{
}
template
bool QueueLinked::isEmpty() const
{
return false;
}
template
bool QueueLinked::isFull() const
{
return false;
}
template
void QueueLinked::putFront(const DataType& newDataItem) throw (logic_error)
{
}
template
DataType QueueLinked::getRear() throw (logic_error)
{
DataType temp;
return temp;
}
template
int QueueLinked::getLength() const
{
}
template
void QueueLinked::showStructure() const
{
QueueNode *p; // Iterates through the queue
if ( isEmpty() )
cout << \"Empty queue\" << endl;
else
{
cout << \"Front\\t\";
for ( p = front ; p != 0 ; p = p->next )
{
if( p == front )
{
cout << \'[\' << p->dataItem << \"] \";
}
else
{
cout << p->dataItem << \" \";
}
}
cout << \"\\trear\" << endl;
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------
// QueueLinked.h
#include
#include
using namespace std;
#include \"Queue.h\"
template
class QueueLinked : public Queue {
public:
QueueLinked(int maxNumber = Queue::MAX_QUEUE_SIZE);
QueueLinked(const QueueLinked& other);
QueueLinked& operator=(const QueueLinked& other);
~QueueLinked();
void enqueue(const DataType& newDataItem) throw (logic_error);
DataType dequeue() throw (logic_error);
void clear();
bool isEmpty() const;
bool isFull() const;
// Programming Exercise 2
void putFront(const DataType& newDataItem) throw (logic_error);
DataType getRear() throw (logic_error);
// Programming Exercise 3
int getLength() const;
void showStructure() const;
private:
class QueueNode {
public:
QueueNode(const DataType& nodeData, QueueNode* nextPtr);
DataType dataItem;
QueueNode* next;
};
QueueNode* front;
QueueNode* back;
};
---------------------------------------------------------------------------------------------------
// QueueLinked.h
#include <stdexcept>
#include <iostream>
using namespace std;
#include \"Queue.h\"
template <typename DataType>
class QueueLinked : public Queue<DataType> {
public:
QueueLinked(int maxNumber = Queue<DataType>::MAX_QUEUE_SIZE);
QueueLinked(const QueueLinked& other);
QueueLinked& operator=(const QueueLinked& other);
~QueueLinked();
void enqueue(const DataType& newDataItem) throw (logic_error);
DataType dequeue() throw (logic_error);
void clear();
bool isEmpty() const;
bool isFull() const;
// Programming Exercise 2
void putFront(const DataType& newDataItem) throw (logic_error);
DataType getRear() throw (logic_error);
// Programming Exercise 3
int getLength() const;
void showStructure() const;
private:
class QueueNode {
public:
QueueNode(const DataType& nodeData, QueueNode* nextPtr);
DataType dataItem;
QueueNode* next;
};
QueueNode* front;
QueueNode* back;
};
Solution
#include
#include
using namespace std;
#include \"Queue.h\"
template
class QueueLinked : public Queue {
public:
QueueLinked(int maxNumber = Queue::MAX_QUEUE_SIZE);
QueueLinked(const QueueLinked& other);
QueueLinked& operator=(const QueueLinked& other);
~QueueLinked();
void enqueue(const DataType& newDataItem) throw (logic_error);
DataType dequeue() throw (logic_error);
void clear();
bool isEmpty() const;
bool isFull() const;
// Programming Exercise 2
void putFront(const DataType& newDataItem) throw (logic_error);
DataType getRear() throw (logic_error);
// Programming Exercise 3
int getLength() const;
void showStructure() const;
private:
class QueueNode {
public:
QueueNode(const DataType& nodeData, QueueNode* nextPtr);
DataType dataItem;
QueueNode* next;
};
QueueNode* front;
QueueNode* back;
};
---------------------------------------------------------------------------------------------------
// QueueLinked.h
#include <stdexcept>
#include <iostream>
using namespace std;
#include \"Queue.h\"
template <typename DataType>
class QueueLinked : public Queue<DataType> {
public:
QueueLinked(int maxNumber = Queue<DataType>::MAX_QUEUE_SIZE);
QueueLinked(const QueueLinked& other);
QueueLinked& operator=(const QueueLinked& other);
~QueueLinked();
void enqueue(const DataType& newDataItem) throw (logic_error);
DataType dequeue() throw (logic_error);
void clear();
bool isEmpty() const;
bool isFull() const;
// Programming Exercise 2
void putFront(const DataType& newDataItem) throw (logic_error);
DataType getRear() throw (logic_error);
// Programming Exercise 3
int getLength() const;
void showStructure() const;
private:
class QueueNode {
public:
QueueNode(const DataType& nodeData, QueueNode* nextPtr);
DataType dataItem;
QueueNode* next;
};
QueueNode* front;
QueueNode* back;
};




