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);
};
Step by stepSolved in 3 steps
- Implement a nested class composition relationship between any two class types from the following list: Advisor Вook Classroom Department Friend Grade School Student Teacher Tutor Write all necessary code for both classes to demonstrate a nested composition relationship including the following: a. one encapsulated data member for each class b. inline default constructor using constructor delegation for each class c. inline one-parameter constructor for each class d. inline accessors for all data members e. inline mutators for all data membersarrow_forwardDraw a class diagram for the parking office class below. Diagram shoukd not be hand drawn. N.B Parking office class has relations and dependencies with car, customer, parkinglot and parking charge classes. public class ParkingOffice {String name;String address;String phone;List<Customer> customers;List<Car> cars;List<ParkingLot> lots;List<ParkingCharge> charges; public ParkingOffice(){customers = new ArrayList<>();cars = new ArrayList<>();lots = new ArrayList<>();charges = new ArrayList<>();}public Customer register() {Customer cust = new Customer(name,address,phone);customers.add(cust);return cust;}public Car register(Customer c,String licence, CarType t) {Car car = new Car(c,licence,t);cars.add(car);return car;}public Customer getCustomer(String name) {for(Customer cust : customers)if(cust.getName().equals(name))return cust;return null;}public double addCharge(ParkingCharge p) {charges.add(p);return p.amount;}public String[]…arrow_forwardProgram #11. Show the ArrayStackADT interface 2. Create the ArrayStackDataStrucClass<T> with the following methods: default constructor, overloaded constructor, copy constructor, initializeStack, isEmptyStack, isFullStack, push, peek, void pop 3. Create the PrimeFactorizationDemoClass: instantiate an ArrayStackDataStrucClass<Integer> object with 50 elements. Use a try-catch block in the main( ) using pushes/pops. 4. Exception classes: StackException, StackUnderflowException, StackOverflowException 5. Show the 4 outputs for the following: 3,960 1,234 222,222 13,780arrow_forward
- 8. Following is the node class: class node { int v node *next: public: node(int x) {v=x; next3D03;} friend class list: }3; Implement the sequential list class below: class list { // circular list class // head position node *head; public: bool empty() { return !head;} list() {head-0;} ~list(); void add(int x); int get(); // empty list judgment / constructor // destructor, to be implemented // add to tail, to be implemented // get from head, to be implemented }3Barrow_forwardHelp pls: Write the definitions of the following functions: getRemainingTransactionTime setCurrentCustomer getCurrentCustomerNumber getCurrentCustomerArrivalTime getCurrentCustomerWaitingTime getCurrentCustomerTransactionTime of the class serverType defined in the section Application of Queues: Simulation. serverType::serverType() { status = "free"; transactionTime = 0; } bool serverType::isFree() const { return (status == "free"); } void serverType::setBusy() { status = "busy"; } void serverType::setFree() { status = "free"; } void serverType::setTransactionTime(int t) { transactionTime = t; } void serverType::setTransactionTime() { //TODO: uncomment once getTransactionTime is defined /* int time; time = currentCustomer.getTransactionTime(); transactionTime = time; */ } void serverType::decreaseTransactionTime() { transactionTime--; }arrow_forwardJava (Generic Types) - Zip Code and Populationarrow_forward
- Fix this code for any errorsarrow_forwardGiven the following specification of a front operation for queue:ItemType Front Function: Returns a copy of the front item on the queue. Precondition: Queue is not empty. Postcondition: Queue is not changed. 1. Write this operation as client code, using operations from the QueType class. (Remember,the client code has no access to the private variables of the class). 2. Write this function as a new member function of the QueType class. help me with complete codearrow_forwardcomptuer sciecne helparrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education