pqueue

package
v0.0.0-...-fa9a0de Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: Apache-2.0 Imports: 2 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 {
	// contains filtered or unexported fields
}

An Item is what we manage the queue.

func NewItem

func NewItem(val string) *Item

NewItem creates and initializes an item

type MinPQueue

type MinPQueue []*Item

A MinPQueue implements heap.Interface and holds Items.

func NewMinPQueue

func NewMinPQueue() *MinPQueue

NewMinPQueue creates a pq and initializes it

func (*MinPQueue) DecreaseItem

func (pq *MinPQueue) DecreaseItem(ip *Item) error

DecreaseItem decrements the priority of the specified item

func (*MinPQueue) GetMin

func (pq *MinPQueue) GetMin() string

GetMin returns the value of the root item

func (*MinPQueue) IncreaseMin

func (pq *MinPQueue) IncreaseMin()

IncreaseMin increments the priority of the root item

func (MinPQueue) Len

func (pq MinPQueue) Len() int

Len returns the current length of the pqueue

func (MinPQueue) Less

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

Less returns true when the first item has higher priority

func (*MinPQueue) Pop

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

Pop removes the last item and returns it

func (*MinPQueue) Push

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

Push adds the item to the end of the queue

func (*MinPQueue) PushItem

func (pq *MinPQueue) PushItem(item *Item)

PushItem adds the specified item to the pq

func (*MinPQueue) RemoveItem

func (pq *MinPQueue) RemoveItem(ip *Item) error

RemoveItem removes the specified item from pq

func (MinPQueue) Swap

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

Swap swaps the positions of the two items

Jump to

Keyboard shortcuts

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