-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathheap_test.go
More file actions
49 lines (38 loc) · 933 Bytes
/
heap_test.go
File metadata and controls
49 lines (38 loc) · 933 Bytes
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
package promsketch
import (
"fmt"
"testing"
)
func TestTopKHeap(t *testing.T) {
topkheap := NewTopKHeap(5)
topkheap.Update("orange", 1)
fmt.Println("after insert orange:")
topkheap.Print()
topkheap.Update("mango", 10)
fmt.Println("after insert mango:")
topkheap.Print()
topkheap.Insert("lemon", 8)
fmt.Println("after insert lemon:")
topkheap.Print()
topkheap.Insert("kiwi", 11)
fmt.Println("after insert kiwi:")
topkheap.Print()
topkheap.Update("aa", 1)
fmt.Println("after insert aa:")
topkheap.Print()
topkheap.Update("mango", 0)
fmt.Println("after update mongo:")
topkheap.Print()
topkheap.Update("mango", 100)
fmt.Println("after update mongo:")
topkheap.Print()
topkheap.Update("bb", 3)
fmt.Println("after update bb:")
topkheap.Print()
topkheap.Update("cc", 5)
fmt.Println("after update cc:")
topkheap.Print()
topkheap.Update("dd", 1)
fmt.Println("after update dd:")
topkheap.Print()
}