prioqueue

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 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 any
	// contains filtered or unexported fields
}

Item contains a reference to an enqueued value.

type LessFunc

type LessFunc func(any, any) 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() any

Peek returns the minimum value in the queue.

func (*PrioQueue) Pop

func (q *PrioQueue) Pop() any

Pop removes and returns the minimum value from the queue.

func (*PrioQueue) Push

func (q *PrioQueue) Push(value any) *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