priority_queue

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: MIT 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[V any, P constraints.Ordered] struct {
	// contains filtered or unexported fields
}

type Queue

type Queue[V any, P constraints.Ordered] struct {
	// contains filtered or unexported fields
}

Queue represents a priority queue with MINIMUM priority.

func New

func New[V any, P constraints.Ordered]() Queue[V, P]

New creates a new priority queue. Not required to call.

func (*Queue[V, P]) Len

func (pq *Queue[V, P]) Len() int

Len returns the length of the priroity queue.

func (*Queue[V, P]) Peek

func (pq *Queue[V, P]) Peek() V

Peek returns the minimum element of the priority queue without removing it.

func (*Queue[V, P]) PeekPriority

func (pq *Queue[V, P]) PeekPriority() P

Peek returns the minimum element's priority.

func (*Queue[V, P]) Pop

func (pq *Queue[V, P]) Pop() V

Pop removes and returns the minimum element of the priority queue.

func (*Queue[V, P]) Push

func (pq *Queue[V, P]) Push(value V, priority P) *Item[V, P]

Push pushes the 'value' onto the priority queue.

func (*Queue[V, P]) Update

func (pq *Queue[V, P]) Update(item *Item[V, P], value V, priority P)

Update modifies the priority and value of the item

Jump to

Keyboard shortcuts

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