-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
42 lines (37 loc) · 781 Bytes
/
Copy pathexample_test.go
File metadata and controls
42 lines (37 loc) · 781 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
package weightedrand_test
import (
"fmt"
"math/rand"
"github.com/nikole-dunixi/weightedrand"
)
func ExampleNewAliasVoseMethod() {
rand := rand.New(rand.NewSource(1337))
wr := weightedrand.NewAliasVoseMethod(rand,
weightedrand.WeightedItem[string, int]{
Item: "Hollow Knight: Silksong",
Weight: 1,
},
weightedrand.WeightedItem[string, int]{
Item: "Don't Starve Together",
Weight: 3,
},
weightedrand.WeightedItem[string, int]{
Item: "Stardew Valley",
Weight: 3,
},
weightedrand.WeightedItem[string, int]{
Item: "Deep Rock Galactic",
Weight: 7,
},
)
for range 5 {
fmt.Printf("%s\n", wr.Next())
}
// Output:
//
// Stardew Valley
// Deep Rock Galactic
// Deep Rock Galactic
// Stardew Valley
// Deep Rock Galactic
}