This function removes an element from the queue using on self.front value as an index and returns it >>> cq = CircularQueue(5) >>> cq.dequeue() Traceback (most recent call last): ... Exception: UNDERFLOW >>> cq.enqueue("A").enqueue
(self)
| 79 | return self |
| 80 | |
| 81 | def dequeue(self): |
| 82 | """ |
| 83 | This function removes an element from the queue using on self.front value as an |
| 84 | index and returns it |
| 85 | |
| 86 | >>> cq = CircularQueue(5) |
| 87 | >>> cq.dequeue() |
| 88 | Traceback (most recent call last): |
| 89 | ... |
| 90 | Exception: UNDERFLOW |
| 91 | >>> cq.enqueue("A").enqueue("B").dequeue() |
| 92 | 'A' |
| 93 | >>> (cq.size, cq.first()) |
| 94 | (1, 'B') |
| 95 | >>> cq.dequeue() |
| 96 | 'B' |
| 97 | >>> cq.dequeue() |
| 98 | Traceback (most recent call last): |
| 99 | ... |
| 100 | Exception: UNDERFLOW |
| 101 | """ |
| 102 | if self.size == 0: |
| 103 | raise Exception("UNDERFLOW") |
| 104 | |
| 105 | temp = self.array[self.front] |
| 106 | self.array[self.front] = None |
| 107 | self.front = (self.front + 1) % self.n |
| 108 | self.size -= 1 |
| 109 | return temp |
nothing calls this directly
no outgoing calls
no test coverage detected