更新队列的链表实现中 self.__front 判空的方式 (#297)

* 更新队列的链表实现中 self.__front 判空的方式

self.__front 初始化为 None, 元素入队判断队列是否为空,延用头节点的初始化值 None 而不是 0

* Update linkedlist_queue.py

---------

Co-authored-by: Yudong Jin <krahets@163.com>
pull/298/head
beintentional 2 years ago committed by GitHub
parent d76e6582fa
commit 3858048d0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,7 +30,7 @@ class LinkedListQueue:
# 尾结点后添加 num
node = ListNode(num)
# 如果队列为空,则令头、尾结点都指向该结点
if self.__front == 0:
if self.__front is None:
self.__front = node
self.__rear = node
# 如果队列不为空,则将该结点添加到尾结点后

@ -412,7 +412,7 @@ comments: true
# 尾结点后添加 num
node = ListNode(num)
# 如果队列为空,则令头、尾结点都指向该结点
if self.__front == 0:
if self.__front is None:
self.__front = node
self.__rear = node
# 如果队列不为空,则将该结点添加到尾结点后

Loading…
Cancel
Save