yq/pkg/yqlib/treeops/operator_union.go

20 lines
484 B
Go
Raw Normal View History

2020-10-17 11:10:47 +00:00
package treeops
2020-10-21 01:54:58 +00:00
import "container/list"
2020-10-17 11:10:47 +00:00
2020-10-21 01:54:58 +00:00
func UnionOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *PathTreeNode) (*list.List, error) {
2020-10-17 11:10:47 +00:00
lhs, err := d.getMatchingNodes(matchingNodes, pathNode.Lhs)
if err != nil {
return nil, err
}
rhs, err := d.getMatchingNodes(matchingNodes, pathNode.Rhs)
if err != nil {
return nil, err
}
for el := rhs.Front(); el != nil; el = el.Next() {
node := el.Value.(*CandidateNode)
2020-10-21 01:54:58 +00:00
lhs.PushBack(node)
2020-10-17 11:10:47 +00:00
}
return lhs, nil
}