reorder functions in file
This commit is contained in:
parent
0ed88f9c62
commit
50c67f95fa
@ -72,19 +72,24 @@ func (n *Node) HardwareType() HardwareType {
|
||||
return ht
|
||||
}
|
||||
|
||||
// Values from json root
|
||||
func (n *Node) Values() ([]Value, error) {
|
||||
ret := []Value{}
|
||||
err := n.Walk(func(val Value) error {
|
||||
ret = append(ret, val)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Walk from json root
|
||||
func (n *Node) Walk(fn Visitor) error {
|
||||
return n.walk(fn, Value{Hardware: []Hardware{}}, 0, 0)
|
||||
}
|
||||
|
||||
func (n *Node) childDeviceTotals() map[HardwareType]int {
|
||||
totals := map[HardwareType]int{}
|
||||
for _, child := range n.Children {
|
||||
totals[child.HardwareType()]++
|
||||
}
|
||||
return totals
|
||||
}
|
||||
|
||||
func (n *Node) walk(fn Visitor, ctx Value, hwIndex, hwTotal int) error {
|
||||
if n.IsValue() {
|
||||
ctx.Label = n.Text
|
||||
@ -115,17 +120,12 @@ func (n *Node) walk(fn Visitor, ctx Value, hwIndex, hwTotal int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Values from json root
|
||||
func (n *Node) Values() ([]Value, error) {
|
||||
ret := []Value{}
|
||||
err := n.Walk(func(val Value) error {
|
||||
ret = append(ret, val)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
func (n *Node) childDeviceTotals() map[HardwareType]int {
|
||||
totals := map[HardwareType]int{}
|
||||
for _, child := range n.Children {
|
||||
totals[child.HardwareType()]++
|
||||
}
|
||||
return ret, nil
|
||||
return totals
|
||||
}
|
||||
|
||||
// Stringify tree
|
||||
|
||||
Loading…
Reference in New Issue
Block a user