core: Index | Files

package queue

import ""

Package queue implements a priority queue.


Package Files


type Entry Uses

type Entry struct {
    Value    interface{}
    Priority uint64

Entry is a PriorityQueue entry.

type PriorityQueue Uses

type PriorityQueue struct {
    // contains filtered or unexported fields

PriorityQueue is a priority queue instance.

func New Uses

func New() *PriorityQueue

New creates a new PriorityQueue.

func (*PriorityQueue) DequeueIndex Uses

func (q *PriorityQueue) DequeueIndex(index int) *Entry

DequeueIndex removes the specified entry from the queue.

func (*PriorityQueue) DequeueRandom Uses

func (q *PriorityQueue) DequeueRandom(r *rand.Rand) *Entry

DequeueRandom removes a random entry from the queue.

func (*PriorityQueue) Enqueue Uses

func (q *PriorityQueue) Enqueue(priority uint64, value interface{})

Enqueue inserts the provided value, into the queue with the specified priority.

func (*PriorityQueue) FilterOnce Uses

func (q *PriorityQueue) FilterOnce(filter func(value interface{}) bool)

FilterOnce removes the first item from the queue who's value is passed to the filter function and returns true.

func (*PriorityQueue) Len Uses

func (q *PriorityQueue) Len() int

Len returns the current length of the priority queue.

func (PriorityQueue) Less Uses

func (q PriorityQueue) Less(i, j int) bool

Less implements sort.Interface Less method

func (*PriorityQueue) Peek Uses

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 Uses

func (q *PriorityQueue) PeekIndex(i int) *Entry

PeekIndex peeks at the specified index.

func (*PriorityQueue) Pop Uses

func (q *PriorityQueue) Pop() interface{}

Pop removes and returns the 0th entry (lowest priority) if any.

func (*PriorityQueue) Push Uses

func (q *PriorityQueue) Push(x interface{})

Push implements heap.Interface Push method

func (*PriorityQueue) Remove Uses

func (q *PriorityQueue) Remove(index int) interface{}

Remove removes and returns element from the heap with given index

func (*PriorityQueue) RemovePriority Uses

func (q *PriorityQueue) RemovePriority(priority uint64) interface{}

RemovePriority removes and returns element from the heap with given priority or nil

func (PriorityQueue) Swap Uses

func (q PriorityQueue) Swap(i, j int)

Swap implements sort.Interface Swap method

Package queue imports 2 packages (graph) and is imported by 3 packages. Updated 2019-04-01. Refresh now. Tools for package owners.