Source File
search.go
Belonging Package
strings
package strings
badCharSkip [256]int
goodSuffixSkip []int
}
func ( string) *stringFinder {
:= &stringFinder{
pattern: ,
goodSuffixSkip: make([]int, len()),
:= len() - 1
for := range .badCharSkip {
.badCharSkip[] = len()
for := 0; < ; ++ {
.badCharSkip[[]] = -
}
:=
for := ; >= 0; -- {
if HasPrefix(, [+1:]) {
= + 1
.goodSuffixSkip[] = + -
for := 0; < ; ++ {
:= longestCommonSuffix(, [1:+1])
func ( *stringFinder) ( string) int {
:= len(.pattern) - 1
:= len(.pattern) - 1
for >= 0 && [] == .pattern[] {
--
--
}
if < 0 {
return + 1 // match
}
+= max(.badCharSkip[[]], .goodSuffixSkip[])
}
return -1
}
func (, int) int {
if > {
return
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |