class RollingHash
- RollingHash
- Reference
- Object
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.crConstructors
-
.new(text : String, size : Int32)
Creates a new RollingHash for the document text, for substrings of length size.
Instance Method Summary
-
#next : Int32
Advances the substring window by one and returns the next hash.
-
#onetime(s : String) : Int32
Returns a hash for a single string from this instance's exiting parameters.
Constructor Detail
def self.new(text : String, size : Int32)
#
Creates a new RollingHash for the document text, for substrings of length size.
Instance Method Detail
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.