The FNVHash structure
Author: John Reppy
Keywords: Standard ML, SML, SML/NJ Library

The SML of NJ Library
The `FNVHash` structure

The `FNVHash` structure provides an implementation of the Fowler-Noll-Vo (FNV) hashing algorithm (specifically the 64-bit FNV-1a algorithm).

## Synopsis

    structure FNVHash

## Interface

    val offsetBasis : Word64.word

    val hashByte : Word8.word * Word64.word -> Word64.word
    val hashChar : char * Word64.word -> Word64.word

    val hashString : string -> word
    val hashSubstring : substring -> word

## Description

`val offsetBasis : Word64.word`

  The `offsetBasis` should be used as the initial value when using `hashByte` and/or `hashChar` to incrementally hash a data value.

`val hashByte : Word8.word * Word64.word -> Word64.word`

  `hashByte (b, h)` computes one step of the FNV hashing algorithm for byte `b` and initial hash value `h`.

`val hashChar : char * Word64.word -> Word64.word`

  `hashByte (c, h)` computes one step of the FNV hashing algorithm for character `c` and initial hash value `h`.

`val hashString : string -> word`

  `hashString s` returns the hash of the given string. It is equivalent to the expression

      CharVector.foldl hashChar offsetBasis s

`val hashSubstring : substring -> word`

  `hashSubstring ss` returns the hash of the given substring. It is equivalent to the expression

      Substring.foldl hashChar offsetBasis ss

## See Also

The Util Library

SML/NJ Version 110.99 (December 24, 2020)
Last updated 2020-04-16 16:37:39 UTC