Namespace: go.std.hash.maphash
v1.0Contents
Summary
Provides a lowlevel interface to the hash/maphash package.
Package maphash provides hash functions on byte sequences.
These hash functions are intended to be used to implement hash tables or
other data structures that need to map arbitrary strings or byte
sequences to a uniform distribution on unsigned 64bit integers.
Each different instance of a hash table or data structure should use its own Seed.
The hash functions are not cryptographically secure.
(See crypto/sha256 and crypto/sha512 for cryptographic use.)
Index
Legend

Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.
(None.)
Variables

(None.)
Functions, Macros, and Special Forms

MakeSeed
Function v1.0(MakeSeed)
MakeSeed returns a new random seed.
Go returns: Seed
Joker input arguments: []
Joker returns: ^Seed
Types

Hash
Concrete Type v1.0A Hash computes a seeded hash of a byte sequence.
The zero Hash is a valid Hash ready to use.
A zero Hash chooses a random seed for itself during
the first call to a Reset, Write, Seed, Sum64, or Seed method.
For control over the seed, use SetSeed.
The computed hash values depend only on the initial seed and
the sequence of bytes provided to the Hash object, not on the way
in which the bytes are provided. For example, the three sequences
h.Write([]byte{'f','o','o'})
h.WriteByte('f'); h.WriteByte('o'); h.WriteByte('o')
h.WriteString("foo")
all have the same effect.
Hashes are intended to be collisionresistant, even for situations
where an adversary controls the byte sequences being hashed.
A Hash is not safe for concurrent use by multiple goroutines, but a Seed is.
If multiple goroutines must compute the same seeded hash,
each can declare its own Hash and call SetSeed with a common Seed.

Seed
Concrete Type v1.0A Seed is a random value that selects the specific hash function
computed by a Hash. If two Hashes use the same Seeds, they
will compute the same hash values for any given input.
If two Hashes use different Seeds, they are very likely to compute
distinct hash values for any given input.
A Seed must be initialized by calling MakeSeed.
The zero seed is uninitialized and not valid for use with Hash's SetSeed method.
Each Seed value is local to a single process and cannot be serialized
or otherwise recreated in a different process.

arrayOfHash
Concrete Type v1.0A Hash computes a seeded hash of a byte sequence.
The zero Hash is a valid Hash ready to use.
A zero Hash chooses a random seed for itself during
the first call to a Reset, Write, Seed, Sum64, or Seed method.
For control over the seed, use SetSeed.
The computed hash values depend only on the initial seed and
the sequence of bytes provided to the Hash object, not on the way
in which the bytes are provided. For example, the three sequences
h.Write([]byte{'f','o','o'})
h.WriteByte('f'); h.WriteByte('o'); h.WriteByte('o')
h.WriteString("foo")
all have the same effect.
Hashes are intended to be collisionresistant, even for situations
where an adversary controls the byte sequences being hashed.
A Hash is not safe for concurrent use by multiple goroutines, but a Seed is.
If multiple goroutines must compute the same seeded hash,
each can declare its own Hash and call SetSeed with a common Seed.

arrayOfSeed
Concrete Type v1.0A Seed is a random value that selects the specific hash function
computed by a Hash. If two Hashes use the same Seeds, they
will compute the same hash values for any given input.
If two Hashes use different Seeds, they are very likely to compute
distinct hash values for any given input.
A Seed must be initialized by calling MakeSeed.
The zero seed is uninitialized and not valid for use with Hash's SetSeed method.
Each Seed value is local to a single process and cannot be serialized
or otherwise recreated in a different process.

refToHash
Concrete Type v1.0A Hash computes a seeded hash of a byte sequence.
The zero Hash is a valid Hash ready to use.
A zero Hash chooses a random seed for itself during
the first call to a Reset, Write, Seed, Sum64, or Seed method.
For control over the seed, use SetSeed.
The computed hash values depend only on the initial seed and
the sequence of bytes provided to the Hash object, not on the way
in which the bytes are provided. For example, the three sequences
h.Write([]byte{'f','o','o'})
h.WriteByte('f'); h.WriteByte('o'); h.WriteByte('o')
h.WriteString("foo")
all have the same effect.
Hashes are intended to be collisionresistant, even for situations
where an adversary controls the byte sequences being hashed.
A Hash is not safe for concurrent use by multiple goroutines, but a Seed is.
If multiple goroutines must compute the same seeded hash,
each can declare its own Hash and call SetSeed with a common Seed.

BlockSize
Receiver for refToHash v1.0([])
BlockSize returns h's block size.

Reset
Receiver for refToHash v1.0([])
Reset discards all bytes added to h.
(The seed remains the same.)

Seed
Receiver for refToHash v1.0([])
Seed returns h's seed value.

SetSeed
Receiver for refToHash v1.0([seed])
SetSeed sets h to use seed, which must have been returned by MakeSeed
or by another Hash's Seed method.
Two Hash objects with the same seed behave identically.
Two Hash objects with different seeds will very likely behave differently.
Any bytes added to h before this call will be discarded.

Size
Receiver for refToHash v1.0([])
Size returns h's hash value size, 8 bytes.

Sum
Receiver for refToHash v1.0([b])
Sum appends the hash's current 64bit value to b.
It exists for implementing hash.Hash.
For direct calls, it is more efficient to use Sum64.

Sum64
Receiver for refToHash v1.0([])
Sum64 returns h's current 64bit value, which depends on
h's seed and the sequence of bytes added to h since the
last call to Reset or SetSeed.
All bits of the Sum64 result are close to uniformly and
independently distributed, so it can be safely reduced
by using bit masking, shifting, or modular arithmetic.

Write
Receiver for refToHash v1.0([b])
Write adds b to the sequence of bytes hashed by h.
It always writes all of b and never fails; the count and error result are for implementing io.Writer.

WriteByte
Receiver for refToHash v1.0([b])
WriteByte adds b to the sequence of bytes hashed by h.
It never fails; the error result is for implementing io.ByteWriter.

WriteString
Receiver for refToHash v1.0([s])
WriteString adds the bytes of s to the sequence of bytes hashed by h.
It always writes all of s and never fails; the count and error result are for implementing io.StringWriter.

refToSeed
Concrete Type v1.0A Seed is a random value that selects the specific hash function
computed by a Hash. If two Hashes use the same Seeds, they
will compute the same hash values for any given input.
If two Hashes use different Seeds, they are very likely to compute
distinct hash values for any given input.
A Seed must be initialized by calling MakeSeed.
The zero seed is uninitialized and not valid for use with Hash's SetSeed method.
Each Seed value is local to a single process and cannot be serialized
or otherwise recreated in a different process.