close #491 check whether link node is head

This commit is contained in:
Yanzhen Yu
2021-02-27 13:46:29 +08:00
parent 860ff38e90
commit 2c6be72f35

View File

@@ -62,7 +62,11 @@ class DoubleLinkedList {
if (current) { if (current) {
current.previous = node; current.previous = node;
} }
} else if (n.nextSibling && isNodeInLinkedList(n.nextSibling)) { } else if (
n.nextSibling &&
isNodeInLinkedList(n.nextSibling) &&
n.nextSibling.__ln.previous
) {
const current = n.nextSibling.__ln.previous; const current = n.nextSibling.__ln.previous;
node.previous = current; node.previous = current;
node.next = n.nextSibling.__ln; node.next = n.nextSibling.__ln;