You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the enqueue part is enlarge the array and didn't change it ,when the test case large, and go into tail < head, will have bugs. so need change the enqueue function as bellow:
def enqueue(self,data):
if (self._tail+1) % self._capacity == self._head:
return False
#self._value.append(data)
self._tail = (self._tail+1) % self._capacity
if len(self._value) < self._capacity -1:
self._value.append(data)
else:
self._value[self._tail] = data
And also need change repr fuction as bellow:
def repr(self):
if self._tail >= self._head:
return " ".join(item for item in self._value[self._head:self._tail])
else:
return " ".join(item for item in chain(self._value[self._head:], self._value[:self._tail+1]))
The text was updated successfully, but these errors were encountered:
the enqueue part is enlarge the array and didn't change it ,when the test case large, and go into tail < head, will have bugs. so need change the enqueue function as bellow:
def enqueue(self,data):
if (self._tail+1) % self._capacity == self._head:
return False
#self._value.append(data)
self._tail = (self._tail+1) % self._capacity
And also need change repr fuction as bellow:
def repr(self):
if self._tail >= self._head:
return " ".join(item for item in self._value[self._head:self._tail])
else:
return " ".join(item for item in chain(self._value[self._head:], self._value[:self._tail+1]))
The text was updated successfully, but these errors were encountered: