softheap
Soft Heap Implementation in Go
Description
A soft heap is a priority queue data structure that allows for the create, meld (combine
two soft heaps) and delete operations to be performed in constant amortized time while the
insert operation operates in O(log{1/e}) time, with the caveat that at most e*n
elements in the queue have their key (the priority) corrupted (i.e., their value changed
from the original).
References
Usage
heap := softheap.New[string]()
heap.Insert(10, "Rome")
heap.Insert(2, "Paris")
heap.Insert(5, "London")
k, v := heap.ExtractMin()
fmt.Printf("%d, %s\n", k, v)
k, v = heap.ExtractMin()
fmt.Printf("%d, %s\n", k, v)
k, v = heap.ExtractMin()
fmt.Printf("%d, %s\n", k, v)