tree

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fmap

func Fmap(f func(*TreeNode), root *TreeNode)

Fmap applies a function f to every node under (and including) root even thought State contains Nodes and we can range over all the nodes, Fmap is useful for two reasons:

  • it applies the function to the nodes in a consistent and hierarchical order
  • it can be applied to a branch only, just supply it with a starting node that isn't the root

Types

type TreeNode

type TreeNode struct {
	XY             *coord.Coord
	Color          color.Color
	Down           []*TreeNode
	Up             *TreeNode
	Index          int
	PreferredChild int
	fields.Fields
	Diff      *coord.Diff
	Depth     int
	BlackCaps int
	WhiteCaps int
}

func NewTreeNode

func NewTreeNode(crd *coord.Coord, col color.Color, index int, up *TreeNode, flds fields.Fields) *TreeNode

func (*TreeNode) Copy

func (n *TreeNode) Copy() *TreeNode

func (*TreeNode) HasChild

func (n *TreeNode) HasChild(crd *coord.Coord, col color.Color) (int, bool)

func (*TreeNode) MaxDepth

func (n *TreeNode) MaxDepth() int

func (*TreeNode) RecomputeDepth

func (n *TreeNode) RecomputeDepth()

RecomputeDepth is used when grafting, to make sure the depth is set correctly for all lower nodes

func (*TreeNode) SetDiff

func (n *TreeNode) SetDiff(diff *coord.Diff)

func (*TreeNode) SetParent

func (n *TreeNode) SetParent(up *TreeNode)

SetParent exists to add the depth attribute

func (*TreeNode) ShallowEqual

func (n *TreeNode) ShallowEqual(m *TreeNode) bool

func (*TreeNode) TrunkNum

func (n *TreeNode) TrunkNum(i int) int

Jump to

Keyboard shortcuts

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