Get `item` from the Queue >>> queue = QueueByList((10, 20, 30)) >>> queue.get() 10 >>> queue.put(40) >>> queue.get() 20 >>> queue.get() 30 >>> len(queue) 1 >>> queue.get() 40 >>> queue.g
(self)
| 70 | self.entries.append(item) |
| 71 | |
| 72 | def get(self) -> T: |
| 73 | """ |
| 74 | Get `item` from the Queue |
| 75 | |
| 76 | >>> queue = QueueByList((10, 20, 30)) |
| 77 | >>> queue.get() |
| 78 | 10 |
| 79 | >>> queue.put(40) |
| 80 | >>> queue.get() |
| 81 | 20 |
| 82 | >>> queue.get() |
| 83 | 30 |
| 84 | >>> len(queue) |
| 85 | 1 |
| 86 | >>> queue.get() |
| 87 | 40 |
| 88 | >>> queue.get() |
| 89 | Traceback (most recent call last): |
| 90 | ... |
| 91 | IndexError: Queue is empty |
| 92 | """ |
| 93 | |
| 94 | if not self.entries: |
| 95 | raise IndexError("Queue is empty") |
| 96 | return self.entries.pop(0) |
| 97 | |
| 98 | def rotate(self, rotation: int) -> None: |
| 99 | """Rotate the items of the Queue `rotation` times |