heap

package
v0.0.0-...-86e9f11 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package heap implements generic heap functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixSlice

func FixSlice[T any](x []T, index int, less func(x, y T) bool)

FixSlice fixes the element x[index] in order to preserve the min-heap invariant determined by the provided comparison function.

func OrderSlice

func OrderSlice[T any](x []T, less func(x, y T) bool)

OrderSlice shuffles x into min-heap ordering according to the provided comparison function. If len(x) > 0, the "smallest" element in x will always be x[0].

func PopSlice

func PopSlice[T any](x *[]T, less func(x, y T) bool) T

PopSlice removes the "smallest" element from x based on the provided comparison function and updates x appropriately to preserve the heap invariant.

func PushSlice

func PushSlice[T any](x *[]T, item T, less func(x, y T) bool)

PushSlice adds item to x while preserving the min-heap invariant determined by the provided comparison function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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