Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindByMaxScore ¶
FindByMaxScore finds a node which has maximum score and returns its index. If nodes has no node, it returns -1.
func FindBySeed ¶
FindBySeed finds a node by seed and returns its index. If seed is not exists, it returns -1.
func ResponsibleNodes ¶
ResponsibleNodes calculates all scores from nodes and puts responsible nodes into respNodes.
Types ¶
type Node ¶
type Node struct { Seed uint32 Weight float64 Data interface{} // contains filtered or unexported fields }
Node is a container of Seed, Weight, Data to find responsible nodes. Data is a custom data to use free.
type Nodes ¶
type Nodes []Node
Nodes is a Node slice and it implements sort.Interface to use sort package.
func MergeNodes ¶
MergeNodes merges nodes1 and nodes2, appends mergedNodesIn, returns mergedNodes which has all merged nodes. mergedNodesIn can be nil.
func ResponsibleNodes2 ¶
ResponsibleNodes2 calculates all scores from nodes and returns responsible nodes.