From ff7390073ad42b9584aa2c509669867edab8c2f6 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 30 Oct 2024 22:05:16 +0100 Subject: fix List::remove --- backend/List.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'backend') diff --git a/backend/List.hpp b/backend/List.hpp index f4dce23..25e7a56 100644 --- a/backend/List.hpp +++ b/backend/List.hpp @@ -28,8 +28,15 @@ void List::remove(const T & target) { } if (link == nullptr) return; // target not in list - if (link->next != nullptr) link->next->prev = link->prev; - if (link->prev != nullptr) link->prev->next = link->next; + if (link->next == nullptr) + this->head = link->prev; + else + link->next->prev = link->prev; + if (link->prev == nullptr) + this->tail = link->next; + else + link->prev->next = link->next; + delete link; this->length--; } -- cgit v1.2.3