Discover Packages
github.com/SnellerInc/sneller
heap
package
Version:
v0.0.0-...-86e9f11
Opens a new window with list of versions in this module.
Published: Jan 7, 2024
License: Apache-2.0
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Package heap implements generic heap functions.
func FixSlice[T any](x []T, index int, less func(x, y T) bool)
func OrderSlice[T any](x []T, less func(x, y T) bool)
func PopSlice[T any](x *[]T, less func(x, y T) bool) T
func PushSlice[T any](x *[]T, item T, less func(x, y T) bool)
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[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[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[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.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.