D16

package
v0.0.0-...-69b1d18 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Help1

func Help1() int

func ReadFile

func ReadFile() [][]string

Types

type HeapKind

type HeapKind int

HeapKind specifies the heap kind - min or max

const (
	// A heap which yields min-value items
	MinHeap HeapKind = iota

	// A heap which yields max-value items
	MaxHeap
)

type Item

type Item[T comparable, V int64 | float64] struct {
	// The value associated with the item
	Value T

	// The priority of the item
	Priority V
	// contains filtered or unexported fields
}

Item represents an item from the priority queue.

type PriorityQueue

type PriorityQueue[T comparable, V int64 | float64] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PriorityQueue is a priority queue implementation based container/heap

func New

func New[T comparable, V int64 | float64](kind HeapKind) *PriorityQueue[T, V]

New creates a new priority queue, containing items of type T with priority V.

func (*PriorityQueue[T, V]) Get

func (pq *PriorityQueue[T, V]) Get() *Item[T, V]

Get returns the next item from the priority queue

func (*PriorityQueue[T, V]) IsEmpty

func (pq *PriorityQueue[T, V]) IsEmpty() bool

IsEmpty returns a boolean indicating whether the priority queue is empty or not

func (*PriorityQueue[T, V]) Len

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

Len implements sort.Interface

func (*PriorityQueue[T, V]) Less

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

Less implements sort.Interface

func (*PriorityQueue[T, V]) Pop

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

Pop implements heap.Interface

func (*PriorityQueue[T, V]) Push

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

Push implements heap.Interface

func (*PriorityQueue[T, V]) Put

func (pq *PriorityQueue[T, V]) Put(value T, priority V)

Put adds a value with the given priority to the priority queue

func (*PriorityQueue[T, V]) Swap

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

Swap implements sort.Interface

func (*PriorityQueue[T, V]) Update

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

Update updates the priority associated with the given value

Jump to

Keyboard shortcuts

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