Question
How to use concatenate for linked lists with this format? this is what i have QueueT QueueT::concatenate(QueueT& qu, int n)const{ QueueT result = front; QueueT
How to use concatenate for linked lists with this format?
this is what i have
QueueT QueueT::concatenate(QueueT& qu, int n)const{
QueueT result = front;
QueueT re = qu;
int stop = 0;
//while it is not empty, we want to for the size n, iterate and insert the first n values
if(n > re.size()){
throw std::runtime_error("n is greater than size of param");
}
while(stop != n){
result.enqueue(re.front->data);
re.dequeue();
stop++;
}
return result;
}
and my test program calls it like this, q1.concatenate(q4, 1); but i do not know how to reach both linked lists
concatenate - has two parameters, a QueueT reference and an integer (referred to as n in this description) adds the first n values stored in its Queuet parameter to the end of the calling object, the resulting queue therefore contains its original contents - order unchanged - followed by the first n values of the parameter queue in their original order; the values added to the calling object should be removed from the parameter; both queue's sizes should be adjusted as appropriate; if n is greater than the size of the parameter a runtime_error should be thrown and no changes made to either queueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started