fix: Update linkedlist_deque.cpp (#1062)

There is something error when delete node, should 'delete front' or 'delete rear' outside the body of if cycle.
pull/1064/head
Scai 10 months ago committed by GitHub
parent c69ae9534d
commit 84f4b8d285
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -92,8 +92,8 @@ class LinkedListDeque {
if (fNext != nullptr) {
fNext->prev = nullptr;
front->next = nullptr;
delete front;
}
delete front;
front = fNext; // 更新头节点
// 队尾出队操作
} else {
@ -103,8 +103,8 @@ class LinkedListDeque {
if (rPrev != nullptr) {
rPrev->next = nullptr;
rear->prev = nullptr;
delete rear;
}
delete rear;
rear = rPrev; // 更新尾节点
}
queSize--; // 更新队列长度

Loading…
Cancel
Save