예제 #1
0
func sort(arr []int) []int {
	h := heap.NewMin()
	for i := 0; i < len(arr); i++ {
		h.Insert(heap.Int(arr[i]))
	}

	for i := 0; i < len(arr); i++ {
		arr[i] = int(h.Extract().(heap.Int))
	}

	return arr
}
예제 #2
0
func NewMin() (q *PQ) {
	return &PQ{
		data: *heap.NewMin(),
	}
}