This chapter describes the array implementation of queues that use a special array slot, called the reserved slot, to distinguish between an empty and a full queue. Write the definition of the class and the definitions of the function members of this queue design. Also, write a program (in main.cpp) to test various operations on a queue. //Header file QueueAsArray   #ifndef H_QueueAsArray #define H_QueueAsArray   #include #include   using namespace std;   template class queueType { public:     const queueType& operator=(const queueType&);             // overload the assignment operator     void initializeQueue();     int isEmptyQueue() const;     int isFullQueue() const;       Type front() const;       Type back() const;       void addQueue(Type queueElement);     void deleteQueue();       queueType(int queueSize = 100);     queueType(const queueType& otherQueue); // copy constructor     ~queueType(); //destructor   private:     int maxQueueSize;     int queueFront;     int queueRear;     Type *list; //pointer to array that holds queue elements };   //TODO: Write method definitions here #endif //Header file: queueADT.h   #ifndef H_queueADT #define H_queueADT    template class queueADT { public:     virtual bool isEmptyQueue() const = 0;       //Function to determine whether the queue is empty.       //Postcondition: Returns true if the queue is empty,       //               otherwise returns false.       virtual bool isFullQueue() const = 0;       //Function to determine whether the queue is full.       //Postcondition: Returns true if the queue is full,       //               otherwise returns false.       virtual void initializeQueue() = 0;       //Function to initialize the queue to an empty state.       //Postcondition: The queue is empty.       virtual Type front() const = 0;       //Function to return the first element of the queue.       //Precondition: The queue exists and is not empty.       //Postcondition: If the queue is empty, the program       //               terminates; otherwise, the first       //               element of the queue is returned.         virtual Type back() const = 0;       //Function to return the last element of the queue.       //Precondition: The queue exists and is not empty.       //Postcondition: If the queue is empty, the program       //               terminates; otherwise, the last       //               element of the queue is returned.       virtual void addQueue(const Type& queueElement) = 0;       //Function to add queueElement to the queue.       //Precondition: The queue exists and is not full.       //Postcondition: The queue is changed and queueElement       //               is added to the queue.       virtual void deleteQueue() = 0;       //Function to remove the first element of the queue.       //Precondition: The queue exists and is not empty.       //Postcondition: The queue is changed and the first       //               element is removed from the queue. };            #endif

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This chapter describes the array implementation of queues that use a special array slot, called the reserved slot, to distinguish between an empty and a full queue.

Write the definition of the class and the definitions of the function members of this queue design.

Also, write a program (in main.cpp) to test various operations on a queue.

//Header file QueueAsArray

 

#ifndef H_QueueAsArray

#define H_QueueAsArray

 

#include <iostream>

#include <cassert>

 

using namespace std;

 

template<class Type>

class queueType

{

public:

    const queueType<Type>& operator=(const queueType<Type>&);

            // overload the assignment operator

    void initializeQueue();

    int isEmptyQueue() const;

    int isFullQueue() const;

 

    Type front() const;

 

    Type back() const;

 

    void addQueue(Type queueElement);

    void deleteQueue();

 

    queueType(int queueSize = 100);

    queueType(const queueType<Type>& otherQueue); // copy constructor

    ~queueType(); //destructor

 

private:

    int maxQueueSize;

    int queueFront;

    int queueRear;

    Type *list; //pointer to array that holds queue elements

};

 

//TODO: Write method definitions here



#endif


//Header file: queueADT.h

 

#ifndef H_queueADT

#define H_queueADT

  

template <class Type>

class queueADT

{

public:

    virtual bool isEmptyQueue() const = 0;

      //Function to determine whether the queue is empty.

      //Postcondition: Returns true if the queue is empty,

      //               otherwise returns false.

 

    virtual bool isFullQueue() const = 0;

      //Function to determine whether the queue is full.

      //Postcondition: Returns true if the queue is full,

      //               otherwise returns false.

 

    virtual void initializeQueue() = 0;

      //Function to initialize the queue to an empty state.

      //Postcondition: The queue is empty.

 

    virtual Type front() const = 0;

      //Function to return the first element of the queue.

      //Precondition: The queue exists and is not empty.

      //Postcondition: If the queue is empty, the program

      //               terminates; otherwise, the first

      //               element of the queue is returned.  

 

    virtual Type back() const = 0;

      //Function to return the last element of the queue.

      //Precondition: The queue exists and is not empty.

      //Postcondition: If the queue is empty, the program

      //               terminates; otherwise, the last

      //               element of the queue is returned.

 

    virtual void addQueue(const Type& queueElement) = 0;

      //Function to add queueElement to the queue.

      //Precondition: The queue exists and is not full.

      //Postcondition: The queue is changed and queueElement

      //               is added to the queue.

 

    virtual void deleteQueue() = 0;

      //Function to remove the first element of the queue.

      //Precondition: The queue exists and is not empty.

      //Postcondition: The queue is changed and the first

      //               element is removed from the queue.

};

 

        

#endif

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education