priority_queue

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) int

Push pushes the 'value' onto the priority queue.

func (*Queue[V, P]) Update

func (pq *Queue[V, P]) Update(index int, value V, priority P) int

Update modifies the priority and value of the item with 'index' in the queue. returns the updated index.

Jump to

Keyboard shortcuts

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