Registry / utility / aalpar-deheap

aalpar-deheap

JSON →
library1.1.2gogounverified

A doubly-ended heap (min-max heap) implementation providing O(log n) access to both smallest and largest elements.

go get github.com/aalpar/deheap
INSTALL
IMPORT
SIG · AALPAR-DEHEAP
A
aalpar-deheap
utilitygov1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

deheap
github.com/aalpar/deheap

Creates a min-max heap and retrieves min and max elements.

package main import ( "container/heap" "fmt" "github.com/aalpar/deheap" ) type IntHeap []int func (h IntHeap) Len() int { return len(h) } func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] } func (h IntHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } func (h *IntHeap) Push(x interface{}) { *h = append(*h, x.(int)) } func (h *IntHeap) Pop() interface{} { old := *h; n := len(old); x := old[n-1]; *h = old[0 : n-1]; return x } func main() { h := &IntHeap{3, 1, 4} heap.Init(h) deheap.Init(h) fmt.Println(deheap.Min(h), deheap.Max(h)) }
Debug
Known issues

No known issues recorded.

Upgrade
Version history
1.1.2latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
46 hits · last 30 days
node
40
OpenAI (training)
1
Resources
aalpar-deheap — go get aalpar-deheap · libregistry