//---------------------------------------------------------------------------------------------------------------------- // Constructors //---------------------------------------------------------------------------------------------------------------------- template ThinListDouble::ThinListDouble() :previous(0), next(0) { } //---------------------------------------------------------------------------------------------------------------------- template ThinListDouble::ThinListDouble(const T& aobject, ThinListDouble* aprevious, ThinListDouble* anext) :previous(aprevious), next(anext), object(aobject) { } //---------------------------------------------------------------------------------------------------------------------- template ThinListDouble::ThinListDouble(const ThinListDouble& source, ThinListDouble* aprevious) :previous(aprevious), next(0), object(source.object) { if (source.next != 0) { next = new ThinListDouble(*source.next, this); } } //---------------------------------------------------------------------------------------------------------------------- template ThinListDouble::~ThinListDouble() { ThinListDouble* deleteEntry = next; while (deleteEntry != 0) { ThinListDouble* nextDeleteEntry = deleteEntry->next; deleteEntry->next = 0; delete deleteEntry; deleteEntry = nextDeleteEntry; } } //---------------------------------------------------------------------------------------------------------------------- // Insert functions //---------------------------------------------------------------------------------------------------------------------- template void ThinListDouble::PushToBack(const T& entry) { ThinListDouble* targetEntry = this; while (targetEntry->next != 0) { targetEntry = targetEntry->next; } targetEntry->next = new ThinListDouble(entry, targetEntry); } //---------------------------------------------------------------------------------------------------------------------- template void ThinListDouble::InsertAfter(const T& entry) { ThinListDouble* newEntry = new ThinListDouble(entry, this, next); if (next != 0) { next->previous = newEntry; } next = newEntry; } //---------------------------------------------------------------------------------------------------------------------- template void ThinListDouble::InsertBefore(const T& entry) { ThinListDouble* newEntry = new ThinListDouble(entry, previous, this); if (previous != 0) { previous->next = newEntry; } previous = newEntry; }