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

Method __iter__

data_structures/binary_tree/binary_search_tree.py:106–115  ·  view source on GitHub ↗

>>> list(Node(0)) [0] >>> list(Node(0, Node(-1), Node(1), None)) [-1, 0, 1]

(self)

Source from the content-addressed store, hash-verified

104 parent: Node | None = None # Added in order to delete a node easier
105
106 def __iter__(self) -> Iterator[int]:
107 """
108 >>> list(Node(0))
109 [0]
110 >>> list(Node(0, Node(-1), Node(1), None))
111 [-1, 0, 1]
112 """
113 yield from self.left or []
114 yield self.value
115 yield from self.right or []
116
117 def __repr__(self) -> str:
118 from pprint import pformat

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected