key

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DistInt

func DistInt(x, y Key) *big.Int

DistInt 计算两个Key之间的距离 参数:

  • x: Key 第一个Key
  • y: Key 第二个Key

返回值:

  • *big.Int 距离值

func Equal

func Equal(x, y Key) bool

Equal 比较两个Key是否相等 参数:

  • x: Key 第一个Key
  • y: Key 第二个Key

返回值:

  • bool 是否相等

Types

type Key

type Key []byte

Key 是由Go字节切片支持的位向量 第一个字节最重要 每个字节中的第一位最不重要

func ByteKey

func ByteKey(b byte) Key

ByteKey 将单个字节转换为Key 参数:

  • b: byte 输入字节

返回值:

  • Key 转换后的Key

func BytesKey

func BytesKey(b []byte) Key

BytesKey 将字节切片转换为Key 参数:

  • b: []byte 输入字节切片

返回值:

  • Key 转换后的Key

func KbucketIDToKey

func KbucketIDToKey(id kbucket.ID) Key

KbucketIDToKey 将kbucket.ID转换为Key 参数:

  • id: kbucket.ID kbucket的ID

返回值:

  • Key 转换后的Key

func Xor

func Xor(x, y Key) Key

Xor 计算两个Key的异或值 参数:

  • x: Key 第一个Key
  • y: Key 第二个Key

返回值:

  • Key 异或结果

func (Key) BitAt

func (k Key) BitAt(offset int) byte

BitAt 获取指定偏移位置的位值 参数:

  • offset: int 位偏移量

返回值:

  • byte 位值(0或1)

func (Key) BitLen

func (k Key) BitLen() int

BitLen 获取Key的位长度 返回值:

  • int 位长度

func (Key) BitString

func (k Key) BitString() string

BitString 返回Key的位表示,按重要性降序排列 返回值:

  • string Key的位字符串表示

func (Key) NormInt

func (k Key) NormInt() *big.Int

NormInt 将Key转换为大整数 返回值:

  • *big.Int 转换后的大整数

func (Key) String

func (k Key) String() string

String 将Key转换为字符串表示 返回值:

  • string Key的字符串表示

Jump to

Keyboard shortcuts

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