package two type minPath []move func newHeap() *minPath { return &minPath{} } func (h minPath) Len() int { return len(h) } func (h minPath) Less(i, j int) bool { return h[i].cost < h[j].cost } func (h minPath) Swap(i, j int) { h[i], h[j] = h[j], h[i] } func (h *minPath) Push(x interface{}) { *h = append(*h, x.(move)) } func (h *minPath) Pop() interface{} { old := *h n := len(old) x := old[n-1] *h = old[:n-1] return x }