Return the smallest value from the heap. >>> sh = SkewHeap() >>> sh.insert(3) >>> sh.top() 3 >>> sh.insert(1) >>> sh.top() 1 >>> sh.insert(3) >>> sh.top() 1 >>> sh.insert(7) >>> sh.top()
(self)
| 196 | return result |
| 197 | |
| 198 | def top(self) -> T: |
| 199 | """ |
| 200 | Return the smallest value from the heap. |
| 201 | |
| 202 | >>> sh = SkewHeap() |
| 203 | >>> sh.insert(3) |
| 204 | >>> sh.top() |
| 205 | 3 |
| 206 | >>> sh.insert(1) |
| 207 | >>> sh.top() |
| 208 | 1 |
| 209 | >>> sh.insert(3) |
| 210 | >>> sh.top() |
| 211 | 1 |
| 212 | >>> sh.insert(7) |
| 213 | >>> sh.top() |
| 214 | 1 |
| 215 | """ |
| 216 | if not self._root: |
| 217 | raise IndexError("Can't get top element for the empty heap.") |
| 218 | return self._root.value |
| 219 | |
| 220 | def clear(self) -> None: |
| 221 | """ |