MCPcopy Index your code
hub / github.com/keon/algorithms / peek

Method peek

algorithms/data_structures/queue.py:196–207  ·  view source on GitHub ↗

Return the front element without removing it. Returns: The front element. Raises: IndexError: If the queue is empty.

(self)

Source from the content-addressed store, hash-verified

194 return value
195
196 def peek(self) -> object:
197 """Return the front element without removing it.
198
199 Returns:
200 The front element.
201
202 Raises:
203 IndexError: If the queue is empty.
204 """
205 if self.is_empty():
206 raise IndexError("Queue is empty")
207 return self._front.value

Callers 1

Calls 1

is_emptyMethod · 0.45

Tested by 1