Home Manual Reference Source

Function

Static Public Summary
public

rabinKarp(code: Function, d: number, q: number, one: number): Function

Note that q should be random and about m (that is, log m bits) for best performance.

Static Public

public rabinKarp(code: Function, d: number, q: number, one: number): Function source

Note that q should be random and about m (that is, log m bits) for best performance. Make sure d * (q-1) <= Number.MAX_SAFE_INTEGER and q + (q-1) <= Number.MAX_SAFE_INTEGER. Otherwise use bigints.

Params:

NameTypeAttributeDescription
code Function

Returns a value between 0 and d-1.

d number

|∑|

q number

is the prime number to use to lessen spurious hits

one number
  • optional
  • default: 1

The value for one. Given 1n if using bigints.

Return:

Function