class RollingHash

Overview

Rolling hash generator for use with algorithms such as Rabin-Karp. Initialized with the entire text to generate a rolling hash for, and can then be called upon to return the next hash in the sequence with #next. Hashes are all Int32s.

Defined in:

rabin-karp/rabin-karp.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(text : String, size : Int32) #

Creates a new RollingHash for the document text, for substrings of length size.


[View source]

Instance Method Detail

def next : Int32 #

Advances the substring window by one and returns the next hash.


[View source]
def onetime(s : String) : Int32 #

Returns a hash for a single string from this instance's exiting parameters. Doesn't store the string as it will never be advanced.


[View source]