Fix remove on last node of singly-linked list [backport:1.6] (#19353)

This commit is contained in:
gecko
2022-01-10 09:27:59 +00:00
committed by GitHub
parent b098546da0
commit 955040f0f1
3 changed files with 16 additions and 0 deletions

View File

@@ -739,6 +739,8 @@ proc remove*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]): bool {.disc
if prev.next == nil:
return false
prev.next = n.next
if L.tail == n:
L.tail = prev # update tail if we removed the last node
true
proc remove*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) =