Push 添加一个元素
(x interface{})
| 51 | |
| 52 | // Push 添加一个元素 |
| 53 | func (pq *PriorityQueue[T]) Push(x interface{}) { |
| 54 | if item, ok := x.(T); ok { |
| 55 | pq.items = append(pq.items, item) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // Pop 移除并返回最小元素 |
| 60 | func (pq *PriorityQueue[T]) Pop() interface{} { |