prioqueue

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrioQueue

type PrioQueue[T comparable, P cmp.Ordered] struct {
	// contains filtered or unexported fields
}

PrioQueue Priority queue implemented with a heap. Lowest number -> highest priority. Admits duplicates for both priorities and items

func NewPrioQueue

func NewPrioQueue[T comparable, P cmp.Ordered]() PrioQueue[T, P]

func (*PrioQueue[T, P]) ChangePriority

func (q *PrioQueue[T, P]) ChangePriority(item T, newPriority P)

ChangePriority If the item is not found is added to the priority list

func (*PrioQueue[T, P]) ChangeValue

func (q *PrioQueue[T, P]) ChangeValue(toChange T, newValue T)

ChangeValue Changes the value of an element of the queue. Does nothing if the element is not found

func (*PrioQueue[T, P]) Dequeue

func (q *PrioQueue[T, P]) Dequeue() T

Dequeue Removes and returns the item with the highest priority

func (*PrioQueue[T, P]) GetPriority

func (q *PrioQueue[T, P]) GetPriority(item T) (P, error)

GetPriority Returns the priority of the specified item. If there are duplicates returns one of them with no guarantees about which item is retrieved

func (*PrioQueue[T, P]) Insert

func (q *PrioQueue[T, P]) Insert(item T, priority P)

func (*PrioQueue[T, P]) IsEmpty

func (q *PrioQueue[T, P]) IsEmpty() bool

func (*PrioQueue[T, P]) Peek

func (q *PrioQueue[T, P]) Peek() T

Peek Returns the item with the highest priority

func (*PrioQueue[T, P]) Remove

func (q *PrioQueue[T, P]) Remove(priority P) T

func (*PrioQueue[T, P]) Size

func (q *PrioQueue[T, P]) Size() int

func (*PrioQueue[T, P]) String

func (q *PrioQueue[T, P]) String() string

String Elements are not guaranteed to be in order of priority

Jump to

Keyboard shortcuts

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