commit
871ff9746d
@ -16,9 +16,16 @@ class ArrayQueue:
|
||||
self._tail = 0
|
||||
|
||||
def enqueue(self, item: str) -> bool:
|
||||
if self._tail == self._capacity: return False
|
||||
if self._tail == self._capacity:
|
||||
if self._head == 0:
|
||||
return False
|
||||
else:
|
||||
for i in range(0, self._tail - self._head):
|
||||
self._data[i] = self._items[i + self._head]
|
||||
self._tail = self._tail - self._head
|
||||
self._head = 0
|
||||
|
||||
self._items.append(item)
|
||||
self._items.insert(self._tail, item)
|
||||
self._tail += 1
|
||||
return True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user