Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education