-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheap_test.go
57 lines (51 loc) · 992 Bytes
/
heap_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package Solution
import (
"container/heap"
"fmt"
"testing"
)
func TestIntHeap_Less(t *testing.T) {
h := &IntMaxHeap{}
heap.Init(h)
heap.Push(h, 7)
heap.Push(h, 3)
heap.Push(h, 2)
heap.Push(h, 1)
heap.Push(h, 5)
heap.Push(h, 5)
heap.Push(h, 6)
heap.Push(h, 7)
fmt.Printf("minimum: %d\n", (*h))
for h.Len() > 0 {
fmt.Printf("%d ", heap.Pop(h))
}
// fmt.Printf("minimum: %d\n", (*h))
// fmt.Printf("minimum: %d\n", (*h)[2])
//h := &IntMaxHeap{[5]int{}...}
//heap.Init(h)
//n := 0
// for _,v := range nums {
// if n <k {
// }
// }
//}
}
//func TestIntHeap_Max(t *testing.T) {
// h := &IntMaxHeap{}
// heap.Init(h)
// heap.Push(h, 7)
// heap.Push(h, 3)
// heap.Push(h, 2)
// heap.Push(h, 1)
// heap.Push(h, 5)
// heap.Push(h, 5)
// heap.Push(h, 6)
// heap.Push(h, 7)
// fmt.Printf("minimum: %d\n", (*h))
//
// for h.Len() > 0 {
// fmt.Printf("%d ", heap.Pop(h))
// }
// // fmt.Printf("minimum: %d\n", (*h))
// // fmt.Printf("minimum: %d\n", (*h)[2])
//}