package city
import "github.com/go-faster/city"
Package city implements CityHash in go.
Index ¶
- func Hash32(s []byte) uint32
- func Hash64(s []byte) uint64
- func Hash64WithSeed(s []byte, seed uint64) uint64
- func Hash64WithSeeds(s []byte, seed0, seed1 uint64) uint64
- type U128
Examples ¶
Functions ¶
func Hash32 ¶
Hash32 return 32-bit hash.
Code:
Output:Example¶
{
s := []byte("hello")
hash32 := Hash32(s)
fmt.Printf("the 32-bit hash of 'hello' is: 0x%x\n", hash32)
// Output:
// the 32-bit hash of 'hello' is: 0x79969366
}
the 32-bit hash of 'hello' is: 0x79969366
func Hash64 ¶
Hash64 return a 64-bit hash.
Code:
Output:Example¶
{
s := []byte("hello")
hash64 := Hash64(s)
fmt.Printf("the 64-bit hash of 'hello' is: 0x%x\n", hash64)
// Output:
// the 64-bit hash of 'hello' is: 0xb48be5a931380ce8
}
the 64-bit hash of 'hello' is: 0xb48be5a931380ce8
func Hash64WithSeed ¶
Hash64WithSeed return a 64-bit hash with a seed.
func Hash64WithSeeds ¶
Hash64WithSeeds return a 64-bit hash with two seeds.
Types ¶
type U128 ¶
type U128 struct { Low, High uint64 // much faster than uint64[2] }
U128 is uint128.
func Hash128 ¶
Hash128 returns a 128-bit hash and are tuned for strings of at least
a few hundred bytes. Depending on your compiler and hardware,
it's likely faster than Hash64() on sufficiently long strings.
It's slower than necessary on shorter strings, but we expect
that case to be relatively unimportant.
Code:
Output:Example¶
{
s := []byte("hello")
hash128 := Hash128(s)
fmt.Printf("the 128-bit hash of 'hello' is: 0x%x%x\n", hash128.High, hash128.Low)
// Output:
// the 128-bit hash of 'hello' is: 0x65148f580b45f3476f72e4abb491a74a
}
the 128-bit hash of 'hello' is: 0x65148f580b45f3476f72e4abb491a74a
func Hash128Seed ¶
Hash128Seed return a 128-bit hash with a seed.
Source Files ¶
128.go 32.go 64.go doc.go u128.go
- Version
- v0.0.2
- Published
- Nov 17, 2021
- Platform
- js/wasm
- Imports
- 1 packages
- Last checked
- now –
Tools for package owners.