Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Heapable ¶
type Heapable interface {
Priority(other interface{}) bool
}
Heapable reflects an interface that an item must implement in order to be placed into a priority queue.
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue implements a priority queue of Heapable items. Each item must implement the Heapable interface and is responsible for giving each item priority respective to every other item. The main benefit of this implementation is to abstract away any direct heap usage.
func NewPriorityQueue ¶
func NewPriorityQueue() *PriorityQueue
NewPriorityQueue returns a reference to a new initialized PriorityQueue.
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() Heapable
Pop removes a Sortable item from the priority queue with the highest priority and returns it.
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(s Heapable)
Push adds a Sortable item to the priority queue.
func (*PriorityQueue) Size ¶
func (pq *PriorityQueue) Size() int
Size returns the size of the priority queue.