MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __iter__

Method __iter__

data_structures/queues/double_ended_queue.py:419–437  ·  view source on GitHub ↗

Implements iteration. Time complexity: O(1) >>> our_deque = Deque([1, 2, 3]) >>> for v in our_deque: ... print(v) 1 2 3 >>> from collections import deque >>> deque_collections = deque([1, 2, 3]) >>> for v in

(self)

Source from the content-addressed store, hash-verified

417 return True
418
419 def __iter__(self) -> Deque._Iterator:
420 """
421 Implements iteration.
422 Time complexity: O(1)
423 >>> our_deque = Deque([1, 2, 3])
424 >>> for v in our_deque:
425 ... print(v)
426 1
427 2
428 3
429 >>> from collections import deque
430 >>> deque_collections = deque([1, 2, 3])
431 >>> for v in deque_collections:
432 ... print(v)
433 1
434 2
435 3
436 """
437 return Deque._Iterator(self._front)
438
439 def __repr__(self) -> str:
440 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected