Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type MaxHeap []int
- func (h MaxHeap) Less(i, j int) bool {
- return h[i] < h[j]
- }
- func (h MaxHeap) Swap(i, j int) {
- h[i], h[j] = h[j], h[i]
- }
- func (h MaxHeap) Len() int {
- return len(h)
- }
- func (h *MaxHeap) Push(i interface{}) {
- *h = append(*h, i.(int))
- }
- func (h *MaxHeap) Pop() interface{} {
- item := (*h)[len(*h)-1]
- *h = (*h)[:len(*h)-1]
- return item
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement