Documentation
¶
Overview ¶
Package treeprint provides a simple ASCII tree composing tool. Forked from: https://github.com/xlab/treeprint
Index ¶
- Variables
- type EdgeType
- type MetaValue
- type Node
- func (n *Node) AddBranch(v Value) Tree
- func (n *Node) AddGap() Tree
- func (n *Node) AddMetaBranch(meta MetaValue, v Value) Tree
- func (n *Node) AddMetaNode(meta MetaValue, v Value) Tree
- func (n *Node) AddNode(v Value) Tree
- func (n *Node) Branch() Tree
- func (n *Node) Bytes() []byte
- func (n *Node) FindByMeta(meta MetaValue) Tree
- func (n *Node) FindByValue(value Value) Tree
- func (n *Node) FindLastNode() Tree
- func (n *Node) SetMetaValue(meta MetaValue)
- func (n *Node) SetValue(value Value)
- func (n *Node) String() string
- func (n *Node) VisitAll(fn NodeVisitor)
- type NodeVisitor
- type Tree
- type Value
Constants ¶
This section is empty.
Variables ¶
View Source
var IndentSize = 3
IndentSize is the number of spaces per tree level.
Functions ¶
This section is empty.
Types ¶
type Node ¶
func (*Node) FindByMeta ¶
func (*Node) FindByValue ¶
func (*Node) FindLastNode ¶
func (*Node) SetMetaValue ¶
func (*Node) VisitAll ¶
func (n *Node) VisitAll(fn NodeVisitor)
type NodeVisitor ¶
type NodeVisitor func(item *Node)
NodeVisitor function type for iterating over nodes
type Tree ¶
type Tree interface {
// AddGap adds a new gap to a branch.
AddGap() Tree
// AddNode adds a new Node to a branch.
AddNode(v Value) Tree
// AddMetaNode adds a new Node with meta value provided to a branch.
AddMetaNode(meta MetaValue, v Value) Tree
// AddBranch adds a new branch Node (a level deeper).
AddBranch(v Value) Tree
// AddMetaBranch adds a new branch Node (a level deeper) with meta value provided.
AddMetaBranch(meta MetaValue, v Value) Tree
// Branch converts a leaf-Node to a branch-Node,
// applying this on a branch-Node does no effect.
Branch() Tree
// FindByMeta finds a Node whose meta value matches the provided one by reflect.DeepEqual,
// returns nil if not found.
FindByMeta(meta MetaValue) Tree
// FindByValue finds a Node whose value matches the provided one by reflect.DeepEqual,
// returns nil if not found.
FindByValue(value Value) Tree
// returns the last Node of a tree
FindLastNode() Tree
// String renders the tree or subtree as a string.
String() string
// Bytes renders the tree or subtree as byteslice.
Bytes() []byte
SetValue(value Value)
SetMetaValue(meta MetaValue)
// VisitAll iterates over the tree, branches and nodes.
// If need to iterate over the whole tree, use the root Node.
// Note this method uses a breadth-first approach.
VisitAll(fn NodeVisitor)
}
Tree represents a tree structure with leaf-nodes and branch-nodes.
func NewWithRoot ¶
NewWithRoot Generates new tree with the given root value
Click to show internal directories.
Click to hide internal directories.