tree

package
v0.7.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCyclicDependencyEncountered = errors.New("a cycle dependency encountered in the tree")

ErrCyclicDependencyEncountered is triggered a tree has a cyclic dependency

Functions

This section is empty.

Types

type MultiRootTree

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

MultiRootTree - represents a data type which has multiple independent root nodes all root nodes have their independent tree based on depdencies of TreeNode. it also maintains a map of nodes for faster lookups and managing node data.

func NewMultiRootTree

func NewMultiRootTree() *MultiRootTree

NewMultiRootTree returns an instance of multi root dag tree

func (*MultiRootTree) AddNode

func (t *MultiRootTree) AddNode(node *TreeNode)

func (*MultiRootTree) AddNodeIfNotExist

func (t *MultiRootTree) AddNodeIfNotExist(node *TreeNode)

func (*MultiRootTree) GetNodeByName

func (t *MultiRootTree) GetNodeByName(dagName string) (*TreeNode, bool)

func (*MultiRootTree) GetRootNodes

func (t *MultiRootTree) GetRootNodes() []*TreeNode

func (*MultiRootTree) MarkRoot

func (t *MultiRootTree) MarkRoot(node *TreeNode)

MarkRoot marks a node as root

func (*MultiRootTree) ValidateCyclic

func (t *MultiRootTree) ValidateCyclic() ([]string, error)

ValidateCyclic - detects if there are any cycles in the tree

type TreeData

type TreeData interface {
	GetName() string
}

type TreeNode

type TreeNode struct {
	Data       TreeData
	Dependents []*TreeNode
	Runs       set.Set
}

TreeNode represents a custom data type that contains data along with it's dependent TreeNodes

func NewTreeNode

func NewTreeNode(data TreeData) *TreeNode

NewTreeNode creates an instance of TreeNode

func (*TreeNode) AddDependent

func (t *TreeNode) AddDependent(depNode *TreeNode) *TreeNode

func (*TreeNode) GetAllNodes

func (t *TreeNode) GetAllNodes() []*TreeNode

GetAllNodes returns level order traversal of tree starting from current node

func (*TreeNode) GetName

func (t *TreeNode) GetName() string

Jump to

Keyboard shortcuts

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