()
| 4989 | } |
| 4990 | |
| 4991 | pop(): T | undefined { |
| 4992 | if (this.heap.length === 0) return undefined; |
| 4993 | if (this.heap.length === 1) return this.heap.pop(); |
| 4994 | |
| 4995 | const min = this.heap[0]; |
| 4996 | this.heap[0] = this.heap.pop()!; |
| 4997 | this.bubbleDown(0); |
| 4998 | return min; |
| 4999 | } |
| 5000 | |
| 5001 | private bubbleUp(index: number): void { |
| 5002 | while (index > 0) { |