aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 22:05:16 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 22:05:16 +0100
commitff7390073ad42b9584aa2c509669867edab8c2f6 (patch)
tree9d6674ba6e7fcaf9b56516172195bab52dbe2dfe /backend
parent80ed1262bd654fe2de30389f97a985b5f2c1d783 (diff)
fix List::remove
Diffstat (limited to 'backend')
-rw-r--r--backend/List.hpp11
1 files changed, 9 insertions, 2 deletions
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<T>::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--;
}