iterator

package
v0.8.13 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package iterator provides node, edge and line iterators.

The iterators provided satisfy the graph.Nodes, graph.Edges and graph.Lines interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImplicitNodes

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

ImplicitNodes implements the graph.Nodes interface for a set of nodes over a contiguous ID range.

func NewImplicitNodes

func NewImplicitNodes(beg, end int, new func(id int) graph.Node) *ImplicitNodes

NewImplicitNodes returns a new implicit node iterator spanning nodes in [beg,end). The provided new func maps the id to a graph.Node. NewImplicitNodes will panic if beg is greater than end.

func (*ImplicitNodes) Len

func (n *ImplicitNodes) Len() int

Len returns the remaining number of nodes to be iterated over.

func (*ImplicitNodes) Next

func (n *ImplicitNodes) Next() bool

Next returns whether the next call of Node will return a valid node.

func (*ImplicitNodes) Node

func (n *ImplicitNodes) Node() graph.Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*ImplicitNodes) NodeSlice

func (n *ImplicitNodes) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator.

func (*ImplicitNodes) Reset

func (n *ImplicitNodes) Reset()

Reset returns the iterator to its initial state.

type LazyOrderedNodes

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

LazyOrderedNodes implements the graph.Nodes and graph.NodeSlicer interfaces. The iteration order of LazyOrderedNodes is not determined until the first call to Next or NodeSlice. After that, the iteration order is fixed.

func NewLazyOrderedNodes

func NewLazyOrderedNodes(nodes map[int64]graph.Node) *LazyOrderedNodes

NewLazyOrderedNodes returns a LazyOrderedNodes initialized with the provided nodes.

func (*LazyOrderedNodes) Len

func (n *LazyOrderedNodes) Len() int

Len returns the remaining number of nodes to be iterated over.

func (*LazyOrderedNodes) Next

func (n *LazyOrderedNodes) Next() bool

Next returns whether the next call of Node will return a valid node.

func (*LazyOrderedNodes) Node

func (n *LazyOrderedNodes) Node() graph.Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*LazyOrderedNodes) NodeSlice

func (n *LazyOrderedNodes) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator.

func (*LazyOrderedNodes) Reset

func (n *LazyOrderedNodes) Reset()

Reset returns the iterator to its initial state.

type LazyOrderedNodesByEdge

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

LazyOrderedNodesByEdge implements the graph.Nodes and graph.NodeSlicer interfaces. The iteration order of LazyOrderedNodesByEdge is not determined until the first call to Next or NodeSlice. After that, the iteration order is fixed.

func NewLazyOrderedNodesByEdge

func NewLazyOrderedNodesByEdge(nodes map[int64]graph.Node, edges map[int64]graph.Edge) *LazyOrderedNodesByEdge

NewLazyOrderedNodesByEdge returns a LazyOrderedNodesByEdge initialized with the provided nodes.

func (*LazyOrderedNodesByEdge) Len

func (n *LazyOrderedNodesByEdge) Len() int

Len returns the remaining number of nodes to be iterated over.

func (*LazyOrderedNodesByEdge) Next

func (n *LazyOrderedNodesByEdge) Next() bool

Next returns whether the next call of Node will return a valid node.

func (*LazyOrderedNodesByEdge) Node

func (n *LazyOrderedNodesByEdge) Node() graph.Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*LazyOrderedNodesByEdge) NodeSlice

func (n *LazyOrderedNodesByEdge) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator.

func (*LazyOrderedNodesByEdge) Reset

func (n *LazyOrderedNodesByEdge) Reset()

Reset returns the iterator to its initial state.

type LazyOrderedNodesByLines

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

LazyOrderedNodesByLines implements the graph.Nodes and graph.NodeSlicer interfaces. The iteration order of LazyOrderedNodesByLines is not determined until the first call to Next or NodeSlice. After that, the iteration order is fixed.

func NewLazyOrderedNodesByLines

func NewLazyOrderedNodesByLines(nodes map[int64]graph.Node, edges map[int64]map[int64]graph.Line) *LazyOrderedNodesByLines

NewLazyOrderedNodesByLine returns a LazyOrderedNodesByLines initialized with the provided nodes.

func (*LazyOrderedNodesByLines) Len

func (n *LazyOrderedNodesByLines) Len() int

Len returns the remaining number of nodes to be iterated over.

func (*LazyOrderedNodesByLines) Next

func (n *LazyOrderedNodesByLines) Next() bool

Next returns whether the next call of Node will return a valid node.

func (*LazyOrderedNodesByLines) Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*LazyOrderedNodesByLines) NodeSlice

func (n *LazyOrderedNodesByLines) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator.

func (*LazyOrderedNodesByLines) Reset

func (n *LazyOrderedNodesByLines) Reset()

Reset returns the iterator to its initial state.

type LazyOrderedNodesByWeightedEdge

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

LazyOrderedNodesByWeightedEdge implements the graph.Nodes and graph.NodeSlicer interfaces. The iteration order of LazyOrderedNodesByEeightedEdge is not determined until the first call to Next or NodeSlice. After that, the iteration order is fixed.

func NewLazyOrderedNodesByWeightedEdge

func NewLazyOrderedNodesByWeightedEdge(nodes map[int64]graph.Node, edges map[int64]graph.WeightedEdge) *LazyOrderedNodesByWeightedEdge

NewLazyOrderedNodesByWeightedEdge returns a LazyOrderedNodesByEdge initialized with the provided nodes.

func (*LazyOrderedNodesByWeightedEdge) Len

Len returns the remaining number of nodes to be iterated over.

func (*LazyOrderedNodesByWeightedEdge) Next

Next returns whether the next call of Node will return a valid node.

func (*LazyOrderedNodesByWeightedEdge) Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*LazyOrderedNodesByWeightedEdge) NodeSlice

func (n *LazyOrderedNodesByWeightedEdge) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator.

func (*LazyOrderedNodesByWeightedEdge) Reset

func (n *LazyOrderedNodesByWeightedEdge) Reset()

Reset returns the iterator to its initial state.

type LazyOrderedNodesByWeightedLines

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

LazyOrderedNodesByWeightedLines implements the graph.Nodes and graph.NodeSlicer interfaces. The iteration order of LazyOrderedNodesByEeightedLine is not determined until the first call to Next or NodeSlice. After that, the iteration order is fixed.

func NewLazyOrderedNodesByWeightedLines

func NewLazyOrderedNodesByWeightedLines(nodes map[int64]graph.Node, edges map[int64]map[int64]graph.WeightedLine) *LazyOrderedNodesByWeightedLines

NewLazyOrderedNodesByWeightedLines returns a LazyOrderedNodesByLines initialized with the provided nodes.

func (*LazyOrderedNodesByWeightedLines) Len

Len returns the remaining number of nodes to be iterated over.

func (*LazyOrderedNodesByWeightedLines) Next

Next returns whether the next call of Node will return a valid node.

func (*LazyOrderedNodesByWeightedLines) Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*LazyOrderedNodesByWeightedLines) NodeSlice

func (n *LazyOrderedNodesByWeightedLines) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator.

func (*LazyOrderedNodesByWeightedLines) Reset

Reset returns the iterator to its initial state.

type Nodes

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

Nodes implements the graph.Nodes interfaces. The iteration order of Nodes is randomized.

func NewNodes

func NewNodes(nodes map[int64]graph.Node) *Nodes

NewNodes returns a Nodes initialized with the provided nodes, a map of node IDs to graph.Nodes. No check is made that the keys match the graph.Node IDs, and the map keys are not used.

Behavior of the Nodes is unspecified if nodes is mutated after the call the NewNodes.

func (*Nodes) Len

func (n *Nodes) Len() int

Len returns the remaining number of nodes to be iterated over.

func (*Nodes) Next

func (n *Nodes) Next() bool

Next returns whether the next call of Node will return a valid node.

func (*Nodes) Node

func (n *Nodes) Node() graph.Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*Nodes) NodeSlice

func (n *Nodes) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator. The order of nodes within the returned slice is not specified.

func (*Nodes) Reset

func (n *Nodes) Reset()

Reset returns the iterator to its initial state.

type NodesByEdge

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

NodesByEdge implements the graph.Nodes interfaces. The iteration order of Nodes is randomized.

func NewNodesByEdge

func NewNodesByEdge(nodes map[int64]graph.Node, edges map[int64]graph.Edge) *NodesByEdge

NewNodesByEdge returns a NodesByEdge initialized with the provided nodes, a map of node IDs to graph.Nodes, and the set of edges, a map of to-node IDs to graph.Edge, that can be traversed to reach the nodes that the NodesByEdge will iterate over. No check is made that the keys match the graph.Node IDs, and the map keys are not used.

Behavior of the NodesByEdge is unspecified if nodes or edges is mutated after the call the NewNodes.

func NewNodesByLines

func NewNodesByLines(nodes map[int64]graph.Node, lines map[int64]map[int64]graph.Line) *NodesByEdge

NewNodesByLines returns a NodesByEdge initialized with the provided nodes, a map of node IDs to graph.Nodes, and the set of lines, a map to-node IDs to map of graph.Line, that can be traversed to reach the nodes that the NodesByEdge will iterate over. No check is made that the keys match the graph.Node IDs, and the map keys are not used.

Behavior of the NodesByEdge is unspecified if nodes or lines is mutated after the call the NewNodes.

func NewNodesByWeightedEdge

func NewNodesByWeightedEdge(nodes map[int64]graph.Node, edges map[int64]graph.WeightedEdge) *NodesByEdge

NewNodesByWeightedEdge returns a NodesByEdge initialized with the provided nodes, a map of node IDs to graph.Nodes, and the set of edges, a map of to-node IDs to graph.WeightedEdge, that can be traversed to reach the nodes that the NodesByEdge will iterate over. No check is made that the keys match the graph.Node IDs, and the map keys are not used.

Behavior of the NodesByEdge is unspecified if nodes or edges is mutated after the call the NewNodes.

func NewNodesByWeightedLines

func NewNodesByWeightedLines(nodes map[int64]graph.Node, lines map[int64]map[int64]graph.WeightedLine) *NodesByEdge

NewNodesByWeightedLines returns a NodesByEdge initialized with the provided nodes, a map of node IDs to graph.Nodes, and the set of lines, a map to-node IDs to map of graph.WeightedLine, that can be traversed to reach the nodes that the NodesByEdge will iterate over. No check is made that the keys match the graph.Node IDs, and the map keys are not used.

Behavior of the NodesByEdge is unspecified if nodes or lines is mutated after the call the NewNodes.

func (*NodesByEdge) Len

func (n *NodesByEdge) Len() int

Len returns the remaining number of nodes to be iterated over.

func (*NodesByEdge) Next

func (n *NodesByEdge) Next() bool

Next returns whether the next call of Node will return a valid node.

func (*NodesByEdge) Node

func (n *NodesByEdge) Node() graph.Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*NodesByEdge) NodeSlice

func (n *NodesByEdge) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator. The order of nodes within the returned slice is not specified.

func (*NodesByEdge) Reset

func (n *NodesByEdge) Reset()

Reset returns the iterator to its initial state.

type OrderedEdges

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

OrderedEdges implements the graph.Edges and graph.EdgeSlicer interfaces. The iteration order of OrderedEdges is the order of edges passed to NewEdgeIterator.

func NewOrderedEdges

func NewOrderedEdges(edges []graph.Edge) *OrderedEdges

NewOrderedEdges returns an OrderedEdges initialized with the provided edges.

func (*OrderedEdges) Edge

func (e *OrderedEdges) Edge() graph.Edge

Edge returns the current edge of the iterator. Next must have been called prior to a call to Edge.

func (*OrderedEdges) EdgeSlice

func (e *OrderedEdges) EdgeSlice() []graph.Edge

EdgeSlice returns all the remaining edges in the iterator and advances the iterator.

func (*OrderedEdges) Len

func (e *OrderedEdges) Len() int

Len returns the remaining number of edges to be iterated over.

func (*OrderedEdges) Next

func (e *OrderedEdges) Next() bool

Next returns whether the next call of Edge will return a valid edge.

func (*OrderedEdges) Reset

func (e *OrderedEdges) Reset()

Reset returns the iterator to its initial state.

type OrderedLines

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

OrderedLines implements the graph.Lines and graph.LineSlicer interfaces. The iteration order of OrderedLines is the order of lines passed to NewLineIterator.

func NewOrderedLines

func NewOrderedLines(lines []graph.Line) *OrderedLines

NewOrderedLines returns an OrderedLines initialized with the provided lines.

func (*OrderedLines) Len

func (e *OrderedLines) Len() int

Len returns the remaining number of lines to be iterated over.

func (*OrderedLines) Line

func (e *OrderedLines) Line() graph.Line

Line returns the current line of the iterator. Next must have been called prior to a call to Line.

func (*OrderedLines) LineSlice

func (e *OrderedLines) LineSlice() []graph.Line

LineSlice returns all the remaining lines in the iterator and advances the iterator.

func (*OrderedLines) Next

func (e *OrderedLines) Next() bool

Next returns whether the next call of Line will return a valid line.

func (*OrderedLines) Reset

func (e *OrderedLines) Reset()

Reset returns the iterator to its initial state.

type OrderedNodes

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

OrderedNodes implements the graph.Nodes and graph.NodeSlicer interfaces. The iteration order of OrderedNodes is the order of nodes passed to NewNodeIterator.

func NewOrderedNodes

func NewOrderedNodes(nodes []graph.Node) *OrderedNodes

NewOrderedNodes returns a OrderedNodes initialized with the provided nodes.

func (*OrderedNodes) Len

func (n *OrderedNodes) Len() int

Len returns the remaining number of nodes to be iterated over.

func (*OrderedNodes) Next

func (n *OrderedNodes) Next() bool

Next returns whether the next call of Node will return a valid node.

func (*OrderedNodes) Node

func (n *OrderedNodes) Node() graph.Node

Node returns the current node of the iterator. Next must have been called prior to a call to Node.

func (*OrderedNodes) NodeSlice

func (n *OrderedNodes) NodeSlice() []graph.Node

NodeSlice returns all the remaining nodes in the iterator and advances the iterator.

func (*OrderedNodes) Reset

func (n *OrderedNodes) Reset()

Reset returns the iterator to its initial state.

type OrderedWeightedEdges

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

OrderedWeightedEdges implements the graph.Edges and graph.EdgeSlicer interfaces. The iteration order of OrderedWeightedEdges is the order of edges passed to NewEdgeIterator.

func NewOrderedWeightedEdges

func NewOrderedWeightedEdges(edges []graph.WeightedEdge) *OrderedWeightedEdges

NewOrderedWeightedEdges returns an OrderedWeightedEdges initialized with the provided edges.

func (*OrderedWeightedEdges) Len

func (e *OrderedWeightedEdges) Len() int

Len returns the remaining number of edges to be iterated over.

func (*OrderedWeightedEdges) Next

func (e *OrderedWeightedEdges) Next() bool

Next returns whether the next call of WeightedEdge will return a valid edge.

func (*OrderedWeightedEdges) Reset

func (e *OrderedWeightedEdges) Reset()

Reset returns the iterator to its initial state.

func (*OrderedWeightedEdges) WeightedEdge

func (e *OrderedWeightedEdges) WeightedEdge() graph.WeightedEdge

WeightedEdge returns the current edge of the iterator. Next must have been called prior to a call to WeightedEdge.

func (*OrderedWeightedEdges) WeightedEdgeSlice

func (e *OrderedWeightedEdges) WeightedEdgeSlice() []graph.WeightedEdge

WeightedEdgeSlice returns all the remaining edges in the iterator and advances the iterator.

type OrderedWeightedLines

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

OrderedWeightedLines implements the graph.Lines and graph.LineSlicer interfaces. The iteration order of OrderedWeightedLines is the order of lines passed to NewLineIterator.

func NewOrderedWeightedLines

func NewOrderedWeightedLines(lines []graph.WeightedLine) *OrderedWeightedLines

NewWeightedLineIterator returns an OrderedWeightedLines initialized with the provided lines.

func (*OrderedWeightedLines) Len

func (e *OrderedWeightedLines) Len() int

Len returns the remaining number of lines to be iterated over.

func (*OrderedWeightedLines) Next

func (e *OrderedWeightedLines) Next() bool

Next returns whether the next call of WeightedLine will return a valid line.

func (*OrderedWeightedLines) Reset

func (e *OrderedWeightedLines) Reset()

Reset returns the iterator to its initial state.

func (*OrderedWeightedLines) WeightedLine

func (e *OrderedWeightedLines) WeightedLine() graph.WeightedLine

WeightedLine returns the current line of the iterator. Next must have been called prior to a call to WeightedLine.

func (*OrderedWeightedLines) WeightedLineSlice

func (e *OrderedWeightedLines) WeightedLineSlice() []graph.WeightedLine

WeightedLineSlice returns all the remaining lines in the iterator and advances the iterator.

Jump to

Keyboard shortcuts

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