Enqueue 添加一个元素
(item T)
| 70 | |
| 71 | // Enqueue 添加一个元素 |
| 72 | func (pq *PriorityQueue[T]) Enqueue(item T) error { |
| 73 | if pq.Len() >= pq.capacity { |
| 74 | return ErrOutOfCapacity |
| 75 | } |
| 76 | heap.Push(pq, item) |
| 77 | return nil |
| 78 | } |
| 79 | |
| 80 | // Dequeue 移除并返回最小元素 |
| 81 | func (pq *PriorityQueue[T]) Dequeue() (T, error) { |
no test coverage detected