base

package
v1.1.0-beta.0...-97e7b5c Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NilFlag    byte = 0
	NotNilFlag byte = 1
)

NilFlag and NotNilFlag are used to indicate whether a pointer/interface type field inside struct is nil or not. like a structure:

type MyStruct struct {
	 a *OtherStruct
}

Once a is nil, we should hash the NilFlag, otherwise, we should hash the NotNilFlag nil : [0] not nil : [1] [xxx] the NotNilFlag should not be missed, otherwise, once [xxx] is []byte{0}, it will be treated as nil.

Variables

This section is empty.

Functions

This section is empty.

Types

type Equals

type Equals interface {
	// Equals checks whether two base objects are equal.
	Equals(any) bool
}

Equals is the interface for equality check. When we need to compare two objects when countering hash conflicts, we can use this interface to check whether they are equal.

type Hash64

type Hash64 interface {
	// Hash64 returns the uint64 digest of an object.
	Hash64(h Hasher)
}

Hash64 is the interface for hashcode. It is used to calculate the lossy digest of an object to return uint64 rather than compacted bytes from cascaded operators bottom-up.

type Hash64a

type Hash64a uint64

Hash64a is the type for the hash value.

type HashEquals

type HashEquals interface {
	Hash64
	Equals
}

HashEquals is the interface for hash64 and equality check.

type Hasher

type Hasher interface {
	HashBool(val bool)
	HashInt(val int)
	HashInt64(val int64)
	HashUint64(val uint64)
	HashFloat64(val float64)
	HashRune(val rune)
	HashString(val string)
	HashByte(val byte)
	HashBytes(val []byte)
	Reset()
	SetCache([]byte)
	Cache() []byte
	Sum64() uint64
}

Hasher is the interface for computing hash values of different types.

func NewHashEqualer

func NewHashEqualer() Hasher

NewHashEqualer creates a new HashEqualer.

Jump to

Keyboard shortcuts

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