Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include template class DList{ struct Node{ T data_; Node* next_; Node* prev_; Node(const T& data=T{},Node* next=nullptr, Node* prev=nullptr){ data_=data; next_=next; prev_=prev; } }; Node* front_;

#include
template
class DList{
struct Node{
T data_;
Node* next_;
Node* prev_;
Node(const T& data=T{},Node* next=nullptr, Node* prev=nullptr){
data_=data;
next_=next;
prev_=prev;
}
};
Node* front_;
Node* back_;
public:
DList(){
front_=nullptr;
back_=nullptr;
}
void push_front(const T& data);
void push_back(const T& data);
void pop_front();
void pop_back();
int getData(int data[]) const;
int getReverseData(int data[]) const;
~DList();
};
template
void DList::push_front(const T& data){
}
template
void DList::push_back(const T& data){
}
template
void DList::pop_front(){
}
template
void DList::pop_back(){
}
template
int DList::getData(int data[]) const{
Node* curr=front_;
int numData=0;
while(curr!=nullptr){
data[numData++]=curr->data_;
curr=curr->next_;
}
return numData;
}
template
int DList::getReverseData(int data[]) const{
Node* curr=back_;
int numData=0;
while(curr!=nullptr){
data[numData++]=curr->data_;
curr=curr->prev_;
}
return numData;
}
template
DList::~DList(){
}
template

Complete the push_front(), push_back(), pop_front(), pop_back() and destructor functions for a DList class.

Please answer the above question in C++ code language, thank you!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

1. Does your voice project confidence? Authority?

Answered: 1 week ago