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 Nodes ¶
type Nodes struct {
// contains filtered or unexported fields
}
Nodes implements the graph.Nodes interfaces. The iteration order of Nodes is randomized.
func NewNodes ¶
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.
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.