In that case, I would either define different methods or use a different sentinel value to indicate pruning, like a public static Object PRUNE = new Object(); somewhere. Then, the each method does not do if(closure()) it.prune() but if(PRUNE == closure()) it.prune().
On Fri, Dec 4, 2015 at 12:14 PM, Felix Dorner <[email protected]> wrote: > > > while (iterator.hasNext()){ >> Object next = it.next() >> doSomethingWith(next) >> if (!childrenAreInteresting(next)){ >> it.prune() // this skips the subtree of the current element >> } >> } >> > This should be iterator.prune() >
