remove wrong code, add dequene() return

1. 去掉下面的错误代码
<<<<<<< HEAD
                    self._data[i] = self._items[i + self._head]
=======
2. 按照课程中的java代码,增加“队列为空时,返回None”
This commit is contained in:
scyes 2019-03-04 14:15:54 +08:00 committed by GitHub
parent 67b6efd5e1
commit f36eb15b84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,11 +21,7 @@ class ArrayQueue:
return False return False
else: else:
for i in range(0, self._tail - self._head): 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] self._items[i] = self._items[i + self._head]
>>>>>>> upstream/master
self._tail = self._tail - self._head self._tail = self._tail - self._head
self._head = 0 self._head = 0
@ -38,6 +34,8 @@ class ArrayQueue:
item = self._items[self._head] item = self._items[self._head]
self._head += 1 self._head += 1
return item return item
else:
return None
def __repr__(self) -> str: def __repr__(self) -> str:
return " ".join(item for item in self._items[self._head : self._tail]) return " ".join(item for item in self._items[self._head : self._tail])