Skip to content

Buzhash

Defined in: rolling/buzhash.ts:59

Buzhash / cyclic-polynomial rolling hash (Cohen 1997): each byte contributes SUBSTITUTION_TABLE[byte], rotated left by its distance from the front of a fixed-size window; sliding the window rotates the whole accumulator left by one and XORs in the new byte’s contribution while XORing out the departing byte’s (pre-rotated by windowSize positions, so removal costs one table lookup, not a runtime rotate).

new Buzhash(windowSize): Buzhash

Defined in: rolling/buzhash.ts:68

number

Buzhash

readonly windowSize: number

Defined in: rolling/buzhash.ts:60

get value(): number

Defined in: rolling/buzhash.ts:87

The rolling hash’s current value.

number

The rolling hash’s current value.

IRollingHash.value

push(byteIn): number

Defined in: rolling/buzhash.ts:91

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

Complexity: O(1).

number

The next byte, 0-255.

number

IRollingHash.push