forked from sean-public/skiplist-survey
-
Notifications
You must be signed in to change notification settings - Fork 2
/
stl4go.go
84 lines (61 loc) · 1.47 KB
/
stl4go.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main
import (
"time"
chen3feng "github.com/chen3feng/stl4go"
)
func chen3fengInserts(n int) {
list := chen3feng.NewSkipList[int, []byte]()
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
list.Insert(n-i, testByteString)
}
}
func chen3fengWorstInserts(n int) {
list := chen3feng.NewSkipList[int, []byte]()
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
list.Insert(i, testByteString)
}
}
func chen3fengAvgSearch(n int) {
list := chen3feng.NewSkipList[int, []byte]()
for i := 0; i < n; i++ {
list.Insert(i, testByteString)
}
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
_ = list.Find(i)
}
}
func chen3fengSearchEnd(n int) {
list := chen3feng.NewSkipList[int, []byte]()
for i := 0; i < n; i++ {
list.Insert(i, testByteString)
}
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
_ = list.Find(n)
}
}
func chen3fengDelete(n int) {
list := chen3feng.NewSkipList[int, []byte]()
for i := 0; i < n; i++ {
list.Insert(i, testByteString)
}
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
_ = list.Remove(i)
}
}
func chen3fengWorstDelete(n int) {
list := chen3feng.NewSkipList[int, []byte]()
for i := 0; i < n; i++ {
list.Insert(i, testByteString)
}
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
_ = list.Remove(n - i)
}
}
var chen3fengFunctions = []func(int){chen3fengInserts, chen3fengWorstInserts,
chen3fengAvgSearch, chen3fengSearchEnd, chen3fengDelete, chen3fengWorstDelete}