perfect-hash-generator-0.1.0.3: Perfect minimal hashing implementation in native Haskell

Safe HaskellSafe
LanguageHaskell2010

Data.PerfectHash.Hashing

Description

Implements the specialized hash function for this perfect hashing algorithm.

Synopsis

Documentation

primeFNV :: Int Source #

This choice of prime number was taken from the Python implementation on Steve Hanov's page.

class ToNumeric a where Source #

A Foldable of any data type may be hashed, so long as it implements an instance of this class.

Minimal complete definition

toNum

Methods

toNum :: a -> Int Source #

Instances

ToNumeric Char Source #

The numeric value of a character is simply its ordinal value.

Methods

toNum :: Char -> Int Source #

ToNumeric Int Source # 

Methods

toNum :: Int -> Int Source #

hash :: (Foldable f, ToNumeric a) => Int -> f a -> Int Source #

Uses the "FNV-1a" algorithm from the FNV website:

hash = offset_basis
for each octet_of_data to be hashed
        hash = hash xor octet_of_data
        hash = hash * FNV_prime
return hash

The interface is comparable to the hashWithSalt function from the hashable package.