Heap

package
v0.0.0-...-de9bdf8 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

type Heap[T any] struct {
	// contains filtered or unexported fields
}

func NewHeap

func NewHeap[T any](mode string) *Heap[T]

Create a new heap

func (*Heap[T]) Insert

func (h *Heap[T]) Insert(value T, priority int)

Add item to the heap

func (*Heap[T]) Peek

func (h *Heap[T]) Peek() Sortable[T]

Peek at the top item in the heap

func (*Heap[T]) Remove

func (h *Heap[T]) Remove() Sortable[T]

Remove item from the heap. Returns the item with the highest priority

func (*Heap[T]) Size

func (h *Heap[T]) Size() int

Get the size of the heap

type Sortable

type Sortable[T any] struct {
	Value    T
	Priority int
}

Jump to

Keyboard shortcuts

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