priorityqueue

package
v0.0.0-...-31dbb72 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

type PriorityQueue[Element any, Priority generalheap.Comparable[Priority]] struct {
	// contains filtered or unexported fields
}

PriorityQueue is a priority queue that sorts elements by a priority value.

func New

func New[Element any, Priority generalheap.Comparable[Priority]]() *PriorityQueue[Element, Priority]

New creates a new PriorityQueue.

func (*PriorityQueue[Element, Priority]) IsEmpty

func (p *PriorityQueue[Element, Priority]) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*PriorityQueue[Element, Priority]) Peek

func (p *PriorityQueue[Element, Priority]) Peek() (element Element, exists bool)

Peek returns the element with the highest priority without removing it.

func (*PriorityQueue[Element, Priority]) Pop

func (p *PriorityQueue[Element, Priority]) Pop() (element Element, exists bool)

Pop removes the element with the highest priority from the queue.

func (*PriorityQueue[Element, Priority]) PopAll

func (p *PriorityQueue[Element, Priority]) PopAll() []Element

PopAll removes all elements from the queue.

func (*PriorityQueue[Element, Priority]) PopUntil

func (p *PriorityQueue[Element, Priority]) PopUntil(priority Priority) []Element

PopUntil removes all elements with a priority lower than the given priority from the queue.

func (*PriorityQueue[Element, Priority]) Push

func (p *PriorityQueue[Element, Priority]) Push(element Element, priority Priority) (remove func())

Push adds an element to the queue with the given priority.

func (*PriorityQueue[Element, Priority]) Size

func (p *PriorityQueue[Element, Priority]) Size() int

Size returns the number of elements in the queue.

Jump to

Keyboard shortcuts

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