Documentation ¶
Overview ¶
Package tree provides abstract tree operations.
Since 0.1.5
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DepthFirst ¶
DepthFirst walks through a tree in a depth-first manner: process children in order then their parent.
Since 0.1.5
func String ¶
String converts a Tree into a multiline string.
A tree node is in form of
<income-label>-><node-id>+<step>*<fanout-count>=<value>
E.g.:
000->#000+2*3 001->#001+4*2 003->#004+1=0 006->#007+2=1 004->#005+1=2 006->#008+2=3 002->#002+3=4 006->#006+2=5 006->#009+2=6 003->#003+5=7`[1:]
Since 0.1.5
Types ¶
type Tree ¶
type Tree interface { // Child returns the child of a node // // Since 0.1.5 Child(node, label interface{}) interface{} // Labels returns the outgoing branch labels from a node. // // Since 0.1.5 Labels(node interface{}) []interface{} // NodeID returns the a node id string. // // Since 0.1.5 NodeID(node interface{}) string // LabelInfo returns a string representation of a branch label. // // Since 0.1.5 LabelInfo(label interface{}) string // NodeInfo returns string describing the node. // // Since 0.1.5 NodeInfo(node interface{}) string // LeafVal returns the value if the node is leaf. // // Since 0.1.5 LeafVal(node interface{}) (interface{}, bool) }
Tree defines required functions to convert a tree-like data structure into string.
A nil indicates root node.
Since 0.1.5
Click to show internal directories.
Click to hide internal directories.