type Seed … // Bytes returns the hash of b with the given seed. // // Bytes is equivalent to, but more convenient and efficient than: // // var h Hash // h.SetSeed(seed) // h.Write(b) // return h.Sum64() func Bytes(seed Seed, b []byte) uint64 { … } // String returns the hash of s with the given seed. // // String is equivalent to, but more convenient and efficient than: // // var h Hash // h.SetSeed(seed) // h.WriteString(s) // return h.Sum64() func String(seed Seed, s string) uint64 { … } type Hash … const bufSize … // initSeed seeds the hash if necessary. // initSeed is called lazily before any operation that actually uses h.seed/h.state. // Note that this does not include Write/WriteByte/WriteString in the case // where they only add to h.buf. (If they write too much, they call h.flush, // which does call h.initSeed.) func (h *Hash) initSeed() { … } // WriteByte adds b to the sequence of bytes hashed by h. // It never fails; the error result is for implementing [io.ByteWriter]. func (h *Hash) WriteByte(b byte) error { … } // 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]. func (h *Hash) Write(b []byte) (int, error) { … } // 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]. func (h *Hash) WriteString(s string) (int, error) { … } // Seed returns h's seed value. func (h *Hash) Seed() Seed { … } // SetSeed sets h to use seed, which must have been returned by [MakeSeed] // or by another [Hash.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. func (h *Hash) SetSeed(seed Seed) { … } // Reset discards all bytes added to h. // (The seed remains the same.) func (h *Hash) Reset() { … } // precondition: buffer is full. func (h *Hash) flush() { … } // Sum64 returns h's current 64-bit value, which depends on // h's seed and the sequence of bytes added to h since the // last call to [Hash.Reset] or [Hash.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. func (h *Hash) Sum64() uint64 { … } // MakeSeed returns a new random seed. func MakeSeed() Seed { … } // Sum appends the hash's current 64-bit value to b. // It exists for implementing [hash.Hash]. // For direct calls, it is more efficient to use [Hash.Sum64]. func (h *Hash) Sum(b []byte) []byte { … } // Size returns h's hash value size, 8 bytes. func (h *Hash) Size() int { … } // BlockSize returns h's block size. func (h *Hash) BlockSize() int { … } // Comparable returns the hash of comparable value v with the given seed // such that Comparable(s, v1) == Comparable(s, v2) if v1 == v2. // If v != v, then the resulting hash is randomly distributed. func Comparable[T comparable](seed Seed, v T) uint64 { … } func comparableReady[T comparable](v T) { … } // WriteComparable adds x to the data hashed by h. func WriteComparable[T comparable](h *Hash, x T) { … } // appendT hash a value, // when the value cannot be directly hash raw memory, // or when purego is used. func appendT(h *Hash, v reflect.Value) { … } func (h *Hash) float64(f float64) { … } func btoi(b bool) byte { … }