diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 22:05:16 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 22:05:16 +0100 |
commit | ff7390073ad42b9584aa2c509669867edab8c2f6 (patch) | |
tree | 9d6674ba6e7fcaf9b56516172195bab52dbe2dfe /backend | |
parent | 80ed1262bd654fe2de30389f97a985b5f2c1d783 (diff) |
fix List::remove
Diffstat (limited to 'backend')
-rw-r--r-- | backend/List.hpp | 11 |
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--; } |