Skip to content

RabinKarpHash

Defined in: rolling/rabin-karp-hash.ts:33

Rabin-Karp’s “standard polynomial” rolling hash: ordinary modular integer arithmetic (unlike RabinFingerprint’s GF(2) polynomial division) — hash = (hash * base + byteIn) mod modulus, i.e. the sliding-window recurrence from Wikipedia’s “Rolling hash” article’s “Polynomial rolling hash” section (first byte carries the highest power of base), with the departing byte’s contribution (byteOut * base^(windowSize - 1) mod modulus) subtracted out first. The high-order term is precomputed once at construction via bigIntModPow, since windowSize is fixed per instance.

new RabinKarpHash(windowSize, options?): RabinKarpHash

Defined in: rolling/rabin-karp-hash.ts:44

number

RabinKarpHashOptions

RabinKarpHash

readonly windowSize: number

Defined in: rolling/rabin-karp-hash.ts:34

get value(): bigint

Defined in: rolling/rabin-karp-hash.ts:60

The rolling hash’s current value.

bigint

The rolling hash’s current value.

IRollingHash.value

push(byteIn): bigint

Defined in: rolling/rabin-karp-hash.ts:64

Feeds one more byte into the window, returning the updated value.

Complexity: O(1).

number

The next byte, 0-255.

bigint

IRollingHash.push