pq

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 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[S any, T Number] struct {
	Value    S // The Value of the item; arbitrary.
	Priority T // The Priority of the item in the queue.
	// The Index is needed by update and is maintained by the heap.Interface methods.
	Index int // The Index of the item in the heap.
}

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

type PriorityQueue

type PriorityQueue[S any, T Number] []*Item[S, T]

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue[S, T]) Len

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

func (PriorityQueue[S, T]) Less

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

func (*PriorityQueue[S, T]) Pop

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

func (*PriorityQueue[S, T]) Push

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

func (PriorityQueue[S, T]) Swap

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

type SortableMap added in v0.0.5

type SortableMap[S comparable, T Number] map[S]T

func NewSortableMap added in v0.0.5

func NewSortableMap[S comparable, T Number]() SortableMap[S, T]

func (SortableMap[S, T]) Top added in v0.0.5

func (m SortableMap[S, T]) Top(k int) SortableMap[S, T]

Jump to

Keyboard shortcuts

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