Return the front element without removing it. Returns: The front element. Raises: IndexError: If the queue is empty.
(self)
| 110 | return value |
| 111 | |
| 112 | def peek(self) -> object: |
| 113 | """Return the front element without removing it. |
| 114 | |
| 115 | Returns: |
| 116 | The front element. |
| 117 | |
| 118 | Raises: |
| 119 | IndexError: If the queue is empty. |
| 120 | """ |
| 121 | if self.is_empty(): |
| 122 | raise IndexError("Queue is empty") |
| 123 | return self._array[self._front] |
| 124 | |
| 125 | def _expand(self) -> None: |
| 126 | """Double the size of the underlying array.""" |