Documentation
¶
Overview ¶
Package queue implements a priority queue.
Index ¶
- type Entry
- type PriorityQueue
- func (q *PriorityQueue) DequeueIndex(index int) *Entry
- func (q *PriorityQueue) DequeueRandom(r *rand.Rand) *Entry
- func (q *PriorityQueue) Enqueue(priority uint64, value interface{})
- func (q *PriorityQueue) Len() int
- func (q PriorityQueue) Less(i, j int) bool
- func (q *PriorityQueue) Peek() *Entry
- func (q *PriorityQueue) PeekIndex(i int) *Entry
- func (q *PriorityQueue) Pop() interface{}
- func (q *PriorityQueue) Push(x interface{})
- func (q *PriorityQueue) Remove(index int) interface{}
- func (q PriorityQueue) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct { Value interface{} Priority uint64 }
Entry is a PriorityQueue entry.
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue is a priority queue instance.
func (*PriorityQueue) DequeueIndex ¶
func (q *PriorityQueue) DequeueIndex(index int) *Entry
DequeueIndex removes the specified entry from the queue.
func (*PriorityQueue) DequeueRandom ¶
func (q *PriorityQueue) DequeueRandom(r *rand.Rand) *Entry
DequeueRandom removes a random entry from the queue.
func (*PriorityQueue) Enqueue ¶
func (q *PriorityQueue) Enqueue(priority uint64, value interface{})
Enqueue inserts the provided value, into the queue with the specified priority.
func (*PriorityQueue) Len ¶
func (q *PriorityQueue) Len() int
Len returns the current length of the priority queue.
func (PriorityQueue) Less ¶
func (q PriorityQueue) Less(i, j int) bool
Less implements sort.Interface Less method
func (*PriorityQueue) Peek ¶
func (q *PriorityQueue) Peek() *Entry
Peek returns the 0th entry (lowest priority) if any, leaving the PriorityQueue unaltered. Callers MUST NOT alter the Priority of the returned entry.
func (*PriorityQueue) PeekIndex ¶
func (q *PriorityQueue) PeekIndex(i int) *Entry
PeekIndex peeks at the specified index.
func (*PriorityQueue) Pop ¶
func (q *PriorityQueue) Pop() interface{}
Pop removes and returns the 0th entry (lowest priority) if any.
func (*PriorityQueue) Push ¶
func (q *PriorityQueue) Push(x interface{})
Push implements heap.Interface Push method
func (*PriorityQueue) Remove ¶
func (q *PriorityQueue) Remove(index int) interface{}
Remove removes and returns element from the heap with given index
func (PriorityQueue) Swap ¶
func (q PriorityQueue) Swap(i, j int)
Swap implements sort.Interface Swap method