Improved variable definitions
This commit is contained in:
parent
0b4b10ed4c
commit
57c9fc22d1
7 changed files with 48 additions and 22 deletions
|
@ -54,6 +54,23 @@ func (expr *Expression) Close() {
|
|||
pool.Put(expr)
|
||||
}
|
||||
|
||||
// EachLeaf iterates through all leaves in the tree.
|
||||
func (expr *Expression) EachLeaf(callBack func(*Expression) error) error {
|
||||
if expr.IsLeaf() {
|
||||
return callBack(expr)
|
||||
}
|
||||
|
||||
for _, child := range expr.Children {
|
||||
err := child.EachLeaf(callBack)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveChild removes a child from the expression.
|
||||
func (expr *Expression) RemoveChild(child *Expression) {
|
||||
for i, c := range expr.Children {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue