-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (35 loc) · 827 Bytes
/
main.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
package main
import (
"github.com/comfysweet/ratings/domain/model"
"github.com/emirpasic/gods/maps/treemap"
)
func main() {
storage := model.PlayerStorage{
PlayerById: map[int]*model.Player{},
PlayersByPoints: treemap.NewWith(IntComparator),
Ratings: model.Ratings{Places: []int{}}}
storage.ChangeRating(1, 1)
storage.PrintStorage()
storage.ChangeRating(2, 0)
storage.PrintStorage()
storage.ChangeRating(2, 3)
storage.PrintStorage()
storage.ChangeRating(3, 1)
storage.PrintStorage()
storage.ChangeRating(3, 0)
storage.PrintStorage()
storage.ChangeRating(3, 1)
storage.PrintStorage()
}
func IntComparator(a, b interface{}) int {
aAsserted := a.(int)
bAsserted := b.(int)
switch {
case aAsserted < bAsserted:
return 1
case aAsserted > bAsserted:
return -1
default:
return 0
}
}