(runes []rune, caseInsensitive bool, depth int)
| 9 | } |
| 10 | |
| 11 | func (this RuneMap) lookup(runes []rune, caseInsensitive bool, depth int) bool { |
| 12 | if len(runes) == 0 { |
| 13 | return false |
| 14 | } |
| 15 | for i, r := range runes { |
| 16 | tree, ok := this[r] |
| 17 | if !ok { |
| 18 | if caseInsensitive { |
| 19 | if r >= 'a' && r <= 'z' { |
| 20 | r -= 32 |
| 21 | tree, ok = this[r] |
| 22 | } else if r >= 'A' && r <= 'Z' { |
| 23 | r += 32 |
| 24 | tree, ok = this[r] |
| 25 | } |
| 26 | } |
| 27 | if !ok { |
| 28 | if depth > 0 { |
| 29 | return false |
| 30 | } |
| 31 | continue |
| 32 | } |
| 33 | } |
| 34 | if tree.IsEnd { |
| 35 | return true |
| 36 | } |
| 37 | b := tree.Children.lookup(runes[i+1:], caseInsensitive, depth+1) |
| 38 | if b { |
| 39 | return true |
| 40 | } |
| 41 | } |
| 42 | return false |
| 43 | } |
| 44 | |
| 45 | type RuneTree struct { |
| 46 | Children RuneMap |
no outgoing calls
no test coverage detected