queue

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2018 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package queue implements a priority queue.

Index

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
	// contains filtered or unexported fields
}

Entry is a PriorityQueue entry.

type PriorityQueue

type PriorityQueue struct {
	// contains filtered or unexported fields
}

PriorityQueue is a priority queue instance.

func New

func New() *PriorityQueue

New creates a new PriorityQueue.

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) 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) Pop

func (q *PriorityQueue) Pop() *Entry

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL