-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
60 lines (46 loc) · 991 Bytes
/
example_test.go
File metadata and controls
60 lines (46 loc) · 991 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package doublearray_test
import (
"fmt"
doublearray "github.com/kampersanda/doublearray-go"
)
var da *doublearray.DoubleArray
func Example() {
keys := []string{
"Aru", "Bocci", "Kai", "Kako", "Nako", "Nakosuke", "Sotca",
}
values := []int{
1, 2, 3, 4, 5, 6, 7,
}
da, _ = doublearray.Build(keys, values)
value, found := da.Lookup("Bocci")
fmt.Println(value, found)
value, found = da.Lookup("Peko")
fmt.Println(value, found)
// Output:
// 2 true
// 0 false
}
func Example_prefixLookup() {
keys, values := da.PrefixLookup("Nakosuke")
fmt.Println(keys)
fmt.Println(values)
// Output:
// [Nako Nakosuke]
// [5 6]
}
func Example_predictiveLookup() {
keys, values := da.PredictiveLookup("Ka")
fmt.Println(keys)
fmt.Println(values)
// Output:
// [Kai Kako]
// [3 4]
}
func Example_enumerate() {
keys, values := da.PredictiveLookup("")
fmt.Println(keys)
fmt.Println(values)
// Output:
// [Aru Bocci Kai Kako Nako Nakosuke Sotca]
// [1 2 3 4 5 6 7]
}