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

Function isMatch

strings/horspool/horspool.go:43–49  ·  view source on GitHub ↗

Checks if the array p matches the subarray of t starting at pos. Note that backward iteration. There are [other](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm#Tuning_the_comparison_loop) approaches possible.

(pos int, t, p []rune)

Source from the content-addressed store, hash-verified

41// There are [other](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm#Tuning_the_comparison_loop)
42// approaches possible.
43func isMatch(pos int, t, p []rune) bool {
44 j := len(p)
45 for j > 0 && t[pos+j-1] == p[j-1] {
46 j--
47 }
48 return j == 0
49}
50
51func computeShiftMap(t, p []rune) (res map[rune]int) {
52 res = make(map[rune]int)

Callers 1

horspoolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected