-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
74 lines (69 loc) · 1.49 KB
/
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"fmt"
elli "github.com/elliotchance/orderedmap"
iter "github.com/mantyr/iterator"
"github.com/mitchellh/hashstructure"
wk8 "github.com/wk8/go-ordered-map"
"strconv"
"math/rand"
)
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func RandStringRunes(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}
type human struct {
Name string
Age int
Job string
}
func makeData() human {
ret := human{
Name: RandStringRunes(10),
Age: rand.Int(),
Job: RandStringRunes(5),
}
return ret
}
const SIZE = 10
// logic testing
func main() {
lookup := make(map[string]human, SIZE)
stringmap := make([]string, 0)
wk8om := wk8.New()
elli := elli.NewOrderedMap()
iterom := iter.New()
for i := 0; i < SIZE; i += 1 {
data := makeData()
hash, _ := hashstructure.Hash(data, nil)
key := strconv.FormatUint(hash, 10)
stringmap = append(stringmap, key)
lookup[key] = data
wk8om.Set(key, data)
elli.Set(key, data)
iterom.Add(key, data)
}
//fmt.Println(lookup)
keymap := make([]int, 0)
for i:=0;i<SIZE;i++ {
keymap = append(keymap, i)
}
rand.Shuffle(len(keymap),func(i, j int) {
keymap [i], keymap[j] = keymap [j], keymap[i]
})
fmt.Println(wk8om)
fmt.Println(elli)
fmt.Println(iterom)
for key := range keymap {
wk8om.Delete(stringmap[key])
elli.Delete(stringmap[key])
iterom.Del(stringmap[key])
}
fmt.Println(wk8om)
fmt.Println(elli)
fmt.Println(iterom)
}