boolmap - examples_test.go
1 package boolmap_test
2
3 import (
4 "fmt"
5
6 "vimagination.zapto.org/boolmap"
7 )
8
9 func ExampleMap() {
10 m := boolmap.NewMap()
11
12 m.SetBool(42, true)
13 m.SetBool(100, false)
14
15 fmt.Println(m.GetBool(42))
16 fmt.Println(m.GetBool(100))
17 fmt.Println(m.GetBool(101))
18
19 // Output:
20 // true
21 // false
22 // false
23 }
24
25 func ExampleSlice() {
26 m := boolmap.NewSlice()
27
28 m.SetBool(42, true)
29 m.SetBool(100, false)
30
31 fmt.Println(m.GetBool(42))
32 fmt.Println(m.GetBool(100))
33 fmt.Println(m.GetBool(101))
34
35 // Output:
36 // true
37 // false
38 // false
39 }
40
41 func ExampleCrumbMap() {
42 m := boolmap.NewCrumbMap()
43
44 m.Set(42, 1)
45 m.Set(100, 3)
46
47 fmt.Println(m.Get(42))
48 fmt.Println(m.Get(100))
49 fmt.Println(m.Get(101))
50
51 // Output:
52 // 1
53 // 3
54 // 0
55 }
56
57 func ExampleCrumbSlice() {
58 m := boolmap.NewCrumbSlice()
59
60 m.Set(42, 1)
61 m.Set(100, 3)
62
63 fmt.Println(m.Get(42))
64 fmt.Println(m.Get(100))
65 fmt.Println(m.Get(101))
66
67 // Output:
68 // 1
69 // 3
70 // 0
71 }
72
73 func ExampleNibbleMap() {
74 m := boolmap.NewNibbleMap()
75
76 m.Set(42, 11)
77 m.Set(100, 13)
78
79 fmt.Println(m.Get(42))
80 fmt.Println(m.Get(100))
81 fmt.Println(m.Get(101))
82
83 // Output:
84 // 11
85 // 13
86 // 0
87 }
88
89 func ExampleNibbleSlice() {
90 m := boolmap.NewNibbleSlice()
91
92 m.Set(42, 11)
93 m.Set(100, 13)
94
95 fmt.Println(m.Get(42))
96 fmt.Println(m.Get(100))
97 fmt.Println(m.Get(101))
98
99 // Output:
100 // 11
101 // 13
102 // 0
103 }
104