Skip to content

conditioniterator adds root node even if it doesn't satisfy condition #4

@houssamya

Description

@houssamya

If one calls
t.conditioniterator(n, condition)
and node n does not satisfy the condition, it will still get added to the returned list of IDs, because of the following code:


function val = recurse(node)        

        val = node;  % <--- first, node is added...

        content = obj.Node{val};

        if obj.isleaf(node) || ~condition(content) % ...THEN, the condition is checked 

            return

        else

            % bla

This only happens for the node passed as argument (the "root" of the traversal). For subsequent nodes visited in the function, they are checked before the recursive call. Which, incidentally, makes the above bolded check redundant.
So it seems the solution is to remove the redundant check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions