pq

package
Version: v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2015 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem interface {
	// SetIndex stores the int index.
	SetIndex(int)
	// Index returns the last given by SetIndex(int).
	Index() int
}

Elem describes elements that can be added to the PQ. Clients must implement this interface.

type ElemComparator

type ElemComparator func(a, b Elem) bool

ElemComparator returns true if pri(a) > pri(b)

type PQ

type PQ interface {
	// Push adds the ele
	Push(Elem)
	// Pop returns the highest priority Elem in PQ.
	Pop() Elem
	// Len returns the number of elements in the PQ.
	Len() int
	// Update `fixes` the PQ.
	Update(index int)
}

PQ is a basic priority queue.

func New

func New(cmp ElemComparator) PQ

New creates a PQ with a client-supplied comparator.

Source Files

Jump to

Keyboard shortcuts

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