Documentation
¶
Overview ¶
Package hash provides hash functions for standard Go types. It leverages the built-in "hash" package, with FNV-1 (Fowler–Noll–Vo) as the default hashing algorithm.
The functions in this package are designed for high performance, following a similar approach to the built-in "encoding/binary" package, but avoiding type assertions or reflection to minimize overhead.
Index ¶
- type HashFunc
- func HashFuncForBool[T ~bool](h hash.Hash64) HashFunc[T]
- func HashFuncForBoolSlice[T ~[]bool](h hash.Hash64) HashFunc[T]
- func HashFuncForComplex128[T ~complex128](h hash.Hash64) HashFunc[T]
- func HashFuncForComplex128Slice[T ~[]complex128](h hash.Hash64) HashFunc[T]
- func HashFuncForComplex64[T ~complex64](h hash.Hash64) HashFunc[T]
- func HashFuncForComplex64Slice[T ~[]complex64](h hash.Hash64) HashFunc[T]
- func HashFuncForFloat32[T ~float32](h hash.Hash64) HashFunc[T]
- func HashFuncForFloat32Slice[T ~[]float32](h hash.Hash64) HashFunc[T]
- func HashFuncForFloat64[T ~float64](h hash.Hash64) HashFunc[T]
- func HashFuncForFloat64Slice[T ~[]float64](h hash.Hash64) HashFunc[T]
- func HashFuncForInt[T ~int](h hash.Hash64) HashFunc[T]
- func HashFuncForInt16[T ~int16](h hash.Hash64) HashFunc[T]
- func HashFuncForInt16Slice[T ~[]int16](h hash.Hash64) HashFunc[T]
- func HashFuncForInt32[T ~int32](h hash.Hash64) HashFunc[T]
- func HashFuncForInt32Slice[T ~[]int32](h hash.Hash64) HashFunc[T]
- func HashFuncForInt64[T ~int64](h hash.Hash64) HashFunc[T]
- func HashFuncForInt64Slice[T ~[]int64](h hash.Hash64) HashFunc[T]
- func HashFuncForInt8[T ~int8](h hash.Hash64) HashFunc[T]
- func HashFuncForInt8Slice[T ~[]int8](h hash.Hash64) HashFunc[T]
- func HashFuncForIntSlice[T ~[]int](h hash.Hash64) HashFunc[T]
- func HashFuncForString[T ~string](h hash.Hash64) HashFunc[T]
- func HashFuncForStringSlice[T ~[]string](h hash.Hash64) HashFunc[T]
- func HashFuncForUint[T ~uint](h hash.Hash64) HashFunc[T]
- func HashFuncForUint16[T ~uint16](h hash.Hash64) HashFunc[T]
- func HashFuncForUint16Slice[T ~[]uint16](h hash.Hash64) HashFunc[T]
- func HashFuncForUint32[T ~uint32](h hash.Hash64) HashFunc[T]
- func HashFuncForUint32Slice[T ~[]uint32](h hash.Hash64) HashFunc[T]
- func HashFuncForUint64[T ~uint64](h hash.Hash64) HashFunc[T]
- func HashFuncForUint64Slice[T ~[]uint64](h hash.Hash64) HashFunc[T]
- func HashFuncForUint8[T ~uint8](h hash.Hash64) HashFunc[T]
- func HashFuncForUint8Slice[T ~[]uint8](h hash.Hash64) HashFunc[T]
- func HashFuncForUintSlice[T ~[]uint](h hash.Hash64) HashFunc[T]
- func HashFuncForUintptr[T ~uintptr](h hash.Hash64) HashFunc[T]
- func HashFuncForUintptrSlice[T ~[]uintptr](h hash.Hash64) HashFunc[T]
- type Hasher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashFunc ¶
HashFunc defines a generic function type for hashing a key of type K.
func HashFuncForBool ¶
HashFuncForBool creates a HashFunc for boolean-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForBoolSlice ¶
HashFuncForBoolSlice creates a HashFunc for slice types with boolean elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForComplex128 ¶
func HashFuncForComplex128[T ~complex128](h hash.Hash64) HashFunc[T]
HashFuncForComplex128 creates a HashFunc for complex128-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForComplex128Slice ¶
func HashFuncForComplex128Slice[T ~[]complex128](h hash.Hash64) HashFunc[T]
HashFuncForComplex128Slice creates a HashFunc for slice types with complex128 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForComplex64 ¶
HashFuncForComplex64 creates a HashFunc for complex64-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForComplex64Slice ¶
HashFuncForComplex64Slice creates a HashFunc for slice types with complex64 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForFloat32 ¶
HashFuncForFloat32 creates a HashFunc for float32-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForFloat32Slice ¶
HashFuncForFloat32Slice creates a HashFunc for slice types with float32 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForFloat64 ¶
HashFuncForFloat64 creates a HashFunc for float64-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForFloat64Slice ¶
HashFuncForFloat64Slice creates a HashFunc for slice types with float64 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt ¶
HashFuncForInt creates a HashFunc for int-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt16 ¶
HashFuncForInt16 creates a HashFunc for int16-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt16Slice ¶
HashFuncForInt16Slice creates a HashFunc for slice types with int16 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt32 ¶
HashFuncForInt32 creates a HashFunc for int32-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt32Slice ¶
HashFuncForInt32Slice creates a HashFunc for slice types with int32 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt64 ¶
HashFuncForInt64 creates a HashFunc for int64-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt64Slice ¶
HashFuncForInt64Slice creates a HashFunc for slice types with int64 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt8 ¶
HashFuncForBool creates a HashFunc for int8-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForInt8Slice ¶
HashFuncForInt8Slice creates a HashFunc for slice types with int8 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForIntSlice ¶
HashFuncForIntSlice creates a HashFunc for slice types with int elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForString ¶
HashFuncForString creates a HashFunc for string-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForStringSlice ¶
HashFuncForStringSlice creates a HashFunc for slice types with string elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint ¶
HashFuncForUint creates a HashFunc for uint-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint16 ¶
HashFuncForUint16 creates a HashFunc for uint16-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint16Slice ¶
HashFuncForUint16Slice creates a HashFunc for slice types with uint16 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint32 ¶
HashFuncForUint32 creates a HashFunc for uint32-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint32Slice ¶
HashFuncForUint32Slice creates a HashFunc for slice types with uint32 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint64 ¶
HashFuncForUint64 creates a HashFunc for uint64-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint64Slice ¶
HashFuncForUint64Slice creates a HashFunc for slice types with uint64 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint8 ¶
HashFuncForUint8 creates a HashFunc for uint8-like types. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUint8Slice ¶
HashFuncForUint8Slice creates a HashFunc for slice types with uint8 elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUintSlice ¶
HashFuncForUintSlice creates a HashFunc for slice types with uint elements. If h is nil, a default hash.Hash64 implementation will be used.
func HashFuncForUintptr ¶
HashFuncForUintptr creates a HashFunc for uintptr-like types. If h is nil, a default hash.Hash64 implementation will be used.