Returns sorted list containing all the values in the heap. >>> sh = SkewHeap([3, 1, 3, 7]) >>> list(sh) [1, 3, 3, 7]
(self)
| 139 | return self._root is not None |
| 140 | |
| 141 | def __iter__(self) -> Iterator[T]: |
| 142 | """ |
| 143 | Returns sorted list containing all the values in the heap. |
| 144 | |
| 145 | >>> sh = SkewHeap([3, 1, 3, 7]) |
| 146 | >>> list(sh) |
| 147 | [1, 3, 3, 7] |
| 148 | """ |
| 149 | result: list[Any] = [] |
| 150 | while self: |
| 151 | result.append(self.pop()) |
| 152 | |
| 153 | # Pushing items back to the heap not to clear it. |
| 154 | for item in result: |
| 155 | self.insert(item) |
| 156 | |
| 157 | return iter(result) |
| 158 | |
| 159 | def insert(self, value: T) -> None: |
| 160 | """ |