Given the interface (header file) of a parametroc Deque below, write its implementation: Listing 3: A Parameterized Deque Class template class Deque { private : /∗∗   ∗ Forward Declaration of the parametric nested   ∗ class representing node objects of the deque   ∗/ template class Node; /∗∗   ∗ A pointer to the head node of this deque   ∗/ Node∗ head;  /∗∗    ∗ A pointer to the rear node of this deque    ∗/ Node∗ rear; /∗∗   ∗ The number of nodes that this deque has   ∗/ int length ; public : /∗∗   ∗ Constructs an empty Deque ;   ∗/   Deque() ; /∗∗   ∗ Copy constructor .   ∗/   Deque(const Deque& aDeque); /∗∗   ∗ destructor − returns the deque’s memory to the system←֓         ;   ∗/ ̃Deque() ; /∗∗   ∗ Determine whether the deque is empty.   ∗ @return true if the the deque is empty;   ∗ otherwise, it returns false .   ∗/   bool isEmpty () const ; /∗∗   ∗ Inserts an item at the front of the deque.   ∗ @param item the value to be inserted .   ∗/   void pushFront(T item ) ; /∗∗   ∗ Inserts an item at the back of the deque.   ∗ @param item the value to be inserted .   ∗/   void pushBack(T item); /∗∗   ∗ Returns the item at the front of a non−empty deque.   ∗ @return item at the front of   ∗ @throw a DequeException when this deque is empty   ∗/   const T& front () const ; /∗∗   ∗ Returns the item at the back   ∗ @return item at the back of the queue.   ∗ @throw a DequeException when t h i s deque i s empty   ∗/   const T& back() const; /∗∗   ∗ Deletes an item from the front of the dequeue.   ∗ @return the item at the front of the queue.   ∗ @throw a DequeException when this deque is empty.   ∗/   T popFront(); /∗∗   ∗ Deletes an item from the back of the dequeue.   ∗ @return the item at the back of the queue.   ∗ @throw a DequeException when this deque is empty.   ∗/   T popBack(); /∗∗   ∗ Allows access to the element at the specified index   ∗ @param index the subscript of the element.   ∗ @return a reference to an element.   ∗ @throw a DequeException when index < 0   ∗ or index > length−1   ∗/ T& operator[](int index); /∗∗   ∗ @return the size of the deque   ∗/    int size() const; }; /∗∗    ∗ Definition of the nested Node class    ∗/   template   template   class Deque::Node  {   private :  /∗∗    ∗ The data item in this node    ∗/  T data;  /∗∗    ∗ The pointer to the previous node    ∗/ Node∗ prev; /∗∗   ∗ The pointer to the next node   ∗/ Node∗ next; /∗∗   ∗ Makes private members of this class accessible   ∗ in the Deque class   ∗/ friend class Deque; public : /∗∗   ∗ Constructs a node with a given data value.   ∗ @param s the data to store in this node   ∗/   Node(T s); };

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
100%

Given the interface (header file) of a parametroc Deque<T> below, write its implementation:

Listing 3: A Parameterized Deque Class

template <typename T>

class Deque

{

private :

/∗∗

  ∗ Forward Declaration of the parametric nested

  ∗ class representing node objects of the deque

  ∗/

template <typename U> class Node;

/∗∗

  ∗ A pointer to the head node of this deque

  ∗/
Node<T>∗ head;

 /∗∗

   ∗ A pointer to the rear node of this deque

   ∗/
Node<T>∗ rear;

/∗∗

  ∗ The number of nodes that this deque has

  ∗/
int length ;

public :
/∗∗

  ∗ Constructs an empty Deque ;

  ∗/
  Deque() ;

/∗∗
  ∗ Copy constructor .
  ∗/
  Deque(const Deque<T>& aDeque);

/∗∗
  ∗ destructor − returns the deque’s memory to the system←֓

        ;

  ∗/

̃Deque() ;

/∗∗
  ∗ Determine whether the deque is empty.
  ∗ @return true if the the deque is empty;

  ∗ otherwise, it returns false .
  ∗/
  bool isEmpty () const ;

/∗∗
  ∗ Inserts an item at the front of the deque.

  ∗ @param item the value to be inserted .
  ∗/
  void pushFront(T item ) ;

/∗∗
  ∗ Inserts an item at the back of the deque.

  ∗ @param item the value to be inserted .
  ∗/
  void pushBack(T item);

/∗∗
  ∗ Returns the item at the front of a non−empty deque.

  ∗ @return item at the front of

  ∗ @throw a DequeException when this deque is empty

  ∗/
  const T& front () const ;

/∗∗
  ∗ Returns the item at the back
  ∗ @return item at the back of the queue.
  ∗ @throw a DequeException when t h i s deque i s empty

  ∗/
  const T& back() const;

/∗∗
  ∗ Deletes an item from the front of the dequeue.
  ∗ @return the item at the front of the queue.
  ∗ @throw a DequeException when this deque is empty.

  ∗/

  T popFront();

/∗∗
  ∗ Deletes an item from the back of the dequeue.
  ∗ @return the item at the back of the queue.
  ∗ @throw a DequeException when this deque is empty.

  ∗/

  T popBack();

/∗∗
  ∗ Allows access to the element at the specified index

  ∗ @param index the subscript of the element.
  ∗ @return a reference to an element.
  ∗ @throw a DequeException when index < 0
  ∗ or index > length−1
  ∗/

T& operator[](int index);

/∗∗
  ∗ @return the size of the deque

  ∗/
   int size() const;

};

/∗∗
   ∗ Definition of the nested Node class

   ∗/

  template <typename U>

  template <typename T>

  class Deque<U>::Node

 {

  private :

 /∗∗

   ∗ The data item in this node

   ∗/
 T data;

 /∗∗
   ∗ The pointer to the previous node

   ∗/

Node<T>∗ prev;

/∗∗

  ∗ The pointer to the next node

  ∗/
Node<T>∗ next;

/∗∗

  ∗ Makes private members of this class accessible

  ∗ in the Deque<T> class
  ∗/

friend class Deque<U>;

public :
/∗∗

  ∗ Constructs a node with a given data value.

  ∗ @param s the data to store in this node
  ∗/
  Node(T s);

};

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Linked List Representation
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
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