Home Manual Reference Source

Function

Static Public Summary
public

build(p: ArrayLike, pi: number, pj: number, t: number[], ti: number)

Computes for each j the largest 0 <= i < j such that p.slice(0, i) is p.slice(j-i, j).

Static Public

public build(p: ArrayLike, pi: number, pj: number, t: number[], ti: number) source

Computes for each j the largest 0 <= i < j such that p.slice(0, i) is p.slice(j-i, j).

This is the "f[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.

Params:

NameTypeAttributeDescription
p ArrayLike
pi number
pj number
t number[]
ti number