| 1 |
**This repo is deprecated, Renamed to PriorityQueue and moved to http://github.com/mailgun/holster** |
| 2 |
|
| 3 |
[](https://drone.io/github.com/mailgun/minheap/latest) |
| 4 |
|
| 5 |
minheap |
| 6 |
======= |
| 7 |
|
| 8 |
Slightly more user-friendly heap on top of containers/heap. |
| 9 |
|
| 10 |
```go |
| 11 |
|
| 12 |
import "github.com/mailgun/minheap" |
| 13 |
|
| 14 |
|
| 15 |
func toEl(i int) interface{} { |
| 16 |
return &i |
| 17 |
} |
| 18 |
|
| 19 |
func fromEl(i interface{}) int { |
| 20 |
return *(i.(*int)) |
| 21 |
} |
| 22 |
|
| 23 |
mh := minheap.NewMinHeap() |
| 24 |
|
| 25 |
el := &minheap.Element{ |
| 26 |
Value: toEl(1), |
| 27 |
Priority: 5, |
| 28 |
} |
| 29 |
|
| 30 |
mh.PushEl(el) |
| 31 |
mh.PeekEl() |
| 32 |
mh.Len() |
| 33 |
mh.PopEl() |
| 34 |
|
| 35 |
``` |