dag

package
v0.0.0-...-f292767 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package dag represents abstract directed acyclic graph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GatherMatchingInputNames

func GatherMatchingInputNames(node Node, condition NodeCondition) []string

GatherMatchingInputNames scans all the inputs and returns those which match the condition.

func Walk

func Walk(graph Graph, walkFn WalkFunc, visited map[Node]struct{}, depth int) error

Walk the graph calling function for every node just once.

func WalkNode

func WalkNode(node Node, walkFn WalkFunc, visited map[Node]struct{}, depth int) error

WalkNode walks the graph starting from the node just once.

Types

type BaseGraph

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

BaseGraph implements core functionality of DAG.

BaseGraph is designed to be embedded into other types.

func (*BaseGraph) AddTarget

func (graph *BaseGraph) AddTarget(target ...Node)

AddTarget adds new targets to the graph.

func (*BaseGraph) Targets

func (graph *BaseGraph) Targets() []Node

Targets returns list of targets for the graph.

type BaseNode

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

BaseNode implements core functionality of the node.

BaseNode is designed to be included into other types.

func NewBaseNode

func NewBaseNode(name string) BaseNode

NewBaseNode creates new embeddable BaseNode.

func (*BaseNode) AddInput

func (node *BaseNode) AddInput(input ...Node)

AddInput implements Node interface.

func (*BaseNode) Inputs

func (node *BaseNode) Inputs() []Node

Inputs implements Node interface.

func (*BaseNode) Name

func (node *BaseNode) Name() string

Name implements Node interface.

type Graph

type Graph interface {
	Targets() []Node
}

Graph represents the targets of the build process.

type Node

type Node interface {
	Name() string
	Inputs() []Node
	AddInput(...Node)
}

Node in directed acyclic graph, recording parent nodes as inputs.

func FindByName

func FindByName(name string, targets ...Node) (result Node)

FindByName walks the nodes to find the node with matching name.

func GatherMatchingInputs

func GatherMatchingInputs(node Node, condition NodeCondition) []Node

GatherMatchingInputs scans all the inputs and returns those which match the condition.

func GatherMatchingInputsRecursive

func GatherMatchingInputsRecursive(node Node, condition NodeCondition) []Node

GatherMatchingInputsRecursive scans all the inputs recursively and returns those which match the condition.

type NodeCondition

type NodeCondition func(Node) bool

NodeCondition checks the node for a specific condition.

func Implements

func Implements[T any]() NodeCondition

Implements checks whether node implements specific type T.

func Not

func Not(condition NodeCondition) NodeCondition

Not inverts the check.

type WalkFunc

type WalkFunc func(node Node) error

WalkFunc is a callback function called by Walk.

Jump to

Keyboard shortcuts

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