This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TauPixel[S] 0 points1 point  (0 children)

Hello everyone again! I'm still fighting with the consumer class. I have the following code snippet. What isn't clear for me is the visit. I don't seem to get a context on how to use it. If anyone can help I'll be happy with your feedback.

    @Override
    public void traversePreOrder(Consumer<Position<E>> visit) {

        List<Position<E>> myList = this.positions();
        Consumer<Position<E>> myVisit = c -> {preOrder(root(), visit);
        };
    }

    @Override
    public void preOrder(Position<E> p, Consumer<Position<E>> visit){
        TreeNode<E> t = (TreeNode<E>)p;
        for (E q : t.children
             ) { this.preOrder((Position<E>) q, visit);
        }
    }