Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how to insert, my code doesnt work. // Insert a piece of data *before* the passed-in iterator // // In: _iter The iterator // _data

how to insert, my code doesnt work.

// Insert a piece of data *before* the passed-in iterator // // In: _iter The iterator // _data The value to add // // Example: /* Before

0<-[4]<->[5]<->[6]->0 I

After

0<-[4]<->[9]<->[5]<->[6]->0 I */ // Return: The iterator // SPECIAL CASE: Inserting at head or empty list // NOTE: The iterator should now be pointing to the new node created

Iterator Insert(Iterator& _iter, const T& _data) { Node* node = new Node(_data); if (_iter.mCurr == mTail) { mTail = node; _iter.mCurr->next = node; } return _iter; }

need help with clear method;

// Clear the list of all dynamic memory // Resets the list to its default state

void Clear() { mSize = 0; Node* temp = mHead; /*mHead = nullptr; mTail = nullptr;*/ mHead = mTail = nullptr; while (temp) { Node* node = temp->next; delete temp; temp = node; } delete mTail; }

how to assign this properly

data members are:

mHead;

mTail;

mSize;

also default constructor sets next, prev, and data

// Assignment operator // Used to assign one object to another // In: _asign The object to assign from // // Return: The invoking object (by reference) // This allows us to daisy-chain

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

foreign country?

Answered: 1 week ago