MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / NewRuneTree

Function NewRuneTree

internal/re/rune_tree.go:50–74  ·  view source on GitHub ↗
(list []string)

Source from the content-addressed store, hash-verified

48}
49
50func NewRuneTree(list []string) RuneMap {
51 var rootMap = RuneMap{}
52 for _, s := range list {
53 if len(s) == 0 {
54 continue
55 }
56
57 var lastMap = rootMap
58 var runes = []rune(s)
59 for index, r := range runes {
60 tree, ok := lastMap[r]
61 if !ok {
62 tree = &RuneTree{
63 Children: RuneMap{},
64 }
65 lastMap[r] = tree
66 }
67 if index == len(runes)-1 {
68 tree.IsEnd = true
69 }
70 lastMap = tree.Children
71 }
72 }
73 return rootMap
74}

Callers 5

TestNewRuneTreeFunction · 0.92
TestNewRuneTree2Function · 0.92
BenchmarkRuneMap_LookupFunction · 0.92
initMethod · 0.85

Calls

no outgoing calls

Tested by 4

TestNewRuneTreeFunction · 0.74
TestNewRuneTree2Function · 0.74
BenchmarkRuneMap_LookupFunction · 0.74