I'm trying to create a circular queue class and i seem to be indexing incorrectly. Any tips on how to fix the issues im running into ?
class circularQueue(ShufflingQueue): def init(self,capacity): super().init(capacity) def is_empty(self): super().is_empty() def is_full(self): super().is_full()
def enqueue(self,item):
if self.is_full() == True:
raise FullError("the queue is full")
elif self.is_empty():
self.front = self.front = 0
self.rear = self.rear = 0
self.queue[self.rear] = item
else:
self.rear =(self.rear+1) % self.capacity
self.queue[self.rear] = item
def dequeue(self):
if self.is_empty()== True:
raise IndexError("cannot dequeu an empty queue")
else:
temp = self.queue[self.front]
self.front = (self.front+1) % self.capacity
return temp
i was expecting this to add some values to the queue using the enqueue method. havennt evven gotten to see if the logic works for dequeue yet.