heap

package
v0.0.0-...-5950b5c Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package heap provides heap-related types and utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MaxHeap

type MaxHeap[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

MaxHeap is a max heap (P>=C).

func NewMaxHeap

func NewMaxHeap[T cmp.Ordered](values ...T) *MaxHeap[T]

NewMaxHeap creates a new MaxHeap with the given initial values.

func (*MaxHeap) Len

func (h *MaxHeap) Len() int

func (*MaxHeap) Less

func (h *MaxHeap) Less(i int, j int) bool

func (*MaxHeap[T]) Max

func (h *MaxHeap[T]) Max() T

Max returns the current maximum value on the heap.

func (*MaxHeap) Pop

func (h *MaxHeap) Pop() T

func (*MaxHeap) Push

func (h *MaxHeap) Push(value T)

func (*MaxHeap) Remove

func (h *MaxHeap) Remove(i int) T

func (*MaxHeap) Reset

func (h *MaxHeap) Reset()

func (*MaxHeap) Swap

func (h *MaxHeap) Swap(i int, j int)

type MinHeap

type MinHeap[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

MinHeap is a min heap (P<=C).

func NewMinHeap

func NewMinHeap[T cmp.Ordered](values ...T) *MinHeap[T]

NewMinHeap creates a new MinHeap with the given initial values.

func (*MinHeap) Len

func (h *MinHeap) Len() int

func (*MinHeap) Less

func (h *MinHeap) Less(i int, j int) bool

func (*MinHeap[T]) Min

func (h *MinHeap[T]) Min() T

Min returns the current minimum value on the heap.

func (*MinHeap) Pop

func (h *MinHeap) Pop() T

func (*MinHeap) Push

func (h *MinHeap) Push(value T)

func (*MinHeap) Remove

func (h *MinHeap) Remove(i int) T

func (*MinHeap) Reset

func (h *MinHeap) Reset()

func (*MinHeap) Swap

func (h *MinHeap) Swap(i int, j int)

Jump to

Keyboard shortcuts

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