prioqueue

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: BSD-3-Clause 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{}
	// contains filtered or unexported fields
}

Item contains a reference to an enqueued value.

type LessFunc

type LessFunc func(interface{}, interface{}) bool

LessFunc returns whether the first parameter is to be considered less than the second parameter.

type PrioQueue

type PrioQueue struct {
	Less LessFunc
	// contains filtered or unexported fields
}

PrioQueue is a min-heap queue with items sorted using the Less function.

func (*PrioQueue) Clear

func (q *PrioQueue) Clear()

Clear removes all items from the queue.

func (*PrioQueue) Len

func (q *PrioQueue) Len() int

Len returns the number of items in the queue.

func (*PrioQueue) Peek

func (q *PrioQueue) Peek() interface{}

Peek returns the minimum value in the queue.

func (*PrioQueue) Pop

func (q *PrioQueue) Pop() interface{}

Pop removes and returns the minimum value from the queue.

func (*PrioQueue) Push

func (q *PrioQueue) Push(value interface{}) *Item

Push inserts a new value into the queue, returning an Item pointer suitable for updating or removing the value directly.

func (*PrioQueue) Remove

func (q *PrioQueue) Remove(item *Item)

Remove removes an item regardless of its current position in the queue.

func (*PrioQueue) Update

func (q *PrioQueue) Update(item *Item)

Update corrects item's position in the queue after its underlying value has been changed.

Jump to

Keyboard shortcuts

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