struct SubHash

Defined in:

sub_hash.cr
sub_hash/version.cr

Constant Summary

DefaultBase = 257_u64
DefaultModulo = (1_u64 << HASH_BITS) - 1
HASH_BITS = 61

find a prime number in http://primes.utm.edu/lists/2small/0bit.html 注意避免溢出

VERSION = "0.1.0"

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(base : UInt64 = DefaultBase, modulo : UInt64 = DefaultModulo, capacity : Int32 = 256) #

[View source]

Class Method Detail

def self.convert(elem : Char) : UInt64 #

[View source]
def self.convert(elem : Int) : UInt64 #

[View source]
def self.hash(term, base : UInt64 = DefaultBase, modulo : UInt64 = DefaultModulo) : UInt64 #

x[0] + base * x[1] + base^2 * x[2] ....


[View source]

Instance Method Detail

def [](start, len) : UInt64 #

[View source]
def sub_hash(term) : Void #

[View source]