hashing

package
v0.0.0-...-32c7374 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash[K any](key K) uint32

Hash returns a hash of a key, panics if the key type is not supported. Add more types as needed.

func HashBool

func HashBool(b bool) uint32

HashBool returns a hash of a bool value.

func HashBytes

func HashBytes(b []byte) uint32

HashBytes returns a hash of a byte slice value.

func HashPointer

func HashPointer(v any) uint32

HashPointer returns a hash of a pointer value. The method is unsafe and must be used only with actual pointers.

func HashString

func HashString(s string) uint32

HashString returns a hash of a string value.

func Shard

func Shard[K any](key K, shards int) int

Shard returns a shard index for a key, panics if the key type is not supported. Add more types as needed.

Types

type Hasher

type Hasher interface {
	// Hash32 returns a 32-bit hash of the object.
	Hash32() uint32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL