MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Horspool

Function Horspool

strings/horspool/horspool.go:10–14  ·  view source on GitHub ↗
(t, p string)

Source from the content-addressed store, hash-verified

8var ErrNotFound = errors.New("pattern was not found in the input string")
9
10func Horspool(t, p string) (int, error) {
11 // in order to handle multy-byte character properly
12 // the input is converted into rune arrays
13 return horspool([]rune(t), []rune(p))
14}
15
16func horspool(t, p []rune) (int, error) {
17 shiftMap := computeShiftMap(t, p)

Callers 2

TestLHorspoolFunction · 0.85

Calls 1

horspoolFunction · 0.85

Tested by 2

TestLHorspoolFunction · 0.68