From f36eb15b8413d9a23eae7b2801d360ecc0fd72bf Mon Sep 17 00:00:00 2001 From: scyes Date: Mon, 4 Mar 2019 14:15:54 +0800 Subject: [PATCH] remove wrong code, add dequene() return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 去掉下面的错误代码 <<<<<<< HEAD self._data[i] = self._items[i + self._head] ======= 2. 按照课程中的java代码,增加“队列为空时,返回None” --- python/09_queue/array_queue.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/python/09_queue/array_queue.py b/python/09_queue/array_queue.py index 19c6b79..1c34b01 100644 --- a/python/09_queue/array_queue.py +++ b/python/09_queue/array_queue.py @@ -21,11 +21,7 @@ class ArrayQueue: return False else: for i in range(0, self._tail - self._head): -<<<<<<< HEAD - self._data[i] = self._items[i + self._head] -======= self._items[i] = self._items[i + self._head] ->>>>>>> upstream/master self._tail = self._tail - self._head self._head = 0 @@ -38,6 +34,8 @@ class ArrayQueue: item = self._items[self._head] self._head += 1 return item + else: + return None def __repr__(self) -> str: return " ".join(item for item in self._items[self._head : self._tail])