Function
Static Public Summary | ||
public |
Computes the failure function for input string. |
Static Public
public build(p: ArrayLike, pi: number, pj: number, t: number[], ti: number) source
import build from '@string-data-structure/failure-function/src/build.js'
Computes the failure function for input string.
This is the "next[j]" table found in "Fast pattern matching in strings" by Knuth, Morris, and Pratt, although here indices are 0-based hence all indices and inputs are one less than in that paper.
NOTE The main loop is somewhat unrolled for faster execution. This was not benchmarked.