heapq

package
v0.0.0-...-c03e3e1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 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 Heapq

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

Heapq represents a priority queue implemented using a binary heap.

func (*Heapq[T]) IsEmpty

func (h *Heapq[T]) IsEmpty() bool

IsEmpty returns true if the heap is empty.

func (*Heapq[T]) Peek

func (h *Heapq[T]) Peek() (T, error)

Peek returns the item with the highest priority without removing it from the heap. It returns an error if the heap is empty.

func (*Heapq[T]) Pop

func (h *Heapq[T]) Pop() (T, error)

Pop removes and returns the item with the highest priority (i.e., the smallest priority value). It returns an error if the heap is empty.

func (*Heapq[T]) Push

func (h *Heapq[T]) Push(item T, priority int)

Push adds a new item to the heap with the given priority. It maintains the heap property by sifting up the new element.

func (*Heapq[T]) Size

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

Size returns the number of elements in the heap.

Jump to

Keyboard shortcuts

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