pq

package
v0.0.0-...-e61498d Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Unlicense Imports: 1 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[T any] struct {
	// contains filtered or unexported fields
}

An Item is something we manage in a priority queue.

type PriorityQueue

type PriorityQueue[T any] []*Item[T]

A PriorityQueue implements heap.Interface and holds Items.

func (*PriorityQueue[T]) Get

func (pq *PriorityQueue[T]) Get() *T

func (*PriorityQueue[T]) Has

func (pq *PriorityQueue[T]) Has(value *T) bool

func (*PriorityQueue[T]) Init

func (pq *PriorityQueue[T]) Init()

func (PriorityQueue[T]) Len

func (pq PriorityQueue[T]) Len() int

func (PriorityQueue[T]) Less

func (pq PriorityQueue[T]) Less(i, j int) bool

func (*PriorityQueue[T]) NewItem

func (pq *PriorityQueue[T]) NewItem(value *T, priority int, index int)

NewItem sets index manually

func (*PriorityQueue[T]) Pop

func (pq *PriorityQueue[T]) Pop() any

func (*PriorityQueue[T]) Push

func (pq *PriorityQueue[T]) Push(x any)

func (*PriorityQueue[T]) PushValue

func (pq *PriorityQueue[T]) PushValue(value *T, priority int)

PushValue sets index automatically

func (PriorityQueue[T]) Swap

func (pq PriorityQueue[T]) Swap(i, j int)

func (*PriorityQueue[T]) Update

func (pq *PriorityQueue[T]) Update(value *T, priority int)

Update modifies the priority and value of an Item in the queue.

func (*PriorityQueue[T]) UpdateOrAdd

func (pq *PriorityQueue[T]) UpdateOrAdd(value *T, priority int)

UpdateOrAdd modifies the priority and value of an Item in the queue or adds it if it's not there.

Jump to

Keyboard shortcuts

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