Documentation ¶
Overview ¶
Package pq provides a priority queue.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a priority queue that supports updating the priority of an element. A Queue must be created with NewQueue.
func NewQueue ¶
NewQueue returns an unbounded priority queue that compares elements using less; the minimal element is at the top of the queue.
If setIndex is not nil, the queue calls setIndex to inform each element of its position in the queue. If an element's priority changes, its position in the queue may be incorrect. Call Fix on the element's index to update the queue. Call Remove on the element's index to remove it from the queue.
func (*Queue) Min ¶
func (pq *Queue) Min() interface{}
Min returns the minimal element. Min panics if the queue is empty.