Question: list.h #pragma once template class List { struct ListNode { ListNode() { } T mData; ListNode *mPrev; ListNode *mNext; }; ListNode *mHead; ListNode *mTail; public:

list.h
#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
}
};
The files section has a gutted List class for you. Just write all the methods. Easy peasy List's big three: Need to do something in the constructor, and need to handle all the dynamic memory made when adding nodes. PushFront: Add a new node as the new first piece of data. Do NOT add anything before Head. PopFront: Remove the first piece of data if there is one. Front: Return the first piece of data. Back: Those same three, except to the end. Do NOT add anything after Tail Size: How many things. Clear: Remove all data, leave head and tail. At: Return data at that position. O is first data Erase: Delete the node at this iterator, if it exists nsert: Insert data after this iterator. Do not allow inserting after tail! Begin: Iterator to first data End: Iterator after last data (remember Unspecified Behavior) Iterator::GetData: Return the T from this node Iterator::Next: Move iterator to the next node Iterator:lsEqual: Are these pointing to the same node? The files section has a gutted List class for you. Just write all the methods. Easy peasy List's big three: Need to do something in the constructor, and need to handle all the dynamic memory made when adding nodes. PushFront: Add a new node as the new first piece of data. Do NOT add anything before Head. PopFront: Remove the first piece of data if there is one. Front: Return the first piece of data. Back: Those same three, except to the end. Do NOT add anything after Tail Size: How many things. Clear: Remove all data, leave head and tail. At: Return data at that position. O is first data Erase: Delete the node at this iterator, if it exists nsert: Insert data after this iterator. Do not allow inserting after tail! Begin: Iterator to first data End: Iterator after last data (remember Unspecified Behavior) Iterator::GetData: Return the T from this node Iterator::Next: Move iterator to the next node Iterator:lsEqual: Are these pointing to the same node
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
