priorityqueue

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Value    interface{} // The Value of the item; arbitrary.
	Priority float64     // The Priority of the item in the queue.
	// contains filtered or unexported fields
}

An Item is something we manage in a Priority queue.

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

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

func (*PriorityQueue) MarshalJSON added in v0.1.2

func (pq *PriorityQueue) MarshalJSON() ([]byte, error)

Marshal a PriorityQueue in priorityqueue order. Warning, this method is not terribly efficient, as iterating over a heap-based PriorityQueue is destructive. Thus, O(n) auxillary space is required to store the item references and O(n) time complexity is needed to re-construct the priority queue post destruction. There are likely more efficient implementations, but in this case n is expected to remain sufficiently small, so this implementation is "good enough".

func (*PriorityQueue) Pop

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

func (*PriorityQueue) Push

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

func (PriorityQueue) Swap

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

Jump to

Keyboard shortcuts

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