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. 0 is first data

Erase: Delete the node at this iterator, if it exists

Insert: 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::IsEqual: Are these pointing to the same node?

list.h

#pragma once

template <typename T>

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

}

};

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now