heap

package
v0.0.0-...-ab939ae Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHeap

func BuildHeap[VALUE any](heap Interface[VALUE])

func Fix

func Fix[VALUE any](h Interface[VALUE], i int)

func Pop

func Pop[VALUE any](heap Interface[VALUE]) (VALUE, error)

func Push

func Push[VALUE any](heap Interface[VALUE], x VALUE)

func Remove

func Remove[VALUE any](heap Interface[VALUE], i int) (VALUE, error)

Types

type Constraint

type Constraint[KEY comparable, VALUE any] interface {
	FormStoreKey(VALUE) KEY
	Less(VALUE, VALUE) bool
}

type Heap

type Heap[V any] interface {
	Add(value V)
	Delete(value V) error
	Peek() (V, error)
	Pop() (V, error)
	Get(value V) (V, bool)
	List() []V
	Len() int
}

func New

func New[KEY comparable, VALUE any](priority Constraint[KEY, VALUE]) Heap[VALUE]

New returns a heap which can be used to queue up items to process.

func NewConcurrent

func NewConcurrent[VALUE any](priority Constraint[string, VALUE]) Heap[VALUE]

type Interface

type Interface[VALUE any] interface {
	sort.Interface
	Push(x VALUE)
	Pop() (VALUE, error)
}

Jump to

Keyboard shortcuts

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