hash::fnv
Implements the Fowler–Noll–Vo (FNV) hash function. This hash is recommended for hash map keys and similar applications when hash flooding isn't an issue. It is a non-cryptographic hash.
Index
Types
type state32 = struct {
hash::hash,
v: u32,
};
type state64 = struct {
hash::hash,
v: u64,
};
Functions
fn fnv32() state32;
fn fnv32a() state32;
fn fnv64() state64;
fn fnv64a() state64;
fn string(s: str) size;
fn string32(s: str) u32;
fn string64(s: str) u64;
fn sum32(h: *hash::hash) u32;
fn sum64(h: *hash::hash) u64;
Types
type state32
Show undocumented member
type state32 = struct {
hash::hash,
v: u32,
};
type state64
Show undocumented member
type state64 = struct {
hash::hash,
v: u64,
};
Functions
fn fnv32
fn fnv32() state32;
Creates a hash::hash which computes the FNV-1 32-bit hash function. This hash does not allocate any state, so you do not need to call hash::close when you're done with it.
Unless you have a reason to use this, fnv32a is recommended instead.
fn fnv32a
fn fnv32a() state32;
Creates a hash::hash which computes the FNV-1a 32-bit hash function. This hash does not allocate any state, so you do not need to call hash::close when you're done with it.
fn fnv64
fn fnv64() state64;
Creates a hash::hash which computes the FNV-1 64-bit hash function. This hash does not allocate any state, so you do not need to call hash::close when you're done with it.
Unless you have a reason to use this, fnv64a is recommended instead.
fn fnv64a
fn fnv64a() state64;
Creates a hash::hash which computes the FNV-1a 64-bit hash function. This hash does not allocate any state, so you do not need to call hash::close when you're done with it.
fn string
fn string(s: str) size;
Hashes a string, returning a size key, for use in a hash map.
fn string32
fn string32(s: str) u32;
Hashes a string, returning a 32-bit key.
fn string64
fn string64(s: str) u64;
Hashes a string, returning a 64-bit key.
fn sum32
fn sum32(h: *hash::hash) u32;
Returns the sum of a 32-bit FNV hash.
fn sum64
fn sum64(h: *hash::hash) u64;
Returns the sum of a 64-bit FNV hash.