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

Method __iter__

data_structures/binary_tree/basic_binary_tree.py:13–18  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

11 right: Node | None = None
12
13 def __iter__(self) -> Iterator[int]:
14 if self.left:
15 yield from self.left
16 yield self.data
17 if self.right:
18 yield from self.right
19
20 def __len__(self) -> int:
21 return sum(1 for _ in self)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected