heap

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package heap provides a typed min-heap with addressable items.

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
}

Heap is a min-heap keyed by int64. The zero value is usable.

func New

func New[T any]() *Heap[T]

func (*Heap[T]) Fix

func (h *Heap[T]) Fix(it *Item[T], newKey int64)

func (*Heap[T]) Len

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

func (*Heap[T]) Peek

func (h *Heap[T]) Peek() (*Item[T], bool)

func (*Heap[T]) Pop

func (h *Heap[T]) Pop() (*Item[T], bool)

func (*Heap[T]) Push

func (h *Heap[T]) Push(key int64, v T) *Item[T]

func (*Heap[T]) Remove

func (h *Heap[T]) Remove(it *Item[T])

type Item

type Item[T any] struct {
	Key   int64
	Value T
	// contains filtered or unexported fields
}

Item is a heap entry returned by Push and accepted by Fix/Remove.

func (*Item[T]) Index

func (it *Item[T]) Index() int

Index reports the item's heap position, or -1 after removal.

Jump to

Keyboard shortcuts

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