Completed part 2 minus the bonus

This commit is contained in:
Christopher Sanden
2025-10-18 17:17:11 +02:00
parent f9dc752231
commit 004fbc291e
7 changed files with 390 additions and 57 deletions

View File

@@ -4,16 +4,13 @@
#include "TMovie.h"
#include "TMovieNode.h"
using namespace std;
class TMovieList {
private:
TMovieNode* head;
TMovieNode* tail;
public:
TMovieList() : head(new TMovieNode(nullptr)) {}
TMovieList() : head(new TMovieNode(nullptr)), tail(head) {}
~TMovieList()
{
@@ -25,14 +22,15 @@ public:
current = next;
}
head = nullptr;
tail = nullptr;
}
void Append(TMovie* m);
void Prepend(TMovie* m);
void PushFront(TMovie* m) const
{
auto* n = new TMovieNode(m);
n->SetNextNode(head->GetNextNode());
head->SetNextNode(n);
}
TMovieNode *NavigateToNode(int index);
TMovie* GetAtIndex(int index);
void Remove(int index);
};