Question: I need help on custom STL list. Using C++ #pragma once template class List { struct ListNode { ListNode() { } T mData; ListNode *mPrev;
I need help on custom STL list. Using C++

#pragma once template class List { struct ListNode { ListNode() { } T mData; ListNode *mPrev; ListNode *mNext; };
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) { } void PopFront() { } T& Front() { }
void PushBack(const T &tWhat) { } void PopBack() { } T& Back() { }
int Size() const { } 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 Erase(Iterator tWhat) { } Iterator Begin() { // First good data } Iterator End() { // First Bad data } };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
