Question: i need help with this data structure assignment, i was given a gutted list class and i need to write the method. Im kinda stuff
i need help with this data structure assignment, i was given a gutted list class and i need to write the method. Im kinda stuff on how to finish it. I already started on some of them
.h
#pragma once template
ListNode *mHead; ListNode *mTail;
public: List() { // Getting Head and Tail correct is not part of the Big 3. It is hella mega required no matter what. //mHead = nullptr; //mTail = nullptr;// bleh. Full of crash. mHead = new ListNode; mTail = new ListNode; mHead->mNext = mTail; mHead->mPrev = nullptr; mTail->mPrev = mHead;// This RULES. We always know we have 2 nodes, so we never have to check for null. mTail->mNext = nullptr; } List(const List & tOther) { } List & operator = (const List & tRHS) { } ~List() { }
void PushFront(const T &tWhat) { ListNode mNode; mHead->mNext = mNode; size++; } void PopFront() { mHead->mNext = mHead->mNext->mNext->mNext->mPrev; size--; } T& Front() { return mHead->mNext->mData; }
void PushBack(const T &tWhat) { ListNode mNode; mTail->mPrev = mNode; size++; } void PopBack() { mTail->mPrev = mTail->mPrev->mPrev->mPrev->mNext; size--; } T& Back() { return mTail->mPrev->mData; }
int Size() const { return mSize; } void Clear() { }
T& At(int tWhere) const { }
/////////////////////////////////////////////////////////////////// // Iterators class Iterator { ListNode *mCurrent; public: Iterator(ListNode *tStart) { } T& GetData() { } void Next()// As in "Move to the next item please". { } bool IsEqual(const Iterator &rhs) { } };
Iterator Insert(Iterator tWhere, const T &tWhat) { Iterator tNewN; tNewN->mData = tWhat; tWhere->; return tWhere; } Iterator Erase(Iterator tWhat) { Iterator tWhat; twhat -> } Iterator Begin() { // First good data Iterator(mHead ->mNext); return tReturn } Iterator End() { // First Bad data Iterator(mTail); return tReturn } };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
