Documentation
¶
Overview ¶
Example ¶
package main import ( "fmt" "github.com/joetifa2003/mm-go/allocator" "github.com/joetifa2003/mm-go/minheap" ) func int_less(a, b int) bool { return a < b } func main() { alloc := allocator.NewC() defer alloc.Destroy() h := minheap.New[int](alloc, int_less) // Push some values onto the heap h.Push(2) h.Push(1) h.Push(4) h.Push(3) h.Push(5) // Pop the minimum value from the heap fmt.Println(h.Pop()) fmt.Println(h.Pop()) }
Output: 1 2
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MinHeap ¶
type MinHeap[T any] struct { // contains filtered or unexported fields }
func (*MinHeap[T]) Peek ¶
func (h *MinHeap[T]) Peek() T
Peek returns the minimum value from the heap without removing it.
Click to show internal directories.
Click to hide internal directories.