collection

package
v0.0.0-...-261d6aa Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 2 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeDistance

type NodeDistance struct {
	ID contract.NodeID
	D  float64
}

NodeDistance contains distance to a node.

func NewNodeDistance

func NewNodeDistance(nID contract.NodeID, d float64) NodeDistance

NewNodeDistance crates a new NodeDistance instance.

type NodeDistanceHeap

type NodeDistanceHeap []NodeDistance

NodeDistanceHeap is a heap of node distances. It is used in the PQ implementation.

func (NodeDistanceHeap) Len

func (heap NodeDistanceHeap) Len() int

Len returns length of the heap.

func (NodeDistanceHeap) Less

func (heap NodeDistanceHeap) Less(i, j int) bool

Less compares elements.

func (*NodeDistanceHeap) Pop

func (heap *NodeDistanceHeap) Pop() interface{}

Pop removes an element from the tail of the heap. Used by heap.Pop().

func (*NodeDistanceHeap) Push

func (heap *NodeDistanceHeap) Push(v interface{})

Push adds an element to the heap. Used by heap.Push().

func (NodeDistanceHeap) Swap

func (heap NodeDistanceHeap) Swap(i, j int)

Swap swaps elements.

type NodeStack

type NodeStack []contract.Node

NodeStack is a slice of nodes.

func (*NodeStack) Append

func (stack *NodeStack) Append(nodes []contract.Node)

Append appends a list of nodes to the end of the stack.

func (*NodeStack) Pop

func (stack *NodeStack) Pop() contract.Node

Pop removes the first node from the stack and returns it.

func (*NodeStack) PopFront

func (stack *NodeStack) PopFront() contract.Node

PopFront removes the first node from the stack and returns it.

func (*NodeStack) Push

func (stack *NodeStack) Push(node contract.Node)

Push adds a node to the end of the stack.

type NodeVisitMap

type NodeVisitMap map[contract.NodeID]int64

NodeVisitMap is a map of visited nodes. Used in iterators.

func (*NodeVisitMap) Visit

func (m *NodeVisitMap) Visit(nID contract.NodeID)

Visit marks nID as visited and increments the visit counter.

func (*NodeVisitMap) Visited

func (m *NodeVisitMap) Visited(nID contract.NodeID) bool

Visited returns true if nID has been visited before.

func (*NodeVisitMap) Visits

func (m *NodeVisitMap) Visits(nID contract.NodeID) int64

Visits tells exactly how many time nID has been visited.

type Nodes

type Nodes struct {
	Map map[contract.NodeID]contract.Node
}

Nodes is a set of INode instances.

func NewNodes

func NewNodes(nodes ...contract.Node) *Nodes

NewNodes creates a new node set instance.

func (*Nodes) Add

func (set *Nodes) Add(n contract.Node) bool

Add adds a node to the set and returns true if it had been inserted for the first time.

func (Nodes) Clone

func (set Nodes) Clone() contract.Nodes

Clone creates a new set by copying the receiver set.

func (Nodes) Count

func (set Nodes) Count() uint

Count tells how many nodes are currently in the set.

func (*Nodes) Get

func (set *Nodes) Get(nID contract.NodeID) contract.Node

Get returns a node from the set.

func (*Nodes) Has

func (set *Nodes) Has(nID contract.NodeID) bool

Has tells whether a node is present in the set.

func (Nodes) Range

func (set Nodes) Range() contract.NChannel

Range iterates over elements in lexicographic key order.

func (*Nodes) Remove

func (set *Nodes) Remove(nID contract.NodeID) bool

Remove removes a node from the set. Returns true if node was present in the set before removal.

func (Nodes) Values

func (set Nodes) Values() []contract.Node

Values creates a slice of values taken from the set.

Jump to

Keyboard shortcuts

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