pqueue

package
v0.0.0-...-e8a74ae Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2014 License: BSD-3-Clause Imports: 1 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 {
	Val      interface{} // Value stored in heap
	Priority int         // the Priority of the item in the heap
	Index    int         // the Index of the item in the heap
}

Item represents a single element of a Priority queue

type Pqueue

type Pqueue priorityQueue

Pqueue implements a priority queue leveraging go's heap implementation

func New

func New(items []*Item) *Pqueue

New creates a new priority queue initialized by items

func (*Pqueue) Pop

func (pq *Pqueue) Pop() *Item

Pop removes and returns the highest priority item of the queue

func (*Pqueue) Push

func (pq *Pqueue) Push(item *Item)

Push adds a new item to the priority queue.

func (*Pqueue) Update

func (pq *Pqueue) Update(item *Item, Value interface{}, Priority int)

Update updates the Priority and Value of an item in the Priority queue

Jump to

Keyboard shortcuts

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