mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 12:58:42 +08:00
Fix the deconstructor of linkedlist_queue.cpp
This commit is contained in:
@ -27,7 +27,7 @@ public:
|
||||
|
||||
/* 析构方法 */
|
||||
~LinkedListDeque() {
|
||||
// 释放内存
|
||||
// 遍历链表删除结点,释放内存
|
||||
DoublyListNode *pre, *cur = front;
|
||||
while (cur != nullptr) {
|
||||
pre = cur;
|
||||
|
||||
@ -20,8 +20,8 @@ public:
|
||||
}
|
||||
|
||||
~LinkedListQueue() {
|
||||
delete front;
|
||||
delete rear;
|
||||
// 遍历链表删除结点,释放内存
|
||||
freeMemoryLinkedList(front);
|
||||
}
|
||||
|
||||
/* 获取队列的长度 */
|
||||
|
||||
@ -19,6 +19,7 @@ public:
|
||||
}
|
||||
|
||||
~LinkedListStack() {
|
||||
// 遍历链表删除结点,释放内存
|
||||
freeMemoryLinkedList(stackTop);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user