diff options
Diffstat (limited to 'backend/List.hpp')
-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--; } |