pq

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

type PriorityQueue[V Value] struct {
	// contains filtered or unexported fields
}

PriorityQueue is a priority queue implemented with max heap.

func NewPriorityQueue

func NewPriorityQueue[V Value]() *PriorityQueue[V]

NewPriorityQueue creates an instance of NewPriorityQueue.

func (*PriorityQueue[V]) Len

func (pq *PriorityQueue[V]) Len() int

Len is the number of elements in this PriorityQueue.

func (*PriorityQueue[V]) Peek

func (pq *PriorityQueue[V]) Peek() V

Peek returns the maximum element from this PriorityQueue.

func (*PriorityQueue[V]) Pop

func (pq *PriorityQueue[V]) Pop() V

Pop removes and returns the maximum element from this PriorityQueue.

func (*PriorityQueue[V]) Push

func (pq *PriorityQueue[V]) Push(value V)

Push pushes the element x onto this PriorityQueue.

func (*PriorityQueue[V]) Release

func (pq *PriorityQueue[V]) Release(value V)

Release deletes the given value from this PriorityQueue.

func (*PriorityQueue[V]) Values

func (pq *PriorityQueue[V]) Values() []V

Values returns the values of this PriorityQueue.

type Value

type Value interface {
	Less(other Value) bool
}

Value represents the data stored by PriorityQueue.

Jump to

Keyboard shortcuts

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