pot

package
v0.0.0-...-f8b7a73 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

包装罐见Go医生

包装罐见Go医生

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPof

func DefaultPof(max int) func(one, other Val, pos int) (int, bool)

defaultpof返回一个接近顺序比较运算符函数

func Label

func Label(v Val) string

标签以二进制格式显示节点的密钥

func NewAddressFromString

func NewAddressFromString(s string) []byte

newAddressFromString从二进制表示的字符串创建字节片

func ProxCmp

func ProxCmp(a, x, y interface{}) int

procmp比较距离a->target和b->target。 如果a接近目标返回-1,如果b接近目标返回1 如果相等,则为0。

func ToBin

func ToBin(a []byte) string

Tobin将字节片转换为字符串二进制表示形式

func ToBytes

func ToBytes(v Val) []byte

tobytes将val转换为字节

Types

type Address

type Address common.Hash

地址是common.hash的别名

func NewAddressFromBytes

func NewAddressFromBytes(b []byte) Address

newAddressFromBytes从字节片构造地址

func RandomAddress

func RandomAddress() Address

random address生成随机地址

func RandomAddressAt

func RandomAddressAt(self Address, prox int) (addr Address)

randomaddressat(地址,代理)生成随机地址 在接近顺序,相对于地址的代理 如果prox为负,则生成随机地址。

func (Address) Bin

func (a Address) Bin() string

bin返回地址的二进制表示的字符串形式(仅前8位)

func (Address) Bytes

func (a Address) Bytes() []byte

字节以字节片的形式返回地址

func (*Address) MarshalJSON

func (a *Address) MarshalJSON() (out []byte, err error)

marshaljson地址序列化

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(value []byte) error

取消标记JSON地址反序列化

type BytesAddress

type BytesAddress interface {
	Address() []byte
}

BytesAddress是一个接口,用于按字节片寻址的元素

type Pof

type Pof func(Val, Val, int) (int, bool)

pof是邻近订单比较运算符函数

type Pot

type Pot struct {
	// contains filtered or unexported fields
}

pot是节点类型(根、分支节点和叶相同)

func Add

func Add(t *Pot, val Val, pof Pof) (*Pot, int, bool)

添加将新值插入到容器中,然后 返回v和布尔值的接近顺序 指示是否找到该项 add called on(t,v)返回包含t的所有元素的新pot 加上V值,使用应用加法 第二个返回值是插入元素的接近顺序。 第三个是布尔值,指示是否找到该项

func NewPot

func NewPot(v Val, po int) *Pot

Newpot构造函数。需要VAL类型的值才能固定 和po指向val键中的跨度 钉住的项目按大小计算

func Remove

func Remove(t *Pot, v Val, pof Pof) (*Pot, int, bool)

remove从pot t t中删除元素v并返回三个参数: 1。新锅,包含所有元素t减去元素v; 2。拆除元件V的接近顺序; 三。指示是否找到该项的布尔值。

func Swap

func Swap(t *Pot, k Val, pof Pof, f func(v Val) Val) (r *Pot, po int, found bool, change bool)

调用的swap(k,f)在k处查找项

如果f(v)返回nil,则删除元素 如果f(v)返回v'<>v,则v'插入锅中。 如果(v)==v,则罐不更换。 如果pof(f(v),k)显示v'和v不是键相等,则会恐慌。

func Union

func Union(t0, t1 *Pot, pof Pof) (*Pot, int)

在(t0,t1,pof)上调用的union返回t0和t1的union 使用应用联合计算联合 第二个返回值是公共元素的数目

func (*Pot) Each

func (t *Pot) Each(f func(Val) bool) bool

每个函数都是pot元素上的同步迭代器,函数为f。

func (*Pot) EachBin

func (t *Pot) EachBin(val Val, pof Pof, po int, f func(int, int, func(func(val Val) bool) bool) bool)

eachbin在pivot节点的bin上迭代,并在每个pivot节点上向调用者提供迭代器。 传递接近顺序和大小的子树 迭代将继续,直到函数的返回值为假 或者没有其他子项

func (*Pot) EachNeighbour

func (t *Pot) EachNeighbour(val Val, pof Pof, f func(Val, int) bool) bool

eachneighbur是任何目标val的邻居上的同步迭代器。 元素的检索顺序反映了目标的接近顺序。 TODO:将最大proxybin添加到迭代的开始范围

func (*Pot) EachNeighbourAsync

func (t *Pot) EachNeighbourAsync(val Val, pof Pof, max int, maxPos int, f func(Val, int), wait bool)

调用的eachneighbourasync(val、max、maxpos、f、wait)是异步迭代器 在不小于maxpos wrt val的元素上。 val不需要与pot元素匹配,但如果匹配,并且 maxpos是keylength,而不是包含在迭代中的keylength 对f的调用是并行的,调用顺序未定义。 在锅中没有元素 如果访问了更近的节点,则不会访问。 当访问最大最近节点数时,迭代完成。 或者,如果整个系统中没有不比未访问的maxpos更近的节点 如果wait为true,则仅当对f的所有调用都完成时,迭代器才返回 TODO:为正确的代理范围迭代实现minpos

func (*Pot) Pin

func (t *Pot) Pin() Val

pin返回pot的pinned元素(键)

func (*Pot) Size

func (t *Pot) Size() int

SIZE返回pot中的值数

func (*Pot) String

func (t *Pot) String() string

type Val

type Val interface{}

VAL是锅的元件类型

Jump to

Keyboard shortcuts

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